Skip to content

Commit 6bae3a2

Browse files
authored
Link parenthesis (#1509)
Link parenthesis
2 parents 2a1bbed + 59ec6fb commit 6bae3a2

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

lib/marked.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -728,7 +728,7 @@ InlineLexer.prototype.output = function(src) {
728728
if (cap = this.rules.link.exec(src)) {
729729
var lastParenIndex = findClosingBracket(cap[2], '()');
730730
if (lastParenIndex > -1) {
731-
var linkLen = cap[0].length - (cap[2].length - lastParenIndex) - (cap[3] || '').length;
731+
var linkLen = 4 + cap[1].length + lastParenIndex;
732732
cap[2] = cap[2].substring(0, lastParenIndex);
733733
cap[0] = cap[0].substring(0, linkLen).trim();
734734
cap[3] = '';

test/specs/new/links_paren.html

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<p>(<a href="http://example.com/1">one</a>) (<a href="http://example.com/2">two</a>)</p>
2+
3+
<p>(<a href="http://example.com/1">one</a>) (<a href="http://example.com/2">two</a>)</p>
4+
5+
<p>(<a href="http://example.com/1" title="a">one</a>) (<a href="http://example.com/2" title="b">two</a>)</p>

test/specs/new/links_paren.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
([one](http://example.com/1)) ([two](http://example.com/2))
2+
3+
([one](http://example.com/1)) ([two](http://example.com/2))
4+
5+
([one](http://example.com/1 "a")) ([two](http://example.com/2 "b"))

0 commit comments

Comments
 (0)