diff --git a/lib/marked.js b/lib/marked.js index a6c5d0456c..192bd644f0 100644 --- a/lib/marked.js +++ b/lib/marked.js @@ -728,7 +728,7 @@ InlineLexer.prototype.output = function(src) { if (cap = this.rules.link.exec(src)) { var lastParenIndex = findClosingBracket(cap[2], '()'); if (lastParenIndex > -1) { - var linkLen = cap[0].length - (cap[2].length - lastParenIndex) - (cap[3] || '').length; + var linkLen = 4 + cap[1].length + lastParenIndex; cap[2] = cap[2].substring(0, lastParenIndex); cap[0] = cap[0].substring(0, linkLen).trim(); cap[3] = ''; diff --git a/test/specs/new/links_paren.html b/test/specs/new/links_paren.html new file mode 100644 index 0000000000..375c0f0cf1 --- /dev/null +++ b/test/specs/new/links_paren.html @@ -0,0 +1,5 @@ +

(one) (two)

+ +

(one) (two)

+ +

(one) (two)

diff --git a/test/specs/new/links_paren.md b/test/specs/new/links_paren.md new file mode 100644 index 0000000000..96f106ce03 --- /dev/null +++ b/test/specs/new/links_paren.md @@ -0,0 +1,5 @@ +([one](http://example.com/1)) ([two](http://example.com/2)) + +([one](http://example.com/1)) ([two](http://example.com/2)) + +([one](http://example.com/1 "a")) ([two](http://example.com/2 "b"))