diff options
author | Nick Mathewson <nickm@torproject.org> | 2023-11-08 12:00:45 -0500 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2023-11-09 16:42:47 -0500 |
commit | 62e97f924b6073035bb3eb790a85e8292d288d57 (patch) | |
tree | 199a4c14fc63e5f67db7827843de5e932be012ca /bin | |
parent | 243543a3e5f8569f4e8c6a07e0ef83b4bbedd2c6 (diff) | |
download | torspec-62e97f924b6073035bb3eb790a85e8292d288d57.tar.gz torspec-62e97f924b6073035bb3eb790a85e8292d288d57.zip |
Use mermaid-cli to generate SVG for our diagrams.
Diffstat (limited to 'bin')
-rwxr-xr-x | bin/build_html | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/bin/build_html b/bin/build_html index 026c525..43d2f01 100755 --- a/bin/build_html +++ b/bin/build_html @@ -3,6 +3,7 @@ set -e -u -o pipefail -x : ${MDBOOK:=mdbook} +: ${MMDC:=mmdc} TOPLEVEL=$(realpath $(dirname "$0"))/.. cd "${TOPLEVEL}" @@ -10,6 +11,25 @@ cd "${TOPLEVEL}" ./bin/make_redirects +# 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/" +trap 'rm -rf ${TOPLEVEL}/tmp_mermaid' 0 + +# 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 + cd "${TOPLEVEL}/mdbook/spec" $MDBOOK build |