A preprocessor for mdBook that automatically exports draw.io diagrams to SVG and embeds them in your book.
- Supports
{{#drawio path="..." page=N}}directives in markdown. - Runs the draw.io CLI to export diagrams as SVGs during
mdbook build. - Embeds the resulting SVGs as images in your book.
- Configurable output directory and drawio binary via
book.toml.
nix buildThe resulting binary will be in ./result/bin/mdbook-drawio.
cargo build --releaseThe binary will be in target/release/mdbook-drawio.
Add a preprocessor section to your book.toml:
[preprocessor.drawio]
command = "mdbook-drawio"In your markdown, use:
{{#drawio path="diagrams/hello.drawio" page=0}}See the example/ directory for a working book with diagrams.
preprocessor.drawio.result-dir: Output directory for SVGs (default:mdbook-drawio)preprocessor.drawio.drawio-bin: Path to the drawio CLI (default:drawio)