Skip to content

Commit

Permalink
Fix rouge-ruby#1022 by supporting diffs other than unified.
Browse files Browse the repository at this point in the history
Close rouge-ruby#846 as it conflicts and this commit differentiates further.
  • Loading branch information
vidarh committed Jan 18, 2019
1 parent e957c74 commit f170a04
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions lib/rouge/lexers/diff.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,18 @@ def self.detect?(text)

state :root do
rule(/^ .*$\n?/, Text)
rule(/^---$\n?/, Text)
rule(/^---$\n?/, Punctuation)
rule(/^[+>]+.*$\n?/, Generic::Inserted)
rule(/^\+.*$\n?/, Generic::Inserted)
rule(/^-+.*$\n?/, Generic::Deleted)
rule(/^[-<]+.*$\n?/, Generic::Deleted)
rule(/^!.*$\n?/, Generic::Strong)
rule(/^@.*$\n?/, Generic::Subheading)
rule(/^([Ii]ndex|diff).*$\n?/, Generic::Heading)
rule(/^(@@[^@]*@@)([^\n]*\n)/) do
groups Punctuation, Text
end
rule(/^\w.*$\n?/, Punctuation)
rule(/^=.*$\n?/, Generic::Heading)
rule(/.*$\n?/, Text)
rule(/\s.*$\n?/, Text)
end
end
end
Expand Down

0 comments on commit f170a04

Please sign in to comment.