diff --git a/lib/rouge/lexers/diff.rb b/lib/rouge/lexers/diff.rb index 0f44832392..71b5158502 100644 --- a/lib/rouge/lexers/diff.rb +++ b/lib/rouge/lexers/diff.rb @@ -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