rust-lang / mdBook

Create book from markdown files. Like Gitbook but implemented in Rust
https://rust-lang.github.io/mdBook/
Mozilla Public License 2.0
17.23k stars 1.58k forks source link

Graphviz Support #730

Open drusellers opened 5 years ago

drusellers commented 5 years ago

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.

mattico commented 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.

drusellers commented 5 years ago

:+1:

brendanzab commented 5 years ago

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}
mattico commented 5 years ago

Or, perhaps ```dot,graphviz.

gilescope commented 5 years ago

or svgbob support or mermaid. Just want a way to do diagrams out of the box.

dylanowen commented 4 years ago

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
}
```