Skip to content

Commit

Permalink
allow ONE level of matching parenthesis in links.
Browse files Browse the repository at this point in the history
NON-COMPLIANT with commonmark!
adjust test #468 accordingly.
  • Loading branch information
Feder1co5oave committed Mar 5, 2018
1 parent fc17a2c commit 9f20c46
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion lib/marked.js
Original file line number Diff line number Diff line change
Expand Up @@ -526,7 +526,7 @@ inline.tag = edit(inline.tag)
.getRegex();

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

inline.link = edit(inline.link)
.replace('inside', inline._inside)
Expand Down
6 changes: 4 additions & 2 deletions test/new/cm_links.html
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,11 @@ <h3 id="example-467">Example 467</h3>

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

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

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

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

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

Expand Down
6 changes: 4 additions & 2 deletions test/new/cm_links.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,11 @@ bar>)

[link](\(foo\))

### Example 468
### Example 4680

[link](foo(and(bar)))
ONE LEVEL of parentheses are allowed without escaping, as long as they are balanced:

[link](foo(bar))

### Example 469

Expand Down

0 comments on commit 9f20c46

Please sign in to comment.