Skip to content

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:

md
```yuhwa
a "Client" -> b "Server": HTTPS
```

```yu works too.

Run:

sh
npx yuhwa md README.md docs/*.md
sh
pnpm dlx yuhwa md README.md docs/*.md

The block becomes an HTML comment, which is invisible on GitHub and in most renderers. An image reference follows it:

md
<!--yuhwa readme-1
a "Client" -> b "Server": HTTPS
-->

![readme-1](diagrams/readme-1.svg)

To change the diagram, edit the source inside the comment and run yuhwa md again. Only the SVG and the image line change.

Options ​

optioneffect
--darkalso writes name.dark.svg and emits a <picture> that follows prefers-color-scheme
--keep-fenceskeeps the fenced block visible and adds the image below it
--out-dir dirwhere the SVGs go, relative to the Markdown file (default diagrams)
--viewlinks 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:

sh
npx yuhwa md README.md docs/*.md
git diff --exit-code   # fails when someone forgot to re-render
sh
pnpm exec yuhwa md README.md docs/*.md
git diff --exit-code   # fails when someone forgot to re-render

Edit 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.

Released under the MIT License.