Skip to content

Commit 3f1d61e

Browse files
committed
Fix to not serialize autolinks, indented code
1 parent f46d7b7 commit 3f1d61e

File tree

4 files changed

+26
-1
lines changed

4 files changed

+26
-1
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
"to-markdown.js"
3333
],
3434
"dependencies": {
35-
"mdast-util-to-markdown": "^0.5.0",
35+
"mdast-util-to-markdown": "^0.6.0",
3636
"parse-entities": "^2.0.0",
3737
"stringify-entities": "^3.1.0",
3838
"unist-util-remove-position": "^3.0.0",

readme.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,9 @@ When using the [syntax extension][extension] with `addResult`, nodes will have a
169169
There are no options, but passing [`options.quote`][quote] to
170170
`mdast-util-to-markdown` is honored for attributes.
171171

172+
this extension configures [`mdast-util-to-markdown`][to-markdown] with
173+
`fences: true` and `resourceLink: true` too, do not overwrite them!
174+
172175
## Syntax tree
173176

174177
The following interfaces are added to **[mdast][]** by this utility.

test.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1530,5 +1530,24 @@ test('mdast -> markdown', function (t) {
15301530
'should escape `<` at the start of a line'
15311531
)
15321532

1533+
t.deepEqual(
1534+
toMarkdown(
1535+
{
1536+
type: 'link',
1537+
url: 'svg:rect',
1538+
children: [{type: 'text', value: 'svg:rect'}]
1539+
},
1540+
{extensions: [mdxJsx.toMarkdown]}
1541+
),
1542+
'[svg:rect](svg:rect)\n',
1543+
'should not serialize links as autolinks'
1544+
)
1545+
1546+
t.deepEqual(
1547+
toMarkdown({type: 'code', value: 'x'}, {extensions: [mdxJsx.toMarkdown]}),
1548+
'```\nx\n```\n',
1549+
'should not serialize code as indented'
1550+
)
1551+
15331552
t.end()
15341553
})

to-markdown.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ exports.unsafe = [
88
{atBreak: true, character: '<'}
99
]
1010

11+
exports.fences = true
12+
exports.resourceLink = true
13+
1114
mdxElement.peek = peekElement
1215

1316
var encode = require('stringify-entities/light')

0 commit comments

Comments
 (0)