Sha256: 15375c431d9105bfb030470bd9fcf177123f13c04bc02295ceccec6b7aeaff09

Contents?: true

Size: 658 Bytes

Versions: 4

Compression:

Stored size: 658 Bytes

Contents

module Rouge
  module Lexers
    class Diff < RegexLexer
      tag 'diff'
      aliases 'patch'
      extensions 'diff', 'patch'

      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

4 entries across 4 versions & 1 rubygems

Version Path
rouge-0.0.6 lib/rouge/lexers/diff.rb
rouge-0.0.5 lib/rouge/lexers/diff.rb
rouge-0.0.4 lib/rouge/lexers/diff.rb
rouge-0.0.3 lib/rouge/lexers/diff.rb