A simple Graphviz binding for Typst using the WebAssembly plugin system.
Note
If you want to access the layouts engines without having to use dot language, there is now a new plugin called diagraph-layout. This plugin is more low level and doesn't comes with a renderer.
This plugin is quite simple to use, you just need to import it:
#import "@preview/diagraph:0.3.6": *You can render a Graphviz Dot string to a SVG image using the render function:
#render("digraph { a -> b }")Alternatively, you can use raw-render to pass a raw instead of a string:
#raw-render(
```dot
digraph {
a -> b
}
```
)For more information about the Graphviz Dot language, you can check the official documentation.
Check the manual for more information about the plugin.
This project was built with emscripten 3.1.46. Apart from that, you just need to run make wasm to build the wasm file. All libraries are downloaded and built automatically to get the right version that works.
There are also some other make commands:
make link: Link the project to the typst plugin foldermake clean: Clean the build folder and the linkmake clean-link: Only clean the linkmake compile_database: Generate the compile_commands.json filemake module: It copy the files needed to run the plugin in a folder calledgraphvizin the current directorymake manual: Generate the manual pdfmake wasi-stub: Build the wasi stub executable, it require a rust toolchain properly configured
Somme functions need to be stubbed to work with the webassembly plugin system. The wasi-stub executable is a spetial one fitting the needs of the typst plugin system. You can find the source code here. It is important to use this one as the default subbed functions are not the same and the makefile is suited for this one.
This package also uses a protocol generator to generate the wasm interface. You can find the source code here. It is a required dependency to build this project.
This project is licensed under the MIT License - see the LICENSE file for details
- Fixed #56 caused by uninitialized html struct member of cluster labels
- Fixed #36 caused by an invalid free on error
- Fixed an invalid memory access caused by the math mode detection
- Fixed the margin of subgraphs clusters being set to 0
- Added edges personalization in the
adjacencyfunction - Updated graphviz version to 13.1.0
- Added an
altparameter to therenderandraw-renderfunctions to specify an alternative text for the image - Fixed a bug with landscape mode not being applied correctly
- Fixed a bug with math-mode in xlabel being ignored and set to the label math mode
- Added a global math mode
- Fixed a bug in math detection
- Added a math mode to change the math detection behavior
- Upgraded the typst version to 0.13.0
- Added a stretch mode to change the graph stretching behavior from
stretchtocontain
- Updated graphviz version to 12.2.1
- Fixed a bug with the font being incorrectly set
- Added adjacency lists to the graph rendering possibilities
- Added support for edge labels
- Added a manual generated with Typst
- Updated graphviz version
- Fix an error in math mode detection
- If the shape is point, the label isn't displayed
- Now a minimum size is not enforced if the node label is empty
- Added support for font alternatives
- Added support for xlabels which are now rendered by Typst
- Added support for cluster labels which are now rendered by Typst
- Fix a margin problem with the clusters
- Updated to typst 0.11.0
- Added support for
fontcolor,fontsizeandfontnamenodes attributes - Diagraph now uses a protocol generator to generate the wasm interface
- Fix an alignment issue
- Added a better mathematic formula recognition for node labels
- Added support for relative lenghts in the
widthandheightarguments - Fix various bugs
- Node labels are now handled by Typst
- Graphs are now scaled to make the graph text size match the document text size
- Remove the
raw-render-ruleshow rule because it doesn't allow use of custom font and therender/raw-renderfunctions are more flexible - Add the
backgroundparameter to therenderandraw-rendertypst functions and default it totransparentinstead ofwhite - Add center attribute to draw graph in the center of the svg in the
renderc function
Initial working version
