Class: RDoc::Rouge::Formatter

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

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Formatter

Returns a new instance of Formatter.



7
8
9
10
11
12
# File 'lib/rdoc/rouge/formatter.rb', line 7

def initialize(options={})
  opts = ::RDoc::Options.new
  opts.pipe = options.delete(:pipe) || false

  super opts, nil
end

Instance Method Details

#accept_verbatim(verbatim) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
# File 'lib/rdoc/rouge/formatter.rb', line 14

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