Class: RedQuilt::Renderer::HTML
- Inherits:
-
Object
- Object
- RedQuilt::Renderer::HTML
- Defined in:
- lib/red_quilt/renderer/html.rb
Instance Method Summary collapse
-
#initialize(document, heading_ids: false, mermaid: false) ⇒ HTML
constructor
A new instance of HTML.
- #render ⇒ Object
-
#render_fragment(nodes) ⇒ Object
Renders the given nodes (an Array of NodeRef) in order and returns the resulting HTML fragment, without affecting the main render output.
Constructor Details
#initialize(document, heading_ids: false, mermaid: false) ⇒ HTML
Returns a new instance of HTML.
6 7 8 9 10 11 12 |
# File 'lib/red_quilt/renderer/html.rb', line 6 def initialize(document, heading_ids: false, mermaid: false) @document = document @arena = document.arena @out = +"" @slugger = Slug::Counter.new if heading_ids @mermaid = mermaid end |
Instance Method Details
#render ⇒ Object
14 15 16 17 |
# File 'lib/red_quilt/renderer/html.rb', line 14 def render render_children(@document.root_id) @out end |
#render_fragment(nodes) ⇒ Object
Renders the given nodes (an Array of NodeRef) in order and returns the resulting HTML fragment, without affecting the main render output.
22 23 24 25 26 27 28 29 |
# File 'lib/red_quilt/renderer/html.rb', line 22 def render_fragment(nodes) saved = @out @out = +"" nodes.each { |node| render_node(node.node_id) } @out ensure @out = saved end |