Class: PseudoHiki::PageComposer::HtmlComposer
- Inherits:
-
BaseComposer
- Object
- BaseComposer
- PseudoHiki::PageComposer::HtmlComposer
- Defined in:
- lib/pseudohiki/converter.rb
Constant Summary collapse
- TABLE =
"table"
Instance Method Summary collapse
- #compose_body(tree) ⇒ Object
- #create_main(toc, body, h1) ⇒ Object
- #create_table_of_contents(tree) ⇒ Object
-
#initialize(options) ⇒ HtmlComposer
constructor
A new instance of HtmlComposer.
Constructor Details
#initialize(options) ⇒ HtmlComposer
Returns a new instance of HtmlComposer.
52 53 54 55 56 |
# File 'lib/pseudohiki/converter.rb', line 52 def initialize() super() @link_manager = setup_link_manager() @relative_link = [:relative_link] end |
Instance Method Details
#compose_body(tree) ⇒ Object
58 59 60 61 62 63 64 65 66 |
# File 'lib/pseudohiki/converter.rb', line 58 def compose_body(tree) super(tree).tap do |html| if @relative_link and @link_manager @link_manager.use_relative_path_for_in_domain_links(html) end assign_table_header_scope(html) if @options[:accessibility] end end |
#create_main(toc, body, h1) ⇒ Object
78 79 80 81 82 83 84 85 86 |
# File 'lib/pseudohiki/converter.rb', line 78 def create_main(toc, body, h1) return nil unless @options[:toc] main = formatter.create_element("section").tap do |element| element["id"] = "main" element.push h1 unless h1.empty? element.push create_toc_container(toc) element.push create_contents_container(body) end end |
#create_table_of_contents(tree) ⇒ Object
68 69 70 71 72 73 74 75 76 |
# File 'lib/pseudohiki/converter.rb', line 68 def create_table_of_contents(tree) @options.formatter.format(create_toc_tree(tree)).tap do |toc| toc.traverse do |element| if element.kind_of? HtmlElement and element.tagname == "a" element["title"] = "toc_item: " + element.children.join.chomp end end end end |