handle escaped brackets in link description

This commit is contained in:
Federico Soave 2018-01-03 01:54:49 +01:00
parent 18deb8b071
commit 1949dfdf21
3 changed files with 29 additions and 1 deletions

View File

@ -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)

View File

@ -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>

View File

@ -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)