From 5ca9faa4e351357319b80322c471514e052d3eb2 Mon Sep 17 00:00:00 2001 From: Federico Soave Date: Wed, 3 Jan 2018 01:54:49 +0100 Subject: [PATCH] handle escaped brackets in link description --- lib/marked.js | 2 +- test/tests/links_inline_style.html | 14 ++++++++++++++ test/tests/links_inline_style.text | 14 ++++++++++++++ 3 files changed, 29 insertions(+), 1 deletion(-) diff --git a/lib/marked.js b/lib/marked.js index 6f0e87c4c5..3590ae2655 100644 --- a/lib/marked.js +++ b/lib/marked.js @@ -459,7 +459,7 @@ var inline = { text: /^[\s\S]+?(?=[\\?(?:\s+['"]([\s\S]*?)['"])?\s*/; inline.link = replace(inline.link) diff --git a/test/tests/links_inline_style.html b/test/tests/links_inline_style.html index 09df236ed7..04921aa080 100644 --- a/test/tests/links_inline_style.html +++ b/test/tests/links_inline_style.html @@ -13,3 +13,17 @@

URL and title.

Empty.

+ +

Now some links with special link text.

+ +

hello [ ok

+ +

hello [] with balanced brackets

+ +

hello! [ ] with escaped balanced brackets

+ +

hello \ with a backslash

+ +

link w/ escaped back\slash

+ +

link w/ back\slash\

\ No newline at end of file diff --git a/test/tests/links_inline_style.text b/test/tests/links_inline_style.text index 8c8eb4902e..6a94265871 100644 --- a/test/tests/links_inline_style.text +++ b/test/tests/links_inline_style.text @@ -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) \ No newline at end of file