Skip to content

Commit a175ea2

Browse files
dschojvns
authored andcommitted
Add support for Mermaid diagrams
Mermaid diagrams (https://mermaid.js.org/) have become a common thing ever since GitHub introduced support for them in GitHub-flavored Markdown codeblocks. With this here commit, we can now also use those diagrams on git-scm.com. The idea is to use the new `mermaid` shortcode, like this: {{< mermaid >}} graph LR A --> B {{< /mermaid >}} Signed-off-by: Johannes Schindelin <[email protected]>
1 parent e35fe51 commit a175ea2

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

layouts/_default/baseof.html

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,5 +191,11 @@ <h1 data-pagefind-meta="title">About{{ if (isset .Params "subtitle") }} - {{ .Pa
191191
{{ end }}
192192

193193
</body>
194+
{{- if .Store.Get "hasMermaid" }}
195+
<script type="module">
196+
import mermaid from 'https://cdn.jsdelivr.net/npm/mermaid/dist/mermaid.esm.min.mjs';
197+
mermaid.initialize({ startOnLoad: true });
198+
</script>
199+
{{ end -}}
194200
</html>
195201
{{ end }}

layouts/shortcodes/mermaid.html

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<pre class="mermaid">
2+
{{ .Inner | htmlEscape | safeHTML }}
3+
</pre>
4+
{{ .Page.Store.Set "hasMermaid" true }}

0 commit comments

Comments
 (0)