aboutsummaryrefslogtreecommitdiff
path: root/bin/build_html
blob: 43d2f01100206c349a834d0ce2569e0981a687dc (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
27
28
29
30
31
32
33
34
35
36
37
#!/usr/bin/env bash

set -e -u -o pipefail -x

: ${MDBOOK:=mdbook}
: ${MMDC:=mmdc}

TOPLEVEL=$(realpath $(dirname "$0"))/..
cd "${TOPLEVEL}"
./bin/reindex

./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

cd "${TOPLEVEL}/mdbook/proposals"
$MDBOOK build