Skip to content

Commit 96d3555

Browse files
committed
fix: convert json attributes to yaml syntax
1 parent 31c04dc commit 96d3555

File tree

4 files changed

+50
-7
lines changed

4 files changed

+50
-7
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@
9999
"rehype-sort-attributes": "^5.0.1",
100100
"remark-emoji": "^5.0.2",
101101
"remark-gfm": "^4.0.1",
102-
"remark-mdc": "https://pkg.pr.new/remark-mdc@3401af1",
102+
"remark-mdc": "https://pkg.pr.new/remark-mdc@597e125",
103103
"remark-parse": "^11.0.0",
104104
"remark-rehype": "^11.1.2",
105105
"remark-stringify": "^11.0.0",

pnpm-lock.yaml

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/runtime/stringify/mdc-remark.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ const mdcRemarkNodeHandlers = {
166166
// if node is not a list item or paragraph and has no children, wrap it in a paragraph and render it as a text component
167167
if (!['li', 'p'].includes(parent?.tagName || '') && !node.children?.length) {
168168
const attributes = Object.entries(node.properties || {})
169-
if (attributes.length < 4 && !attributes.some(([key]) => key.includes('\n'))) {
169+
if (attributes.length < 4 && !attributes.some(([key, value]) => String(value).includes('\n') || key.startsWith(':'))) {
170170
return {
171171
type: 'paragraph',
172172
children: [{

test/stringify/format.test.ts

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,47 @@ describe('stringify format', () => {
4343
const result = await stringifyMarkdown(body)
4444
expect(result).toBe(md)
4545
})
46+
47+
it('should stringify format correctly with yaml props', async () => {
48+
const md = [
49+
'::page-container',
50+
'---',
51+
'simple-array:',
52+
' - item1',
53+
' - item2',
54+
' - item3',
55+
'---',
56+
'::',
57+
'',
58+
'::page-container',
59+
'---',
60+
'items:',
61+
' - name: Item 1',
62+
' description: First item',
63+
' - name: Item 2',
64+
' description: Second item',
65+
'---',
66+
'::',
67+
'',
68+
'::page-container',
69+
'---',
70+
'attributes:',
71+
' - domains:',
72+
' - internal',
73+
' - env:',
74+
' - dev',
75+
' - staging',
76+
' - prod',
77+
' - dogs:',
78+
' - husky',
79+
' - beagle',
80+
'---',
81+
'::',
82+
'',
83+
].join('\n')
84+
85+
const { body } = await parseMarkdown(md)
86+
const result = await stringifyMarkdown(body)
87+
expect(result).toBe(md)
88+
})
4689
})

0 commit comments

Comments
 (0)