#!/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)"