Svgbob-based preprocessor for mdbook transform your ascii diagrams into a svg.
This renders a code-block marked bob
into neat svg diagrams and inline it into the output.
Firstly add the following to your book's manifest file
(usually book.toml
)
toml
[preprocessor.svgbob] # all fields by default
See config for more information.
Add some ascii graphics:
chapter1.md_
md
```bob
0 3
*-------* +y
1 /| 2 /| ^
*-------* | |
| |4 | |7 | ◄╮
| *-----|-* ⤹ +-----> +x
|/ |/ / ⤴
*-------* v
5 6 +z
```
Build your book and open:
mdbook build
open book/index.html
Default preprocessor config:
```toml [preprocessor.svgbob]
fontsize = 14 fontfamily = "Iosevka Fixed, monospace" fillcolor = "black" background = "transparent" # default overridden, differs from svgbob's default strokecolor = "var(--fg)" # default overridden, differs from svgbob's default strokewidth = 2.0 scale = 8.0 enhancecircuitries = true includebackdrop = true includestyles = true includedefs = true mergelinewithshapes = false
code_block = "bob" # render only code-blocks marked as "bob", e.g.: bob
All properties are optional.
See svgbob's settings doc and default values.
For more information about mdbook see mdbook manual, svgbob spec and editor.
Contributions are appreciated. Don't hesitate to participate to discussions in the issues, propose new features and ask for help.
Useful hint for one-command builds crate + book:
command
to the manifest:```toml
[preprocessor.svgbob] command = "cargo run --manifest-path /path/to/mdbook-svgbob/Cargo.toml --quiet" ```
bash
RUST_LOG=mdbook_svgbob=trace mdbook build