Link audit: fix three plate links from elided ranges

CLAUDE.md requires re-auditing the cross-reference rule after any change
to it, and polish.py changed twice this session. tools/linkaudit.py does
it: three classes checked mechanically, the fourth printed to be read.

  dangling targets                      0
  plate page mismatch (listed vs set)   0   (all 178)
  chapter page mismatch                 0
  `p. N` self-references               25   all read, all sound

The finding: an elided range end is not a plate number of its own.
plate_sub ran re.sub(r"\d+") over the whole range, so "pls. 146-8" linked
its 8 to plate 8 (orig. p.35) and "pls. 142-5" linked its 5 to plate 5
(p.23). Three links, all pointing at the wrong plate — invisible to every
other check, since the targets exist and the text is correct. The end is
now expanded against the leading digits of the number it is elided
against: 146-8 -> plate 148 (p.334), 142-5 -> plate 145 (p.329), both
confirmed against the List of Plates and against where \plateop sets
them.

Worth noting what the audit also confirmed: in two footnotes the rule
discriminates a citation page from a self-reference in the same sentence
— "(London, 1962), p. 43; also see below, p. 63" links only the second.

NOT YET BUILT: the Docker daemon is down, so make verify has not run
against this change. polish.py was run on the host and the audit re-run
against its output, but the PDF does not yet carry the fix.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
bdeshiandClaude Opus 5 committed 2026-09-15 10:00:13 +06:00
1 parent bf7e9f49e7
commit e602e7e631
2 files changed
+104 -2

No files matched your search

+13 -2
View File
@@ -81,9 +81,20 @@ def xrefs(t):
# pl. 57 / pls. 83 and 84 — always this thesis's own plates, always linked
def plate_sub(m):
head, nums = m.group(1), m.group(2)
# An elided range end ("pls. 146-8" for 146-148, "142-5" for 142-145) is
# NOT a plate number of its own. Linking it as one sent "pls. 146-8" to
# plate 8 and "pls. 142-5" to plate 5 — three wrong links, found by the
# link audit 2026-09-15. Expand it from the leading digits of the number
# it is elided against before looking the plate up.
prev = None
def one(mm):
n = int(mm.group(0))
return link(PLATE[n], mm.group(0)) if n in PLATE else mm.group(0)
nonlocal prev
tok = mm.group(0); n = int(tok)
if prev is not None and n < prev:
full = int(str(prev)[:len(str(prev)) - len(tok)] + tok)
return link(PLATE[full], tok) if full in PLATE else tok
prev = n
return link(PLATE[n], tok) if n in PLATE else tok
return head + "~" + re.sub(r"\d+", one, nums)
t = re.sub(r"\b(pls?\.)\s+((?:\d+)(?:\s*(?:,|and|-|--)\s*\d+)*)", plate_sub, t)