From 330e4fc451ea3f0b4b7bfc7bf77c45c0200ff06e Mon Sep 17 00:00:00 2001 From: Tony Brix Date: Tue, 2 Jul 2019 08:40:16 -0500 Subject: [PATCH 1/2] add test --- test/specs/new/links_paren.html | 5 +++++ test/specs/new/links_paren.md | 5 +++++ 2 files changed, 10 insertions(+) create mode 100644 test/specs/new/links_paren.html create mode 100644 test/specs/new/links_paren.md 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")) From 0dc60b6627f1bcd597abf1c121a952a7c9b7462a Mon Sep 17 00:00:00 2001 From: Tony Brix Date: Tue, 2 Jul 2019 08:40:28 -0500 Subject: [PATCH 2/2] fix calculation --- lib/marked.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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] = '';