aboutsummaryrefslogtreecommitdiff
path: root/bin/mermaid_cvt_svg
blob: 11aa5968f2b411effd71eaaa8880fde300cd6a1d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#!/usr/bin/env bash

set -e -u -o pipefail -x

TOPLEVEL=$(realpath $(dirname "$0"))/..
: ${MMDC:=mmdc}

# We can't use mktemp here, since we need the actual
# path in build.html
TMPDIR="${TOPLEVEL}/tmp_mermaid/"
rm -rf "$TMPDIR"
mkdir -p "${TOPLEVEL}/tmp_mermaid/"

# We make a mirror of the specs, since we will need to make changes to them.
cp -rl spec ./tmp_mermaid/spec
# We use mermaid-cli to extract the mermaid from any file containing it,
# and generate a new version that uses svg instead.
for fname in $(find ./tmp_mermaid -name "*.md") ; do
    if grep '^```mermaid' $fname; then
	ORIG="${fname%.md}.__orig.md"
	mv $fname $ORIG
	$MMDC -i $ORIG -o $fname
    fi
done