m

mmdr

@preview

A Typst plugin to render Mermaid diagrams

v0.2.2
MIT
1 downloads

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

2. Import in your Typst file

Add this to your .typ file:

#import "@preview/mmdr:0.2.2": *

Version History

0.2.2
e87b54e8a8b2...
0.2.1
f1c20efbd946...
0.2.0
75a2eff3a0d4...
0.1.0
066eb2a14d38...

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:

  1. Install Rust and Cargo.
  2. Install the wasm32-unknown-unknown target:
    rustup target add wasm32-unknown-unknown
    
  3. 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.