diff --git a/lib/rouge/lexers/markdown.rb b/lib/rouge/lexers/markdown.rb index 4feb08bc8f..4bfe7aac0d 100644 --- a/lib/rouge/lexers/markdown.rb +++ b/lib/rouge/lexers/markdown.rb @@ -32,7 +32,7 @@ def html rule %r/^#(?=[^#]).*?$/, Generic::Heading rule %r/^##*.*?$/, Generic::Subheading - rule %r/^([ \t]*)(```|~~~)([^\n]*\n)((.*?)(\2))?/m do |m| + rule %r/^([ \t]*)(`{3,}|~{3,})([^\n]*\n)((.*?)(\n\1)(\2))?/m do |m| name = m[3].strip sublexer = begin @@ -51,8 +51,10 @@ def html delegate sublexer, m[5] end - if m[6] - token Punctuation, m[6] + token Text, m[6] + + if m[7] + token Punctuation, m[7] else push do rule %r/^([ \t]*)(#{m[2]})/ do |mb| diff --git a/spec/visual/samples/markdown b/spec/visual/samples/markdown index c6deaf41fc..9a2b577275 100644 --- a/spec/visual/samples/markdown +++ b/spec/visual/samples/markdown @@ -1074,3 +1074,7 @@ can't highlight me ``` json "a string": "with a triple backtick: ```" ``` + +```` console +$ hello "world" +````