Class: Presently::Renderer

Inherits:
Markly::Renderer::HTML
  • Object
show all
Defined in:
lib/presently/renderer.rb

Overview

Extends the standard Markly HTML renderer to support mermaid diagrams.

Fenced code blocks with the ‘mermaid` language are rendered as `<div class=“mermaid”>` elements instead of `<pre><code>`, allowing the mermaid.js library to pick them up and render diagrams client-side.

Instance Method Summary collapse

Instance Method Details

#code_block(node) ⇒ Object

Render a code block, converting mermaid blocks to diagram containers.



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/presently/renderer.rb', line 18

def code_block(node)
	language, _ = node.fence_info.split(/\s+/, 2)
	
	if language == "mermaid"
		block do
			out(
				"<mermaid-diagram#{source_position(node)}>",
				escape_html(node.string_content),
				"</mermaid-diagram>"
			)
		end
	else
		super
	end
end