Skip to content

Commit 9f20c46

Browse files
committed
allow ONE level of matching parenthesis in links.
NON-COMPLIANT with commonmark! adjust test #468 accordingly.
1 parent fc17a2c commit 9f20c46

File tree

3 files changed

+9
-5
lines changed

3 files changed

+9
-5
lines changed

lib/marked.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -526,7 +526,7 @@ inline.tag = edit(inline.tag)
526526
.getRegex();
527527

528528
inline._inside = /(?:\[[^\]]*\]|\\[\[\]]|[^\[\]]|\](?=[^\[]*\]))*/;
529-
inline._href = /\s*<?((?:\\[()]?|[^\s()\\])*?)>?(?:\s+['"]([\s\S]*?)['"])?\s*/;
529+
inline._href = /\s*<?((?:\\[()]?|\([^\s()\\]*\)|[^\s()\\])*?)>?(?:\s+['"]([\s\S]*?)['"])?\s*/;
530530

531531
inline.link = edit(inline.link)
532532
.replace('inside', inline._inside)

test/new/cm_links.html

+4-2
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,11 @@ <h3 id="example-467">Example 467</h3>
3838

3939
<p><a href="(foo)">link</a></p>
4040

41-
<h3 id="example-468">Example 468</h3>
41+
<h3 id="example-4680">Example 4680</h3>
4242

43-
<p><a href="foo(and(bar))">link</a></p>
43+
<p>ONE LEVEL of parentheses are allowed without escaping, as long as they are balanced:</p>
44+
45+
<p><a href="foo(bar)">link</a></p>
4446

4547
<h3 id="example-469">Example 469</h3>
4648

test/new/cm_links.md

+4-2
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,11 @@ bar>)
3939

4040
[link](\(foo\))
4141

42-
### Example 468
42+
### Example 4680
4343

44-
[link](foo(and(bar)))
44+
ONE LEVEL of parentheses are allowed without escaping, as long as they are balanced:
45+
46+
[link](foo(bar))
4547

4648
### Example 469
4749

0 commit comments

Comments
 (0)