diff --git a/src/commonmark-rules.js b/src/commonmark-rules.js index 77a4c529..66ee01db 100644 --- a/src/commonmark-rules.js +++ b/src/commonmark-rules.js @@ -155,7 +155,7 @@ rules.inlineLink = { var href = node.getAttribute('href') var title = cleanAttribute(node.getAttribute('title')) if (title) title = ' "' + title + '"' - return '[' + content + '](' + href + title + ')' + return '[' + content.trim() + '](' + href + title + ')' } } @@ -169,6 +169,7 @@ rules.referenceLink = { }, replacement: function (content, node, options) { + content = content.trim() var href = node.getAttribute('href') var title = cleanAttribute(node.getAttribute('title')) if (title) title = ' "' + title + '"' diff --git a/test/index.html b/test/index.html index 26fa586c..281b52cd 100644 --- a/test/index.html +++ b/test/index.html @@ -227,6 +227,22 @@
[Some `code`](http://example.com/code)+
[heading +=======](http://example.com/heading)+
[paragraph](http://example.com/paragraph)+
[div](http://example.com/div)+
[Reference link][1]