Commit cda28bd
committed
Add support for Graphviz dot diagrams
While Mermaid diagrams are more and more common on the internet, thanks
to GitHub's support in their GitHub-flavored Markdown codeblocks, it is
often frustratingly difficult to make elegant diagrams with them and to
avoid overlapping or unnecessarily long edges.
Graphviz, in contrast, allows much more control over the layout. The
downside is that Graphviz is a command-line program, not a JavaScript
library, and would require the diagrams to be pre-rendered and committed
into the repository (a recipe for out-of-sync files).
Enter `viz.js` (https://github.com/mdaines/viz-js). Essentially, it is a
WebAssembly build of Graphviz. Therefore, it _does_ run in the browser.
The downside, compared to Mermaid, is the size: While `mermaid.min.js`
weighs around 25 kB, `viz-global.js` weighs around 1.4 MB.
And I did not find any CDN that serves a current version, therefore I
had to download it:
VIZ_VERSION=3.17.0
npm pack @viz-js/viz@$VIZ_VERSION
tar Oxvf viz-js-viz-$VIZ_VERSION.tgz package/dist/viz-global.js \
>static/js/viz-global.js
With this commit, Graphviz dot diagrams can be added like this:
{{< graphviz >}}
digraph {
a -> b -> c
}
{{< /graphviz >}}
While I tried to make it as painless to work on these diagrams locally,
there are more efficient ways than editing the HTML files, running Hugo
and then reloading the page, for example Graphviz Online:
https://dreampuf.github.io/GraphvizOnline/?engine=neato. This page works
entirely in the browser, and uses a slightly outdated version of
`viz.js`.
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>1 parent 802cbb4 commit cda28bd
File tree
4 files changed
+29
-0
lines changed- assets/js
- layouts
- _default
- shortcodes
- static/js
4 files changed
+29
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
782 | 782 | | |
783 | 783 | | |
784 | 784 | | |
| 785 | + | |
| 786 | + | |
| 787 | + | |
| 788 | + | |
| 789 | + | |
| 790 | + | |
| 791 | + | |
| 792 | + | |
| 793 | + | |
| 794 | + | |
| 795 | + | |
| 796 | + | |
785 | 797 | | |
786 | 798 | | |
787 | 799 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
191 | 191 | | |
192 | 192 | | |
193 | 193 | | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
194 | 198 | | |
195 | 199 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
0 commit comments