Sha256: 9f93d2e83f3f75d8b12796db27efcfc84d54c8e54c624f6ba3a870bfcadf27af
Contents?: true
Size: 910 Bytes
Versions: 13
Compression:
Stored size: 910 Bytes
Contents
module Rouge module Lexers class Diff < RegexLexer 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 =~ /\A---.*?\n\+\+\+/m end state :header do rule /^diff .*?\n(?=---|\+\+\+)/m, 'Generic.Heading' rule /^--- .*?\n/, 'Generic.Deleted' rule /^\+\+\+ .*?\n/, 'Generic.Inserted' end state :diff do rule /@@ -\d+,\d+ \+\d+,\d+ @@.*?\n/, 'Generic.Heading' rule /^\+.*?\n/, 'Generic.Inserted' rule /^-.*?\n/, 'Generic.Deleted' rule /^ .*?\n/, 'Text' rule /^.*?\n/, 'Error' end state :root do mixin :header mixin :diff end end end end
Version data entries
13 entries across 13 versions & 1 rubygems