#graphviz #mdbook #dot #add #process #file

app mdbook-graphviz

mdbook preprocessor to add graphviz support

10 releases

new 0.1.7 Apr 9, 2024
0.1.6 Feb 10, 2023
0.1.5 Nov 10, 2022
0.1.4 Feb 19, 2022
0.0.1 Nov 1, 2019

#50 in Text processing

Download history 309/week @ 2023-12-22 321/week @ 2023-12-29 341/week @ 2024-01-05 351/week @ 2024-01-12 209/week @ 2024-01-19 371/week @ 2024-01-26 414/week @ 2024-02-02 372/week @ 2024-02-09 354/week @ 2024-02-16 332/week @ 2024-02-23 398/week @ 2024-03-01 440/week @ 2024-03-08 379/week @ 2024-03-15 401/week @ 2024-03-22 399/week @ 2024-03-29 580/week @ 2024-04-05

1,823 downloads per month

MPL-2.0 license

30KB
644 lines

mdBook Graphviz

crates.io LICENSE

Install

cargo install mdbook-graphviz

Install Graphviz

brew install graphviz

book.toml

[preprocessor.graphviz]
command = "mdbook-graphviz"
output-to-file = false # defaults to false, change to true to create SVG files instead of rendering them inline

Usage

Just dot is supported, but any of the other graphviz tools would be easy to add.

Mark A dot Code Block For Processing

Input

```dot process
digraph {
    "processed" -> "graph"
}
```

Output

<div><svg>...</svg></div>


Rendered

dot Code Blocks Without The process Flag Are Ignored

Input

```dot
digraph {
    "processed" -> "graph"
}
```

Output

```dot
digraph {
    "processed" -> "graph"
}
```

Output To File

The default is to embed the SVG as HTML in the Markdown, however if this causes problems or if the actual files are needed you can disable this via the output-to-file flag:

[preprocessor.graphviz]
output-to-file = true

or

MDBOOK_preprocessor__graphviz__output_to_file="true" mdbook build

.gitignore

This .gitignore should cover the generated SVG files.

*.generated.svg

Embedding dot files

Sometimes you don't want to write dot code, but instead include it from a file:

```dot
{{#include path/to/file.dot}}
```

In this case, you might want to modify the order of preprocessors, so the include directives get resolved before it's passed to Graphviz.

In that case, make sure your [preprocessor.graphviz] section in the config orders itself after links:

[preprocessor.graphviz]
after = ["links"]

More information about preprocessors and ordering can be found here.

Dependencies

~15–29MB
~410K SLoC