Diagrams

·1 min read

A fence tagged mermaid becomes a diagram:

Markdown

unified pipeline

HTML + KaTeX + highlighting

Mermaid SVG

Prerendered pages

Markdown

unified pipeline

HTML + KaTeX + highlighting

Mermaid SVG

Prerendered pages

Figure 1. What the build does to a post. A diagram is captioned like anything else, by following it with a paragraph that starts with Caption:.

Mermaid is about 3 MB of JavaScript. Rather than send that to readers, the build renders each diagram twice — once against the light palette, once against the dark one — and inlines both as SVG. CSS shows whichever matches the reader's theme, so switching theme swaps the diagram with no request and no flash. During npm run dev the diagrams render in the browser instead, which keeps the edit loop fast.

Other diagram types

Anything Mermaid supports works. A state machine:

date set

build runs

changes needed

Draft

Review

Published

date set

build runs

changes needed

Draft

Review

Published

A sequence:

PagesBuildWorkflowPagesBuildWorkflownpm run buildrender diagramsprerender routesupload artifactdeployment URL
PagesBuildWorkflowPagesBuildWorkflownpm run buildrender diagramsprerender routesupload artifactdeployment URL

When a diagram fails

A diagram Mermaid cannot parse does not break the build. The failure is reported on the console with the post it came from, and the block falls back to rendering in the browser, where the error appears in place with the source underneath it. That way a typo in one diagram costs you one diagram.

Cite this post
BibTeX
@misc{soleimanzadeh2026diagrams,
  author  = {Soleimanzadeh, Kiarash},
  title   = {Diagrams},
  year    = {2026},
  url     = {https://blog.kiarashs.ir/blog/diagrams},
  urldate = {2026-02-02}
}
APA
Soleimanzadeh, K. (2026, February 2). Diagrams. Kiarash Soleimanzadeh. https://blog.kiarashs.ir/blog/diagrams
IEEE
K. Soleimanzadeh, "Diagrams," Kiarash Soleimanzadeh, Feb. 2, 2026. [Online]. Available: https://blog.kiarashs.ir/blog/diagrams
Plain text
Kiarash Soleimanzadeh. “Diagrams.” Kiarash Soleimanzadeh, 2 February 2026. https://blog.kiarashs.ir/blog/diagrams

Kiarash Soleimanzadeh