Module: Middleman::Syntax::Highlighter
- Defined in:
- lib/middleman-syntax/highlighter.rb
Class Method Summary collapse
-
.highlight(code, language = nil, opts = {}) ⇒ Object
A helper module for highlighting code.
Class Method Details
.highlight(code, language = nil, opts = {}) ⇒ Object
A helper module for highlighting code
9 10 11 12 13 14 15 16 17 18 |
# File 'lib/middleman-syntax/highlighter.rb', line 9 def self.highlight(code, language=nil, opts={}) lexer = Rouge::Lexer.find_fancy(language, code) || Rouge::Lexers::PlainText = .to_h.merge(opts) [:css_class] = [ [:css_class], lexer.tag ].join(' ') = .delete(:lexer_options) formatter = Middleman::Syntax::Formatters::HTML.new() formatter.format(lexer.lex(code, )) end |