lib/rouge/lexers/diff.rb in rouge-2.2.1 vs lib/rouge/lexers/diff.rb in rouge-3.0.0
- old
+ new
@@ -7,13 +7,13 @@
tag 'diff'
aliases 'patch', 'udiff'
filenames '*.diff', '*.patch'
mimetypes 'text/x-diff', 'text/x-patch'
- def self.analyze_text(text)
- return 1 if text.start_with?('Index: ')
- return 1 if text.start_with?('diff ')
- return 0.9 if text.start_with?('--- ')
+ def self.detect?(text)
+ return true if text.start_with?('Index: ')
+ return true if text =~ %r(\Adiff[^\n]*?\ba/[^\n]*\bb/)
+ return true if text =~ /(---|[+][+][+]).*?\n(---|[+][+][+])/
end
state :root do
rule(/^ .*$\n?/, Text)
rule(/^---$\n?/, Text)