Class: RDoc::Rouge::Formatter

Inherits:
Markup::ToHtml
  • Object
show all
Defined in:
lib/rdoc/rouge/formatter.rb

Instance Method Summary collapse

Constructor Details

#initializeFormatter

Returns a new instance of Formatter.



6
7
8
# File 'lib/rdoc/rouge/formatter.rb', line 6

def initialize
  super ::RDoc::Options.new, nil
end

Instance Method Details

#accept_verbatim(verbatim) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
# File 'lib/rdoc/rouge/formatter.rb', line 10

def accept_verbatim verbatim
  text = verbatim.text.rstrip

  lexer = ::Rouge::Lexer.find_fancy(verbatim.format.to_s, text) || ::Rouge::Lexers::Text

  formatter = ::Rouge::Formatters::HTML.new(
    :css_class => "highlight #{lexer.tag}"
  )

  @res << formatter.format(lexer.lex(text))
end