Add native Mermaid diagram support #300
All Vouch review confidence checks passed
Residual risk 0.17 = Change Risk (0.42) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.42 · 329 lines diff across 4 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.347
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #300"
general
weight: 0.35
NotAShelf
This adds native support for Mermaid diagrams in
mermaidfenced code blocks.Design
ndg-commonmarkhas a newmermaidoption. When it is set, the processor renders eachmermaidcode block as<pre class="mermaid">with the diagram source as text, and does not highlight it. Other code blocks are highlighted as before.ndg-confighas a new[mermaid]section:scriptdefaults to Mermaid 11 from jsDelivr. A value that starts withhttps://,http://or//is a URL. Any other value is a local path, and validation fails if the file does not exist.assets/mermaid-init.jsto each page, with the library location indata-mermaid-src. The script loads the library only on a page that has a diagram, because the library is large. It initializes Mermaid withstartOnLoad: false,securityLevel: "strict"and the Mermaid theme that agrees withdata-themeon<html>, or with the color scheme of the browser. Onndg:themechange(from the theme toggle), it draws the diagrams again in the new theme. AMutationObserverdraws diagrams that the page adds later.assets/as is, without the JS postprocessing, because the library is already minified. Users can overridemermaid-init.jswith a template directory, as withmain.js.ndg-builderhas amermaidoption. It uses the library frommdbook-mermaid, so that a site (and a ZIM archive) does not need a CDN.Mermaid is off by default, so the output does not change for existing sites.
Alternatives
mermaid-cli). This needs a headless browser at build time, so I did not do this.scriptalso takes a local file.Tests
ndg-commonmark/tests/mermaid.rs: the block conversion, with highlighting on and off.ndg-config: the[mermaid]overrides and the URL or file decision.ndg-html/tests/custom_scripts.rs: the loader tag for a URL and for a local file.ndg/tests/integration.rs: the asset copy, also with JS minification.mermaid-init.test.js: the library loads only with diagrams, loads once, draws diagrams added later, and draws them again when the theme changes.checks.mermaid: anndg-buildersite with a diagram.Assisted-by: Claude:claude-opus-5-5
https://claude.ai/code/session_01RJvbghuj5GtCBiCjmBepNJ