Open drusellers opened 5 years ago
This could be implemented using a simple preprocessor. It could look for fenced code blocks like this:
```dot
a -> b
```
extract the source, run it through graphviz, save the resulting image somewhere in the book output, and replace the code block with a link to the image.
:+1:
I would love there to be graphvis support too!
I like the code-fence idea, is has the added benefit of rendering nicely in markdown previews without a preprocessor. Would we be able to have something like:
```dot,preprocess
a -> b
That way the DOT preprocessor wouldn't stomp on DOT code examples too. I could also see this being useful for latex too:
````md
```latex,preprocess
\frac{1}{2}
Or, perhaps ```dot,graphviz
.
or svgbob support or mermaid. Just want a way to do diagrams out of the box.
I created a preprocessor for this:
https://github.com/dylanowen/mdbook-graphviz
https://crates.io/crates/mdbook-graphviz
I just finished the first version so there aren't a ton of features.
I opted for this syntax:
```dot process
digraph {
a -> b
}
```
I'd love to see support for graphviz type diagrams in mdbook, similar to the jekyll based support - https://github.com/kui/jekyll-graphviz
I'm not sure what would be the appropriate "integration" style for mdbook, but would enjoy this capability.