Class: Amber::Render::TableOfContents
- Inherits:
-
Object
- Object
- Amber::Render::TableOfContents
- Defined in:
- lib/amber/render/table_of_contents.rb
Overview
TABLE OF CONTENTS
Direct Known Subclasses
Instance Method Summary collapse
-
#initialize(html, options = {}) ⇒ TableOfContents
constructor
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, …).
- #to_html ⇒ Object
- #to_toc ⇒ Object
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 |
# File 'lib/amber/render/table_of_contents.rb', line 23 def initialize(html, = {}) @html = html @toc = TocItem.new @levels = {"h1" => 0, "h2" => 0, "h3" => 0, "h4" => 0} @heading_anchors = {} @options = @options[:tag] ||= 'ol' end |
Instance Method Details
#to_html ⇒ Object
32 33 34 35 |
# File 'lib/amber/render/table_of_contents.rb', line 32 def to_html parse_doc unless @parsed # override this! end |
#to_toc ⇒ Object
37 38 39 40 |
# File 'lib/amber/render/table_of_contents.rb', line 37 def to_toc parse_doc unless @parsed # override this! end |