Module: Rabbit::Parser::Ext::Rouge
- Includes:
- GetText
- Defined in:
- lib/rabbit/parser/ext/rouge.rb
Defined Under Namespace
Classes: RabbitFormatter
Constant Summary
Constants included from GetText
Class Method Summary collapse
Methods included from GetText
Class Method Details
.highlight(lang, text, logger) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/rabbit/parser/ext/rouge.rb', line 29 def highlight(lang, text, logger) lexer = ::Rouge::Lexer.find(lang).new formatter = RabbitFormatter.new block = Element::SyntaxHighlightingBlock.new text_container = Element::TextContainer.new formatter.format(lexer.lex(text.strip)) do |element| text_container << element end block << text_container block end |