Class: Facwparser::Element::TocMacro

Inherits:
MacroBase show all
Defined in:
lib/facwparser/element.rb

Instance Attribute Summary collapse

Attributes inherited from ElementBase

#children, #source

Instance Method Summary collapse

Methods inherited from ElementBase

#==, #render_text

Constructor Details

#initialize(source, options = nil) ⇒ TocMacro

Returns a new instance of TocMacro.



183
184
185
186
# File 'lib/facwparser/element.rb', line 183

def initialize(source, options = nil)
  super(source)
  @options = options
end

Instance Attribute Details

#headingsObject

Returns the value of attribute headings.



182
183
184
# File 'lib/facwparser/element.rb', line 182

def headings
  @headings
end

Instance Method Details

#render_html(options) ⇒ Object



187
188
189
190
191
192
# File 'lib/facwparser/element.rb', line 187

def render_html(options)
  "<ul>\n" +
    @headings.map{|h| '<li><a href="#%s">%s</a></li>' %
      [CGI.escapeHTML(h.id), CGI.escapeHTML(h.render_text(options))]}.join("\n") +
        "\n</ul>\n"
end