mermaid

context(section: SECTION)
fun DslSlide.mermaid(source: String)

Embed a client-side Mermaid diagram inside a DslSlide content{} block. Unlike diagram (which renders through a Kroki server), the diagram is rendered in the browser by the Mermaid runtime bundled with kslides — no network access or external service is required, so decks keep working offline.

Emits a <pre class="mermaid"> element whose text content is the trimIndent-ed source. Presentations containing at least one mermaid block automatically get the bundled Mermaid runtime plus an init snippet that renders each diagram as its slide becomes visible. Mermaid's dark theme is selected automatically when the presentation's reveal.js theme is dark.

Diagram source can also be loaded from a file or URL via include: mermaid(include("path/to/diagram.mmd")).

Parameters

source

Mermaid diagram source, e.g. "graph TD; A-->B". A blank value logs a warning and emits nothing.

The enclosing <section> is supplied via the SECTION context parameter, so calling this outside a DslSlide content{} block is a compile-time error.