Sha256: a4374c090eb38f7bbbfb36d1d8607c25facf331fba2223d53f17f13ab4d0a7bd
Contents?: true
Size: 945 Bytes
Versions: 14
Compression:
Stored size: 945 Bytes
Contents
module Rouge module Lexers class Diff < RegexLexer desc "Lexes unified diffs or patches" 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
14 entries across 14 versions & 1 rubygems