From ca72f859a49426522b2de905134decfa987e0dbc Mon Sep 17 00:00:00 2001 From: Brandon Frohs <bfrohs@gmail.com> Date: Tue, 11 Dec 2012 01:10:27 -0500 Subject: [PATCH] [markdown] Fix incorrect highlighting of linked images. --- mode/markdown/markdown.js | 4 ++-- mode/markdown/test.js | 14 ++++++++++++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/mode/markdown/markdown.js b/mode/markdown/markdown.js index 34125c9c..2d81bfb5 100644 --- a/mode/markdown/markdown.js +++ b/mode/markdown/markdown.js @@ -246,8 +246,8 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) { return getType(state); } - if (ch === '!' && stream.match(/\[.*\] ?(?:\(|\[)/, false)) { - stream.match(/\[.*\]/); + if (ch === '!' && stream.match(/\[[^\]]*\] ?(?:\(|\[)/, false)) { + stream.match(/\[[^\]]*\]/); state.inline = state.f = linkHref; return image; } diff --git a/mode/markdown/test.js b/mode/markdown/test.js index 7572db51..90c77e66 100644 --- a/mode/markdown/test.js +++ b/mode/markdown/test.js @@ -719,6 +719,20 @@ MT.testMode( ] ); +// Inline link with image +MT.testMode( + 'linkImage', + '[](http://example.com/) bar', + [ + 'link', '[', + 'tag', '![foo]', + 'string', '(http://example.com/)', + 'link', ']', + 'string', '(http://example.com/)', + null, ' bar' + ] +); + // Inline link with Em MT.testMode( 'linkEm', -- GitLab