Open jyasskin opened 1 year ago
Yeah, if there's a Python library for such I'd love to support this, akin to my support for railroad diagrams.
Right now, afaict, that isn't the case - I'd have to link in the mermaid JS lib, and it would result in document shift as the diagrams are rendered.
...well, hm, there is https://mermaid.js.org/config/Tutorials.html#jupyter-integration-with-mermaid-js which shows off using a live-rendering service to generate the images directly. I suppose that works, especially if I do some content-aware caching to avoid pinging it when you've already generated a given image.
I guess it would have to be a bikeshed source
command, tho, which requires you to run things locally. bikeshed spec
can't easily return a bunch of images alongside your spec. Tho I could embed it as base-64 instead, hmmmmmm.
https://mermaid.ink/svg will return SVG that we could embed directly.
Also https://github.com/mermaid-js/mermaid-cli#run-with-npx when Bikeshed notices that npx
is available.
Ooooooh, I didn't see the /svg
option, that's neat.
There is a command line interface to generate SVG files from Mermaid: https://github.com/mermaid-js/mermaid-cli
mmdc -i input.mmd -o output.png -t dark -b transparent
I guess, Bikeshed could save Mermaid code snippets to a separate file and generate SVG files, that can be embedded into the output.
There is also an option to replace Mermaid code block with links to images directly in Markdown files:
mmdc -i readme.template.md -o readme.md
Either Mermaid or PlantUML would work, but Github picked Mermaid, so it probably makes sense to follow them.