Class: Utopia::Project::Renderer
- Inherits:
-
Markly::Renderer::HTML
- Object
- Markly::Renderer::HTML
- Utopia::Project::Renderer
- Defined in:
- lib/utopia/project/renderer.rb
Overview
Renders project Markdown with support for Mermaid code blocks.
Instance Method Summary collapse
-
#code_block(node) ⇒ Object
Render a fenced code block, including Mermaid diagrams.
-
#header(node) ⇒ Object
Render a heading and expose its title to Pagefind for sub-results.
Instance Method Details
#code_block(node) ⇒ Object
Render a fenced code block, including Mermaid diagrams.
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/utopia/project/renderer.rb', line 33 def code_block(node) language, _ = node.fence_info.split(/\s+/, 2) if language == "mermaid" block do out( "<div#{source_position(node)} class=\"mermaid\">", escape_html(node.string_content), "</div>" ) end else super end end |
#header(node) ⇒ Object
Render a heading and expose its title to Pagefind for sub-results.
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/utopia/project/renderer.rb', line 15 def header(node) block do if @headings out("</section>") if @section @section = true out( "<section#{id_for(node)} data-pagefind-title=\"", escape_html(node.to_plaintext.chomp), "\">" ) end out("<h", node.header_level, "#{source_position(node)}>", :children, "</h", node.header_level, ">") end end |