Class: Rouge::Lexers::Diff

Inherits:
RegexLexer show all
Defined in:
lib/rouge/lexers/diff.rb

Class Method Summary collapse

Methods inherited from RegexLexer

[], #get_state, get_state, #initialize, state, states, #step, #stream_tokens, #stream_with_state

Methods inherited from Rouge::Lexer

aliases, #debug, default_options, filenames, find, #get_tokens, guess, guess_by_filename, guess_by_mimetype, guess_by_source, #initialize, lex, #lex, make, mimetypes, new, #option, #options, register, #stream_tokens, tag

Constructor Details

This class inherits a constructor from Rouge::RegexLexer

Class Method Details

.analyze_text(text) ⇒ Object



9
10
11
12
13
14
# File 'lib/rouge/lexers/diff.rb', line 9

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