Class: RDoc::Rouge::Renderer

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Renderer

Returns a new instance of Renderer.



11
12
13
14
15
16
17
# File 'lib/rdoc/rouge.rb', line 11

def initialize(options={})
  @formatter = if options.delete(:toc)
                 Rouge::TOC.new
               else
                 Rouge::Formatter.new(options)
               end
end

Instance Attribute Details

#formatterObject

Returns the value of attribute formatter.



9
10
11
# File 'lib/rdoc/rouge.rb', line 9

def formatter
  @formatter
end

Instance Method Details

#parse(text) ⇒ Object



19
20
21
22
23
24
25
26
# File 'lib/rdoc/rouge.rb', line 19

def parse text
  html = ::RDoc::Markdown.parse(text).accept(@formatter)
  output = if @formatter.is_a? Rouge::TOC
             Rouge::TOC.to_list(html)
           else
             html
           end
end