Markdown and GitHub
GitHub, GitLab and most Markdown hosts do not run diagram plugins. yuhwa md renders the diagrams ahead of time and commits plain SVG files next to your Markdown, so they show up everywhere.
Workflow
Write a fenced block:
```yuhwa
a "Client" -> b "Server": HTTPS
``````yu works too.
Run:
npx yuhwa md README.md docs/*.mdpnpm dlx yuhwa md README.md docs/*.mdThe block becomes an HTML comment, which is invisible on GitHub and in most renderers. An image reference follows it:
<!--yuhwa readme-1
a "Client" -> b "Server": HTTPS
-->
To change the diagram, edit the source inside the comment and run yuhwa md again. Only the SVG and the image line change.
Options
| option | effect |
|---|---|
--dark | also writes name.dark.svg and emits a <picture> that follows prefers-color-scheme |
--keep-fences | keeps the fenced block visible and adds the image below it |
--out-dir dir | where the SVGs go, relative to the Markdown file (default diagrams) |
--view | links each image to a pan and zoom viewer of the diagram |
Name a block with <!--yuhwa my-name to get a stable file name. <!--yu my-name works too.
A block can import "./shared.yu". The path is relative to the Markdown file, so several documents can share one set of classes and nodes. See Imports.
Keep it in sync
yuhwa md is idempotent, so it fits a pre-commit hook or a CI step:
npx yuhwa md README.md docs/*.md
git diff --exit-code # fails when someone forgot to re-renderpnpm exec yuhwa md README.md docs/*.md
git diff --exit-code # fails when someone forgot to re-renderEdit visually
yuhwa edit README.md --block 0 opens the first diagram of the file in the editor. Saving writes the source back into the comment.
Sites that run plugins
Static site generators can render fences at build time instead, with no generated files to commit. See Docs sites and frameworks.