Skip to content

Commit

Permalink
Link parenthesis (markedjs#1509)
Browse files Browse the repository at this point in the history
Link parenthesis
  • Loading branch information
UziTech committed Jul 2, 2019
2 parents cb679e7 + 0dc60b6 commit a69bf7e
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/marked.js
Expand Up @@ -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] = '';
Expand Down
5 changes: 5 additions & 0 deletions test/specs/new/links_paren.html
@@ -0,0 +1,5 @@
<p>(<a href="http://example.com/1">one</a>) (<a href="http://example.com/2">two</a>)</p>

<p>(<a href="http://example.com/1">one</a>) (<a href="http://example.com/2">two</a>)</p>

<p>(<a href="http://example.com/1" title="a">one</a>) (<a href="http://example.com/2" title="b">two</a>)</p>
5 changes: 5 additions & 0 deletions 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"))

0 comments on commit a69bf7e

Please sign in to comment.