aboutsummaryrefslogtreecommitdiff
path: root/bin/mermaid_cvt_svg
diff options
context:
space:
mode:
Diffstat (limited to 'bin/mermaid_cvt_svg')
-rwxr-xr-xbin/mermaid_cvt_svg26
1 files changed, 26 insertions, 0 deletions
diff --git a/bin/mermaid_cvt_svg b/bin/mermaid_cvt_svg
new file mode 100755
index 0000000..a48bbee
--- /dev/null
+++ b/bin/mermaid_cvt_svg
@@ -0,0 +1,26 @@
+#!/usr/bin/env bash
+
+set -e -u -o pipefail -x
+
+TOPLEVEL=$(realpath "$(dirname "$0")")/..
+TMPDIR="$1"
+: "${MMDC:=mmdc}"
+
+cd "$TOPLEVEL"
+
+# We make a mirror of the specs, since we will need to make changes to them.
+cp -rl spec proposals mdbook "$TMPDIR"
+
+# We use mermaid-cli to extract the mermaid from any file containing it,
+# and generate a new version that uses svg instead.
+shopt -s globstar nullglob
+for fname in "$TMPDIR"/**/*.md; do
+ if grep '^```mermaid' "$fname"; then
+ ORIG="${fname%.md}.__orig.md"
+ mv "$fname" "$ORIG"
+ $MMDC -i "$ORIG" -o "$fname"
+ fi
+done
+
+
+