diff --git a/lib/rouge/lexers/markdown.rb b/lib/rouge/lexers/markdown.rb index a0e5fd0176..d9e368a14e 100644 --- a/lib/rouge/lexers/markdown.rb +++ b/lib/rouge/lexers/markdown.rb @@ -102,7 +102,7 @@ def html end # links and images - rule %r/(!?\[)(#{edot}*?)(\])(?=[\[(])/ do + rule %r/(!?\[)(#{edot}*?|[^\]]*?)(\])(?=[\[(])/ do groups Punctuation, Name::Variable, Punctuation push :link end diff --git a/spec/visual/samples/markdown b/spec/visual/samples/markdown index 42f992e900..be2a700002 100644 --- a/spec/visual/samples/markdown +++ b/spec/visual/samples/markdown @@ -1091,3 +1091,9 @@ $ echo "Sample feature output" [This is a link to a TOML section `[with brackets]` (and backticks)](example.com) [This is a link to a TOML section `[[with double brackets]]` (and backticks)](example.com) [This is not a link `with backticks`] (example.com) + +This link has text before it, [it's over two (lines), +has (parens too)](example.com), and text after it. + +[this is not a +link]