aboutsummaryrefslogtreecommitdiff
path: root/bin/mermaid_cvt_svg
blob: a48bbee941504f73c517dff6ea361b5176267e69 (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
25
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