From 3a03b1d142dc8392bab89dc51986de5f7c6d6df5 Mon Sep 17 00:00:00 2001 From: Tony Brix Date: Tue, 5 Mar 2019 20:43:29 -0600 Subject: [PATCH 1/2] add link test --- test/specs/marked/marked.json | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/test/specs/marked/marked.json b/test/specs/marked/marked.json index 5f46f53640..5dd1a065c8 100644 --- a/test/specs/marked/marked.json +++ b/test/specs/marked/marked.json @@ -113,10 +113,16 @@ "html": "

test@test.com

", "example": 1347 }, - { + { "section": "Emphasis extra tests", "markdown": "_test_. _test_: _test_! _test_? _test_-", "html": "

test. test: test! test? test-

", "example": 15 + }, + { + "section": "Links", + "markdown": "[One](https://example.com/1) ([Two](https://example.com/2)) [Three](https://example.com/3)", + "html": "

One (Two) Three

", + "example": 16 } ] From 9dc35bf65a9b38859181862f0f1270bb1d10d3f2 Mon Sep 17 00:00:00 2001 From: Tony Brix Date: Tue, 5 Mar 2019 20:51:46 -0600 Subject: [PATCH 2/2] remove title from link --- lib/marked.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/marked.js b/lib/marked.js index f34e2df0bc..ac39650c77 100644 --- a/lib/marked.js +++ b/lib/marked.js @@ -721,9 +721,10 @@ InlineLexer.prototype.output = function(src) { if (cap = this.rules.link.exec(src)) { var lastParenIndex = findClosingBracket(cap[2], '()'); if (lastParenIndex > -1) { - var removeChars = cap[2].length - lastParenIndex; + var linkLen = cap[0].length - (cap[2].length - lastParenIndex) - (cap[3] || '').length; cap[2] = cap[2].substring(0, lastParenIndex); - cap[0] = cap[0].substring(0, cap[0].length - removeChars); + cap[0] = cap[0].substring(0, linkLen).trim(); + cap[3] = ''; } src = src.substring(cap[0].length); this.inLink = true;