Class: Crosstest::Core::Util::Highlight

Inherits:
Object
  • Object
show all
Defined in:
lib/crosstest/core/util.rb

Instance Method Summary collapse

Constructor Details

#initialize(opts) ⇒ Highlight

Returns a new instance of Highlight.



136
137
138
139
# File 'lib/crosstest/core/util.rb', line 136

def initialize(opts)
  @lexer = Rouge::Lexer.find(opts[:language]) || Rouge::Lexer.guess_by_filename(opts[:filename])
  @formatter = opts[:formatter]
end

Instance Method Details

#highlight(source) ⇒ Object



141
142
143
# File 'lib/crosstest/core/util.rb', line 141

def highlight(source)
  Rouge.highlight(source, @lexer, @formatter)
end