Package Information
- Last Updated
- Authors
- HSGamer
- Categories
- visualization
1. Get the package
Download the package using the TPIX CLI:
tpix get @preview/mmdr:0.2.22. Import in your Typst file
Add this to your .typ file:
#import "@preview/mmdr:0.2.2": *Version History
typst-mmdr
A Typst plugin to render Mermaid
diagrams using
mermaid-rs-renderer.
Limitation
This doesn't guarantee to support all features of
Mermaid JS, as
mermaid-rs-renderer currently
does not support all of the features.
Any problem with the render of the diagram must be reported to
mermaid-rs-renderer instead
of here.
Usage
Import the package and use the mermaid function:
#import "@preview/mmdr:0.2.2": mermaid
#mermaid("graph TD; A-->B;")
More examples can be found
here
Options
You can customize the appearance using base-theme, theme, and layout
parameters.
base-theme: Wraps the base styling. Can be"modern"(default) or
"default".theme: A dictionary of theme overrides. Check
here
for the list of possible options.layout: A dictionary of layout configuration overrides. Check
here
for the list of possible options.
#mermaid(
"graph TD; A-->B;",
base-theme: "default",
theme: (
background: "#f4f4f4",
primary_color: "#ff0000",
),
layout: (
node_spacing: 50,
),
)
Raw SVG
If you need the raw SVG string instead of a Typst image, use mermaid-svg:
#import "@preview/mmdr:0.2.2": mermaid-svg
#let svg-code = mermaid-svg("graph TD; A-->B;")
Build from Source
To build the plugin and prepare it for distribution:
- Install Rust and Cargo.
- Install the
wasm32-unknown-unknowntarget:rustup target add wasm32-unknown-unknown - Run the build script:
just build
The build artifacts will be available in dist/.
License
MIT
The distribution contains the WASM build of
mermaid-rs-renderer, which is
licensed under the
MIT license.