Skip to content

Commit

Permalink
Merge pull request markedjs#996 from Feder1co5oave/fix_link_desc
Browse files Browse the repository at this point in the history
Handle backslash-escaped brackets in link description
  • Loading branch information
joshbruce authored Jan 5, 2018
2 parents c4c3ffc + 5ca9faa commit b4e50c7
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/marked.js
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,7 @@ var inline = {
text: /^[\s\S]+?(?=[\\<!\[_*`]| {2,}\n|$)/
};

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

inline.link = replace(inline.link)
Expand Down
14 changes: 14 additions & 0 deletions test/tests/links_inline_style.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,17 @@
<p><a href="/url/has space/" title="url has space and title">URL and title</a>.</p>

<p><a href="">Empty</a>.</p>

<p>Now some links with special link text.</p>

<p><a href="http://abc.com">hello [ ok</a></p>

<p><a href="http://abc.com">hello [] with balanced brackets</a></p>

<p><a href="http://abc.com">hello! [ ] with escaped balanced brackets</a></p>

<p><a href="http://abc.com">hello \ with a backslash</a></p>

<p><a href="http://abc.com">link w/ escaped back\slash</a></p>

<p><a href="http://abc.com">link w/ back\slash\</a></p>
14 changes: 14 additions & 0 deletions test/tests/links_inline_style.text
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,17 @@ Just a [URL](/url/).
[URL and title]( /url/has space/ "url has space and title").

[Empty]().

Now some links with special link text.

[hello \[ ok](http://abc.com)

[hello [] with balanced brackets](http://abc.com)

[hello! \[ \] with escaped balanced brackets](http://abc.com)

[hello \ with a backslash](http://abc.com)

[link w/ escaped back\\slash](http://abc.com)

[link w/ back\\slash\\](http://abc.com)

0 comments on commit b4e50c7

Please sign in to comment.