diagraph Typst Plugin

repository·main·Indexed 41 days ago

https://github.com/robotechnic/diagraph

A Typst plugin that provides Graphviz capabilities via WebAssembly, allowing users to render Graphviz Dot language strings and code blocks directly into SVG images within Typst documents using functions like render() and raw-render().

Tokens
440
Snippets
4
Records
5
Agent score
50%

What's inside diagraph

  1. Build the diagraph WASM plugin

    main
    The project uses Emscripten 3.1.46 to build the WebAssembly component. To build the WASM file, run make wasm. The build process automatically handles downloading and building the necessary libraries to ensure version compatibility.
    make wasm
  2. Install and use diagraph in Typst

    main

    To use diagraph in your Typst project, import the package using the @preview namespace. This plugin allows you to render Graphviz Dot strings into SVG images directly within your Typst document using the WebAssembly plugin system.

    #import "@preview/diagraph:0.3.7": *
  3. Render Graphviz code blocks with `raw-render()`

    main

    If your Dot code is already inside a Typst code block (e.g., a raw element), use raw-render to process it. This is useful for maintaining syntax highlighting or structured code within your source file.

    #raw-render(
      ```dot
      digraph {
        a -> b
      }

    )

  4. Reference: Build commands for diagraph

    main

    The following make commands are available for managing the build and deployment of the plugin:

    • make wasm: Build the WASM file.
    • make link: Link the project to the Typst plugin folder.
    • make clean: Clean the build folder and the link.
    • make clean-link: Only clean the link.
    • make compile_database: Generate the compile_commands.json file.
    • make module: Copy files needed to run the plugin into a graphviz folder in the current directory.
    • make manual: Generate the manual PDF.
    • make wasi-stub: Build the WASI stub executable (requires a configured Rust toolchain).