mirror of
https://github.com/harvard-edge/cs249r_book.git
synced 2026-07-16 06:07:17 -05:00
New book/tools/audit/check_purpose_overflow.py: for each teaching chapter, locates in the built PDF the page holding the Purpose hook and the page holding the paragraph's last words; flags any chapter whose Purpose ends on a later page than it starts. Uses plain pdftotext (the -layout mode interleaves margin-stack/running-header labels into the paragraph and breaks matching), normalizes curly quotes/em-dashes, falls back to shorter anchors. Wired into preflight.sh as step 5. Run per volume: python3 book/tools/audit/check_purpose_overflow.py <pdf> --vol vol1
16 lines
1.0 KiB
Bash
Executable File
16 lines
1.0 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Pre-flight: "the PDF looks clean" gate. Run from this worktree root.
|
|
# 1) content gate 2) fresh build 3) nothing-steps-out 4) no-ugly-gaps
|
|
set -uo pipefail
|
|
cd "$(dirname "$0")"
|
|
echo "== 1. CONTENT GATE =="; pre-commit run --all-files
|
|
for V in 1 2; do
|
|
P="book/quarto/_build/pdf-vol$V/Machine-Learning-Systems-Vol$V.pdf"
|
|
echo "== 2. BUILD vol$V =="; ./book/binder build pdf --vol$V --skip-validate -v > /tmp/pf_build_vol$V.log 2>&1
|
|
echo "== 3a. overfull/underfull (must be 0) vol$V =="; grep -c 'Overfull\|Underfull' /tmp/pf_build_vol$V.log
|
|
echo "== 3b. collisions vol$V =="; ./book/binder layout collisions "$P" 2>&1 | grep -E 'collisions:'
|
|
echo "== 3c. margins vol$V =="; ./book/binder layout margins "$P" --include-overlaps 2>&1 | grep -E 'overlaps [0-9]'
|
|
echo "== 4. gaps vol$V =="; ./book/binder layout check "$P" --skip-frontmatter 2>&1 | grep -E 'flagged'
|
|
echo "== 5. purpose-overflow vol$V (must be 0) =="; python3 book/tools/audit/check_purpose_overflow.py "$P" --vol vol$V 2>&1 | grep -E '✗|PASS|FAIL'
|
|
done
|