Mermaid diagrams in Markdown
Example taken from mermaid.js.org ↗.
There are many diagramming languages (see text-to-diagram ↗). Mermaid ↗ seems to be popular, as it is supported by GitHub.
There are two options:
rehype-mermaid
- the original plugin. Battle-tested and well supported.@beoe/rehype-mermaid
↗ - my experiment. It is based onmermaid-isomorphic
(the same one used byrehype-mermaid
). It also adds:- Selector-based dark mode ↗. Used by Starlight and others.
- Cache to prevent the permanent launch of a headless browser.
- Out-of-the-box compatibility with pan and zoom "plugin".
@beoe/rehype-mermaid
Installation
-
Install dependencies
-
Update
package.json
-
Configure Astro. See note about Rehype Plugins for Code.
-
Add line to
.gitignore
: -
Add CSS for dark mode:
-
Optional install dependency for cache
-
Optional configure cache
-
Optional add pan and zoom for diagrams