Sha256: 18c3e47ac4b3ccaaa7ab6f5e4e3643b02eefa0c8611884026080cf13a1525740

Contents?: true

Size: 859 Bytes

Versions: 20

Compression:

Stored size: 859 Bytes

Contents

module Rouge
  module Lexers
    class Diff < RegexLexer
      title 'diff'
      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.start_with?('--- ')
      end

      state :root do
        rule(/^ .*$\n?/, Text)
        rule(/^---$\n?/, Text)
        rule(/^\+.*$\n?/, Generic::Inserted)
        rule(/^-+.*$\n?/, Generic::Deleted)
        rule(/^!.*$\n?/, Generic::Strong)
        rule(/^@.*$\n?/, Generic::Subheading)
        rule(/^([Ii]ndex|diff).*$\n?/, Generic::Heading)
        rule(/^=.*$\n?/, Generic::Heading)
        rule(/.*$\n?/, Text)
      end
    end
  end
end

Version data entries

20 entries across 18 versions & 5 rubygems

Version Path
files.com-1.0.55 docs/vendor/bundle/ruby/2.5.0/gems/rouge-2.2.1/lib/rouge/lexers/diff.rb
rouge_ecl-1.0.0 lib/rouge/lexers/diff.rb
rouge-2.2.1 lib/rouge/lexers/diff.rb
rouge-2.2.0 lib/rouge/lexers/diff.rb
rougegal-2.1.2 lib/rouge/lexers/diff.rb
tdiary-5.0.5 vendor/bundle/gems/tdiary-5.0.4/vendor/bundle/gems/rouge-2.0.7/lib/rouge/lexers/diff.rb
tdiary-5.0.5 vendor/bundle/gems/rouge-2.1.1/lib/rouge/lexers/diff.rb
tdiary-5.0.5 vendor/bundle/gems/rouge-2.0.7/lib/rouge/lexers/diff.rb
rouge-2.1.1 lib/rouge/lexers/diff.rb
rouge-2.1.0 lib/rouge/lexers/diff.rb
tdiary-5.0.4 vendor/bundle/gems/rouge-2.0.7/lib/rouge/lexers/diff.rb
rouge-2.0.7 lib/rouge/lexers/diff.rb
rouge-2.0.6 lib/rouge/lexers/diff.rb
rouge-2.0.5 lib/rouge/lexers/diff.rb
rouge-2.0.3 lib/rouge/lexers/diff.rb
rouge-2.0.2 lib/rouge/lexers/diff.rb
rouge-2.0.1 lib/rouge/lexers/diff.rb
rouge-2.0.0 lib/rouge/lexers/diff.rb
rouge-1.11.1 lib/rouge/lexers/diff.rb
rouge-1.11.0 lib/rouge/lexers/diff.rb