Skip to content

Commit

Permalink
Fix parenthese after links in markdown lexer
Browse files Browse the repository at this point in the history
  • Loading branch information
Ravlen committed Mar 4, 2020
1 parent abe35e8 commit ffe07cb
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 15 deletions.
17 changes: 3 additions & 14 deletions lib/rouge/lexers/markdown.rb
Original file line number Diff line number Diff line change
Expand Up @@ -136,10 +136,9 @@ def html
pop!
end

rule %r/[(]/ do
token Punctuation
push :inline_title
push :inline_url
rule %r/(\()(#{edot}*?)(\))/ do
groups Punctuation, Str::Other, Punctuation
pop!
end

rule %r/[ \t]+/, Text
Expand Down Expand Up @@ -167,16 +166,6 @@ def html
rule(//) { pop! }
end

state :inline_title do
rule %r/[)]/, Punctuation, :pop!
mixin :title
end

state :inline_url do
rule %r/[^<\s)]+/, Str::Other, :pop!
rule %r/\s+/m, Text
mixin :url
end
end
end
end
11 changes: 10 additions & 1 deletion spec/visual/samples/markdown
Original file line number Diff line number Diff line change
Expand Up @@ -1090,4 +1090,13 @@ $ echo "Sample feature output"
[This is a link `with backticks`](example.com)
[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 is not a link] (example.com)

[This link is followed by text in](example.com) (parentheses)
[This link is followed by text in](example.com) (paren theses)
[This link is followed by text in](example.com) paren (theses)

[This link is referenced][exampleref]

[exampleref]: http://example.com

0 comments on commit ffe07cb

Please sign in to comment.