Skill Tracer
Skills › Scientific Agent Skills › markdown-mermaid-writing › current-rendering.md

current-rendering.md

149 lines · skills/markdown-mermaid-writing/references/current-rendering.md at 5f2bc03

Open on GitHub
1# Current rendering and validation
2
3Reviewed 2026-10-01 with Mermaid **12.0.0**, Mermaid CLI **12.0.0**, and
4`@mermaid-js/mermaid-zenuml` **1.0.1** in Chromium. Local success is not evidence
5that a hosted Markdown renderer uses these versions.
6

Current rendering and validation

Reviewed 2026-10-01 with Mermaid 12.0.0, Mermaid CLI 12.0.0, and @mermaid-js/mermaid-zenuml 1.0.1 in Chromium. Local success is not evidence that a hosted Markdown renderer uses these versions.

Raw lines 1 to 6
7## Check the destination first
8
9GitHub's [diagram guide](https://docs.github.com/en/get-started/writing-on-github/working-with-advanced-formatting/creating-diagrams)
10documents a fenced `mermaid` block containing `info` to show the installed version.
11Run that probe in the intended preview; do not assume every GitHub surface, editor,
12notebook, or static-site generator has identical support. A Markdown fence labels
13source code; CommonMark itself does not execute Mermaid.
15The bundled guides cover 23 diagram types and one composition pattern collection.
16They are illustrative syntax examples, not current application/provider API contracts.
17The [`-beta` keywords](https://mermaid.js.org/intro/) used here still render in 12.0.0;
18experimental types can change. Prefer a supported simpler diagram or export an SVG/PNG
19with meaningful alt text when a destination cannot render the chosen syntax.

Check the destination first

GitHub's diagram guide documents a fenced mermaid block containing info to show the installed version. Run that probe in the intended preview; do not assume every GitHub surface, editor, notebook, or static-site generator has identical support. A Markdown fence labels source code; CommonMark itself does not execute Mermaid.

The bundled guides cover 23 diagram types and one composition pattern collection. They are illustrative syntax examples, not current application/provider API contracts. The [-beta keywords](https://mermaid.js.org/intro/) used here still render in 12.0.0; experimental types can change. Prefer a supported simpler diagram or export an SVG/PNG with meaningful alt text when a destination cannot render the chosen syntax.

Raw lines 7 to 20
21## Version and configuration changes
23[Mermaid 12 release notes](https://github.com/mermaid-js/mermaid/releases/tag/mermaid%4012.0.0)
24describe an ES2024 build (Node 22.12+; Safari 17.4+), bundled ELK layout, and new
25default appearance for several diagram types. CLI 12 requires **Node 22.13+**.
26Retest layout, wrapping, arrow direction, and contrast when upgrading.
28For a deliberately classic local rendering, save `mermaid-config.json`:
30```json
32 "layout": "dagre",
33 "theme": "default",
34 "look": "classic",
35 "securityLevel": "strict"
37```
39Use top-level `layout`; `flowchart.defaultRenderer`, `class.defaultRenderer`, and
40`state.defaultRenderer` no longer choose an engine. Use top-level `htmlLabels`
41when needed, not the deprecated `flowchart.htmlLabels` field. These options are
42host-controlled in many integrations; a file cannot override every host setting.
44[`%%{init: ...}%%` directives are deprecated](https://mermaid.js.org/config/directives.html)
45since 10.5. Prefer a `config` mapping in Mermaid's diagram frontmatter or the
46host's initialization settings. This is separate from the outer Markdown file's
47frontmatter. Custom `style` and `classDef` rules are valid for types that implement
48them; neither guarantees readable dark-mode colors. Do not disable strict security
49just to make a diagram render.

Version and configuration changes

Mermaid 12 release notes describe an ES2024 build (Node 22.12+; Safari 17.4+), bundled ELK layout, and new default appearance for several diagram types. CLI 12 requires Node 22.13+. Retest layout, wrapping, arrow direction, and contrast when upgrading.

For a deliberately classic local rendering, save mermaid-config.json:

{
  "layout": "dagre",
  "theme": "default",
  "look": "classic",
  "securityLevel": "strict"
}

Use top-level layout; flowchart.defaultRenderer, class.defaultRenderer, and state.defaultRenderer no longer choose an engine. Use top-level htmlLabels when needed, not the deprecated flowchart.htmlLabels field. These options are host-controlled in many integrations; a file cannot override every host setting.

[%%{init: ...}%% directives are deprecated](https://mermaid.js.org/config/directives.html) since 10.5. Prefer a config mapping in Mermaid's diagram frontmatter or the host's initialization settings. This is separate from the outer Markdown file's frontmatter. Custom style and classDef rules are valid for types that implement them; neither guarantees readable dark-mode colors. Do not disable strict security just to make a diagram render.

Raw lines 21 to 50
51## Local CLI export
53The [official CLI](https://github.com/mermaid-js/mermaid-cli) supports SVG, PNG, PDF,
54and Markdown conversion. In a disposable preview directory:
56```bash
57npm install --save-dev --save-exact @mermaid-js/mermaid-cli@12.0.0
58npx mmdc --version
59npx mmdc -i diagram.mmd -o diagram.svg -c mermaid-config.json
60npx mmdc -i diagram.mmd -o diagram-dark.png -t dark -b transparent
61npx mmdc -i report-source.md -o report-rendered.md
62```
64Put the Mermaid body, without Markdown fences, in `diagram.mmd`. Keep
65`report-source.md`: Markdown conversion writes a separate document containing image
66links and adjacent numbered SVGs. Preserve the lockfile for reproducible dependency
67versions. Inspect both the exported file and the final document at its intended size.
69Puppeteer needs a compatible Chrome/Chromium. Installation may download one. To use
70an existing supported browser, set `PUPPETEER_SKIP_DOWNLOAD=true` when installing,
71then supply its executable using `PUPPETEER_EXECUTABLE_PATH` or a Puppeteer JSON file
72via `-p`. Local verification used an installed Chrome rather than downloading another
73browser. Browser availability and fonts remain environment-specific.

Local CLI export

The official CLI supports SVG, PNG, PDF, and Markdown conversion. In a disposable preview directory:

npm install --save-dev --save-exact @mermaid-js/mermaid-cli@12.0.0
npx mmdc --version
npx mmdc -i diagram.mmd -o diagram.svg -c mermaid-config.json
npx mmdc -i diagram.mmd -o diagram-dark.png -t dark -b transparent
npx mmdc -i report-source.md -o report-rendered.md

Put the Mermaid body, without Markdown fences, in diagram.mmd. Keep report-source.md: Markdown conversion writes a separate document containing image links and adjacent numbered SVGs. Preserve the lockfile for reproducible dependency versions. Inspect both the exported file and the final document at its intended size.

Puppeteer needs a compatible Chrome/Chromium. Installation may download one. To use an existing supported browser, set PUPPETEER_SKIP_DOWNLOAD=true when installing, then supply its executable using PUPPETEER_EXECUTABLE_PATH or a Puppeteer JSON file via -p. Local verification used an installed Chrome rather than downloading another browser. Browser availability and fonts remain environment-specific.

Raw lines 51 to 74
75## Browser embedding and parse contract
77[Mermaid's current API](https://mermaid.js.org/config/usage.html) uses promises.
78`parse()` validates syntax; it does not validate scientific meaning or layout.
79A successful parse returns an object containing `diagramType`, not boolean `true`.
80With `{suppressErrors: true}`, invalid input returns `false`; otherwise it throws.
82Example HTML for a page you control (requires CDN access):
84```html
85<!doctype html>
86<html lang="en">
87<body>
88 <pre class="mermaid">
89flowchart LR
90 accTitle: Analysis Workflow
91 accDescr: Input data pass through quality checks before analysis.
92 input["Input data"] --> qc["Quality checks"] --> analysis["Analysis"]
93 </pre>
94 <script type="module">
95 import mermaid from 'https://cdn.jsdelivr.net/npm/mermaid@12.0.0/dist/mermaid.esm.min.mjs';
96 mermaid.initialize({startOnLoad: false, securityLevel: 'strict'});
97 await document.fonts.ready;
98 await mermaid.run({querySelector: '.mermaid'});
99 </script>
100</body>
101</html>
102```
104For programmatic output, `await mermaid.render(uniqueId, source)` returns
105`{svg, bindFunctions}`. Insert the SVG into the intended container, then call
106`bindFunctions?.(container)` if the diagram uses supported interactions. Use a unique
107ID per rendered diagram. `mermaid.init` is deprecated; use `run` for DOM scanning.
108Do not treat arbitrary HTML from another source as trusted output.
110ZenUML requires a separately registered module in a custom browser integration:
111`await mermaid.registerExternalDiagrams([zenuml])` after importing the compatible
112plugin. CLI 12 registers it itself. The two bundled ZenUML examples rendered with
113plugin 1.0.1; this does not establish support in GitHub or every editor.

Browser embedding and parse contract

Mermaid's current API uses promises. parse() validates syntax; it does not validate scientific meaning or layout. A successful parse returns an object containing diagramType, not boolean true. With {suppressErrors: true}, invalid input returns false; otherwise it throws.

Example HTML for a page you control (requires CDN access):

<!doctype html>
<html lang="en">
<body>
  <pre class="mermaid">
flowchart LR
    accTitle: Analysis Workflow
    accDescr: Input data pass through quality checks before analysis.
    input["Input data"] --> qc["Quality checks"] --> analysis["Analysis"]
  </pre>
  <script type="module">
    import mermaid from 'https://cdn.jsdelivr.net/npm/mermaid@12.0.0/dist/mermaid.esm.min.mjs';
    mermaid.initialize({startOnLoad: false, securityLevel: 'strict'});
    await document.fonts.ready;
    await mermaid.run({querySelector: '.mermaid'});
  </script>
</body>
</html>

For programmatic output, await mermaid.render(uniqueId, source) returns {svg, bindFunctions}. Insert the SVG into the intended container, then call bindFunctions?.(container) if the diagram uses supported interactions. Use a unique ID per rendered diagram. mermaid.init is deprecated; use run for DOM scanning. Do not treat arbitrary HTML from another source as trusted output.

ZenUML requires a separately registered module in a custom browser integration: await mermaid.registerExternalDiagrams([zenuml]) after importing the compatible plugin. CLI 12 registers it itself. The two bundled ZenUML examples rendered with plugin 1.0.1; this does not establish support in GitHub or every editor.

Raw lines 75 to 114
115## Accessibility: inspect the output, not only parsing
117Current checks inserted distinct `accTitle` and `accDescr` strings, rendered SVG,
118and inspected its `<title>`/`<desc>`. Results apply to the tested versions:
120| Types | Result / action |
121| --- | --- |
122| Flowchart, sequence, class, state, ER, gantt, pie, git graph, journey, requirement | Both SVG metadata fields emitted |
123| Quadrant, XY, architecture, packet, radar, treemap | Both emitted in 12.0.0; older host versions require checking |
124| Block, kanban, mindmap, Sankey | Do not insert those annotations; use a visible description and export alt text |
125| Timeline | Input accepted, but tested SVG omitted both metadata fields; provide a text alternative |
126| C4 | Tested SVG omitted the accessible title; retain a visible description and inspect export metadata |
127| ZenUML | Plugin-specific; use a visible text alternative and inspect the output |
129See [official accessibility syntax](https://mermaid.js.org/config/accessibility.html).
130`accDescr: ...` is single-line; multiline descriptions use `accDescr { ... }`.
131A valid annotation does not prove screen-reader usability in an embedded host.
132Keep a concise visible explanation and a data table when exact values matter.

Accessibility: inspect the output, not only parsing

Current checks inserted distinct accTitle and accDescr strings, rendered SVG, and inspected its <title>/<desc>. Results apply to the tested versions:

TypesResult / action
Flowchart, sequence, class, state, ER, gantt, pie, git graph, journey, requirementBoth SVG metadata fields emitted
Quadrant, XY, architecture, packet, radar, treemapBoth emitted in 12.0.0; older host versions require checking
Block, kanban, mindmap, SankeyDo not insert those annotations; use a visible description and export alt text
TimelineInput accepted, but tested SVG omitted both metadata fields; provide a text alternative
C4Tested SVG omitted the accessible title; retain a visible description and inspect export metadata
ZenUMLPlugin-specific; use a visible text alternative and inspect the output

See official accessibility syntax. accDescr: ... is single-line; multiline descriptions use accDescr { ... }. A valid annotation does not prove screen-reader usability in an embedded host. Keep a concise visible explanation and a data table when exact values matter.

Raw lines 115 to 133
134## Scientific review before delivery
136- Distinguish workflow order, statistical association, and causation in arrow labels.
137 An inferred or proposed connection must not look like an established result.
138- Preserve units, denominators, uncertainty, and data provenance. Radar `max` controls
139 the axis bound; it does not normalize unlike measures. A shared Y-axis requires
140 commensurate units. Use plotting tools for error bars, scatter data, or exact geometry.
141- Check totals and relationships: Sankey internal flows should balance when the modeled
142 quantity is conserved; pie/treemap values must form meaningful nonnegative parts;
143 ER cardinalities and identifying relationships must match actual constraints.
144- Gantt `crit` is a manual tag, not a computed critical path. Journey diagrams assign
145 one score to each task row, shared by its listed actors. Diagram rendering does not
146 verify a scientific or engineering claim.
147- Label example/synthetic values prominently, and remove placeholders before delivery.
148 A citation must actually support its claim; never cite a paper as evidence for invented
149 measurements or unexecuted software results.

Scientific review before delivery

  • Distinguish workflow order, statistical association, and causation in arrow labels. An inferred or proposed connection must not look like an established result.
  • Preserve units, denominators, uncertainty, and data provenance. Radar max controls the axis bound; it does not normalize unlike measures. A shared Y-axis requires commensurate units. Use plotting tools for error bars, scatter data, or exact geometry.
  • Check totals and relationships: Sankey internal flows should balance when the modeled quantity is conserved; pie/treemap values must form meaningful nonnegative parts; ER cardinalities and identifying relationships must match actual constraints.
  • Gantt crit is a manual tag, not a computed critical path. Journey diagrams assign one score to each task row, shared by its listed actors. Diagram rendering does not verify a scientific or engineering claim.
  • Label example/synthetic values prominently, and remove placeholders before delivery. A citation must actually support its claim; never cite a paper as evidence for invented measurements or unexecuted software results.
Raw lines 134 to 149