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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
|
#!/usr/bin/env nix-shell
#!nix-shell -i bash -p poppler-utils imagemagick python3 html-tidy
#
# Rebuild the published page from the PDF and check it, from scratch.
#
# This exists because paper.html is a *committed* artifact produced by a
# pipeline: without this, "the converter still works" is an article of
# faith, and a change that quietly alters the rendering looks exactly like
# a change that does not.
#
# Usage: ./verify
#
# Exits non-zero if the rebuild differs from the committed paper.html, if
# any citation resolves to the wrong entry, or if the HTML is invalid.
set -euo pipefail
cd "$(dirname "$0")"
work="verify-build"
rm -rf "$work"
./extract "$work" >/dev/null 2>&1 || { ./extract "$work"; exit 1; }
echo "== convert" >&2
(cd "$work" && python3 ../convert.py)
# ---------------------------------------------------------------------------
# 1. Does the pipeline still produce exactly what is published?
#
# Byte equality is the strongest available statement and costs nothing to
# check. Note this is not a tautology: the poppler in shell.nix has already
# drifted a minor version from the one that first produced these files, and
# it changed one line of pdftotext output (an ellipsis on page 10, in text
# the HTML takes from the span extraction instead). If a future poppler
# changes something that *does* matter, this is what says so.
# ---------------------------------------------------------------------------
echo "== compare against committed paper.html" >&2
if cmp "$work/paper.html" ../paper.html; then
echo " identical" >&2
else
echo >&2
echo "The rebuild differs from the committed paper.html." >&2
echo "Either the converter changed (then commit the new rendering, and" >&2
echo "re-run ../make-epub), or a tool underneath it did (then read the" >&2
echo "diff before trusting it)." >&2
exit 1
fi
# ---------------------------------------------------------------------------
# 2. Do the citations point where they claim to?
#
# A word-multiset diff cannot see a citation linked to the wrong entry: it
# changes no word in the document. See forge-paper.7 (METHOD).
# ---------------------------------------------------------------------------
echo "== citations" >&2
python3 checkcites.py ../paper.html
# ---------------------------------------------------------------------------
# 3. Is the markup valid, and are the internal links whole?
# ---------------------------------------------------------------------------
echo "== tidy" >&2
tidy -q -e --drop-empty-elements no ../paper.html
echo " no warnings" >&2
echo "== internal links" >&2
python3 - <<'PY'
import re, sys
doc = open("../paper.html", encoding="utf-8").read()
ids = set(re.findall(r'id="([^"]+)"', doc))
dangling = sorted({h for h in re.findall(r'href="#([^"]+)"', doc)
if h not in ids})
if dangling:
print(f" dangling: {dangling}")
sys.exit(1)
print(f" {len(re.findall(r'href=\"#', doc))} internal links, none dangling")
PY
echo >&2
echo "verified: the committed rendering is reproducible from the PDF." >&2
|