aboutsummaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2023-11-09 14:41:55 -0500
committerNick Mathewson <nickm@torproject.org>2023-11-09 16:42:47 -0500
commitb9ba76e22180aaf1a3c848c74e4019727f7375ec (patch)
tree8df82574c2fb23e8b8794541004655b2e305a017 /bin
parent80d9a790797a423260e666bcfefe470c98f158c1 (diff)
downloadtorspec-b9ba76e22180aaf1a3c848c74e4019727f7375ec.tar.gz
torspec-b9ba76e22180aaf1a3c848c74e4019727f7375ec.zip
Move mermaid server-side copying into its own script.
Diffstat (limited to 'bin')
-rwxr-xr-xbin/build_html20
-rwxr-xr-xbin/mermaid_cvt_svg24
2 files changed, 26 insertions, 18 deletions
diff --git a/bin/build_html b/bin/build_html
index 43d2f01..533e17c 100755
--- a/bin/build_html
+++ b/bin/build_html
@@ -3,7 +3,6 @@
set -e -u -o pipefail -x
: ${MDBOOK:=mdbook}
-: ${MMDC:=mmdc}
TOPLEVEL=$(realpath $(dirname "$0"))/..
cd "${TOPLEVEL}"
@@ -11,24 +10,9 @@ 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
+./bin/mermaid_cvt_svg
-# 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
+trap 'rm -rf ${TOPLEVEL}/tmp_mermaid' 0
cd "${TOPLEVEL}/mdbook/spec"
$MDBOOK build
diff --git a/bin/mermaid_cvt_svg b/bin/mermaid_cvt_svg
new file mode 100755
index 0000000..11aa596
--- /dev/null
+++ b/bin/mermaid_cvt_svg
@@ -0,0 +1,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