diff --git a/lib/marked.js b/lib/marked.js index d07c39618f..52c178bc30 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] = '';