Class: Polytrix::Util::Highlight

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

Instance Method Summary collapse

Constructor Details

#initialize(opts) ⇒ Highlight

Returns a new instance of Highlight.



127
128
129
130
# File 'lib/polytrix/util.rb', line 127

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



132
133
134
# File 'lib/polytrix/util.rb', line 132

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