Closed jthacker closed 5 months ago
For the short term I believe mdbook reads your gitignore to decide which files not to watch. I have the line *.generated.svg
in all of my projects.
For a longer term fix the current master branch renders the SVG files via inline html, however this is dependent on the renderer. For example https://github.com/dylanowen/mdbook-confluence still needs to output the generated svg files.
I would like to output the files to the build directory however I'm blocked by this issue: https://github.com/rust-lang/mdBook/issues/1087 tldr: The build directory is cleared after the preprocessors run, deleting the svg files
I think you could inline the SVG into the HTML.
That would mean all IDs need to be unique across multiple dot outputs on the same page, which would mean postprocessing the SVG. Same logic as choosing filenames could be used to prefix them -- or just strip them out. As far as I know graphviz never refers to them. Leaving them in, with predictable prefixed names, would let on-page js play with them, e.g. incremental reveal.
@jthacker @tv42 I have some initial support for this as part of my version https://github.com/dylanowen/mdbook-graphviz/releases/tag/v0.1.0 let me know what you think
I believe the inline SVGs work as expected (having used them) and the initial problem was a git ignore problem, so this issue is stale.
Could you try it again @jthacker
Works great! Thanks for the fixes. I'll close this out now.
I tested the following:
$ mdbook-graphviz --version
mdbook-graphviz 0.1.7
$ cargo install mdbook-graphviz
$ mdbook init
# Update book.toml per README
# Add a basic graph to chapter_1.md
$ mdbook serve --open
# Make a change and observe the rendered book auto reload.
This plugin generates files like *.generated.svg in the src directory. When running mdbook in watch mode, it will detect these new files and trigger a new build which causes a new file to be generated and thus it continues to loop. I'm not sure how you can resolve this, maybe there's a way to flag to mdbook to ignore the generated files. mdbook watch doesn't seem to support filtering files when watching.
Alternatively, why generate them in src and not the build directory?