AtlatestRepositorysigil-doc
1
#!/usr/bin/env bash2
set -euo pipefail4
repo_dir="$(cd "$(dirname "$0")/.." && pwd)"5
cd "$repo_dir"6
sigil="${SIGIL_D1_COMPILER:-$repo_dir/../task-sigil-language-readers/build/dev/bin/sigil}"7
sigil_sxml_root="${SIGIL_SXML_ROOT:-$repo_dir/../sigil-sxml}"8
typst_bin="${TYPST_BIN:-typst}"9
pdftotext_bin="${PDFTOTEXT_BIN:-pdftotext}"10
mkdir -p build/glossary11
gate_dir="$(mktemp -d "$repo_dir/build/glossary-gate.XXXXXX")"12
export XDG_CACHE_HOME="$gate_dir/cache"13
export SIGIL_REDIRECTS="${SIGIL_D1_REDIRECTS:-$repo_dir/dev-redirects.sgl}"14
export SIGIL_D1_COMPILER="$sigil"16
"$sigil" -L src -L "$sigil_sxml_root/src" test test/test-glossary.sgl --report \17
| tee "$gate_dir/tests.txt"18
rg -q '8 passed' "$gate_dir/tests.txt"19
echo GLOSSARY_GATE_01_MODEL_INDEX_HTML_TYPST_8_821
bash test/gate-semantic-structures.sh | tee "$gate_dir/structures.txt"22
rg -q SEMANTIC_STRUCTURES_GATE_GREEN "$gate_dir/structures.txt"23
echo GLOSSARY_GATE_02_SEMANTIC_STRUCTURES_REGRESSION25
"$sigil" -L src -L "$sigil_sxml_root/src" eval -f test/build-glossary.sgl26
"$typst_bin" compile --root "$repo_dir" --creation-timestamp 0 --pdf-standard a-2b --jobs 1 \27
build/glossary/document.typ "$gate_dir/document.pdf"28
"$pdftotext_bin" -layout "$gate_dir/document.pdf" "$gate_dir/document.txt"29
rg -q '2\.1\. B' "$gate_dir/document.txt"30
rg -q '2\.2\. E' "$gate_dir/document.txt"31
rg -q 'binding \(page 4\)' "$gate_dir/document.txt"32
rg -q 'links a symbol to a location' "$gate_dir/document.txt"33
# `if rg; then fail`, never a bare `! rg` -- bash exempts `!`-inverted34
# commands from `set -e`, so the bare form could never fail (inert 2026-08-24).35
# Subject presence: the positive assertions above prove document.txt exists36
# and carries real glossary content.37
if rg -q '2\.[0-9]+\. A$' "$gate_dir/document.txt"; then38
echo 'GLOSSARY: a bare "A" entry appears in the rendered list (alphabetization/filter regression)' >&239
exit 140
fi41
echo GLOSSARY_GATE_03_REAL_ALPHABETIZED_LINKED_PDF43
echo GLOSSARY_GATE_GREEN