Class: Luo::Helpers::HTMLwithRouge

Inherits:
Redcarpet::Render::HTML
  • Object
show all
Defined in:
lib/luo/helpers.rb

Instance Method Summary collapse

Instance Method Details

#block_code(code, language) ⇒ Object



8
9
10
11
12
13
# File 'lib/luo/helpers.rb', line 8

def block_code(code, language)
  lexer = Rouge::Lexer.find(language) || Rouge::Lexers::PlainText
  formatter = Rouge::Formatters::HTML.new
  highlighted_code = formatter.format(lexer.lex(code))
  "<pre class=\"highlight\">#{highlighted_code}</pre>"
end