Skip to content

Commit 0479147

Browse files
committed
Fix formatted URL from becoming an autolink
Closes GH-10.
1 parent 7f8bd88 commit 0479147

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

lib/util/format-link-as-autolink.js

+4
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ function formatLinkAsAutolink(node, context) {
1111
node.url &&
1212
// And there’s a no title…
1313
!node.title &&
14+
// And the content of `node` is a single text node…
15+
node.children &&
16+
node.children.length === 1 &&
17+
node.children[0].type === 'text' &&
1418
// And if the url is the same as the content…
1519
(raw === node.url || 'mailto:' + raw === node.url) &&
1620
// And that starts w/ a protocol…

test.js

+4
Original file line numberDiff line numberDiff line change
@@ -2720,5 +2720,9 @@ test('roundtrip', function (t) {
27202720

27212721
t.equal(to(from(doc)), doc, 'should roundtrip adjacent block quotes')
27222722

2723+
doc = '[**https://unifiedjs.com/**](https://unifiedjs.com/)\n'
2724+
2725+
t.equal(to(from(doc)), doc, 'should roundtrip formatted URLs')
2726+
27232727
t.end()
27242728
})

0 commit comments

Comments
 (0)