Class: Amber::Render::TableOfContents

Inherits:
Object
  • Object
show all
Defined in:
lib/amber/render/table_of_contents.rb

Overview

TABLE OF CONTENTS

Instance Method Summary collapse

Constructor Details

#initialize(html, options = {}) ⇒ TableOfContents

options:

:content_selector (css selector for headings, nokogiri backend only)
:href_base -- use this href for the toc links
:numeric_prefix  -- prefix toc entries and headings with numeric counter (e.g. 1.1.0, 1.2.0, ...)


23
24
25
26
27
28
29
30
31
# File 'lib/amber/render/table_of_contents.rb', line 23

def initialize(html, options = {})
  @html = html
  @toc = TocItem.new
  @levels = {"h1" => 0, "h2" => 0, "h3" => 0, "h4" => 0}
  @heading_anchors = {}
  @options = options
  @options[:tag] ||= 'ol'
  @parsed = nil
end

Instance Method Details

#to_htmlObject



33
34
35
36
# File 'lib/amber/render/table_of_contents.rb', line 33

def to_html
  parse_doc unless @parsed
  # override this!
end

#to_tocObject



38
39
40
41
# File 'lib/amber/render/table_of_contents.rb', line 38

def to_toc
  parse_doc unless @parsed
  # override this!
end