From 25c44207be9be11a5fae6e49145f87e096fe85e4 Mon Sep 17 00:00:00 2001 From: Estevao Soares dos Santos Date: Fri, 14 Sep 2018 21:34:48 +0100 Subject: [PATCH] fix: allow escaping of colons Previously, you couldn't escape colons (as they were semi-magic markdown characters). Colons (:) can now be backslash escaped. --- src/subParsers/encodeBackslashEscapes.js | 2 +- test/issues/#510.specific-string-gets-removed-from-text.html | 2 ++ test/issues/#510.specific-string-gets-removed-from-text.md | 3 +++ 3 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 test/issues/#510.specific-string-gets-removed-from-text.html create mode 100644 test/issues/#510.specific-string-gets-removed-from-text.md diff --git a/src/subParsers/encodeBackslashEscapes.js b/src/subParsers/encodeBackslashEscapes.js index 7909ed90b..1c0876d19 100644 --- a/src/subParsers/encodeBackslashEscapes.js +++ b/src/subParsers/encodeBackslashEscapes.js @@ -14,7 +14,7 @@ showdown.subParser('encodeBackslashEscapes', function (text, options, globals) { text = globals.converter._dispatch('encodeBackslashEscapes.before', text, options, globals); text = text.replace(/\\(\\)/g, showdown.helper.escapeCharactersCallback); - text = text.replace(/\\([`*_{}\[\]()>#+.!~=|-])/g, showdown.helper.escapeCharactersCallback); + text = text.replace(/\\([`*_{}\[\]()>#+.!~=|:-])/g, showdown.helper.escapeCharactersCallback); text = globals.converter._dispatch('encodeBackslashEscapes.after', text, options, globals); return text; diff --git a/test/issues/#510.specific-string-gets-removed-from-text.html b/test/issues/#510.specific-string-gets-removed-from-text.html new file mode 100644 index 000000000..a4657f157 --- /dev/null +++ b/test/issues/#510.specific-string-gets-removed-from-text.html @@ -0,0 +1,2 @@ +

[^1]:a

+

[^1]:a

diff --git a/test/issues/#510.specific-string-gets-removed-from-text.md b/test/issues/#510.specific-string-gets-removed-from-text.md new file mode 100644 index 000000000..0abb73d92 --- /dev/null +++ b/test/issues/#510.specific-string-gets-removed-from-text.md @@ -0,0 +1,3 @@ +\[^1]:a + +[^1]\:a