blob: d31c1da4ba683688f8b194e6ce0537b28f4f0efe (
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 sh
# Compile every .typ the write stage produced, into $OUT/write/pdf/.
#
# typst is the only thing this stage needs, and it is a single binary. A link
# to a label that does not exist is a compile error, so a stage that says
# nothing has also said that every internal link in every document resolves.
set -e
. "$(dirname "$0")/config.sh"
command -v "$TYPST" >/dev/null 2>&1 || {
echo "pdf.sh: no typst on the path; set TYPST=/path/to/typst"; exit 0; }
mkdir -p "$OUT/write/pdf"
n=0; ok=0
for typ in "$OUT"/write/typst/d/*/*.typ; do
[ -f "$typ" ] || continue
dir=$(dirname "$typ"); stem=$(basename "$typ" .typ)
n=$((n+1))
if "$TYPST" compile --root "$dir" "$typ" "$OUT/write/pdf/$stem.pdf" \
> "$OUT/write/pdf/$stem.log" 2>&1 && [ ! -s "$OUT/write/pdf/$stem.log" ]
then ok=$((ok+1))
else echo "TYPST $stem: $(head -3 "$OUT/write/pdf/$stem.log" | tr '\n' ' ' | cut -c1-140)"
fi
done
echo
echo "documents typeset: $n"
echo "typst compiled silently $ok"
echo " (so every internal link resolves)"
|