mirror of
https://github.com/harvard-edge/cs249r_book.git
synced 2026-07-16 14:42:29 -05:00
The legacy `book/tools/scripts/utilities/validate_epub.py` duplicated
most of what epubcheck covers (mimetype, container.xml, OPF structure,
XHTML well-formedness, unclosed tags, unescaped ampersands) and had a
pre-existing broken exit code that made it unusable in the default
`./binder check epub` run.
Two of its checks were genuinely unique — CSS custom properties and
external resource references. Those patterns produce real user-
reported breakage on older readers (ClearView / Tolino firmware pre-
2023) that epubcheck does not flag because they are valid EPUB 3
spec. Those unique checks now live in _epub_checks.py as
`run_smoke_checks_on()`, exposed via the new scope:
./binder check epub --scope smoke
Smoke runs in <1s, does not require Java, and fails on detection
(error severity) because the patterns caused real load failures.
Default `./binder check epub` now runs three scopes in order:
hygiene (source, pre-build)
smoke (built EPUB, reader compat, no Java)
epubcheck (built EPUB, W3C validation, needs Java)
Together they form a three-layer defense: source, built-EPUB without
Java, built-EPUB with Java. A regression has to escape all three to
reach a reader.
Removed
-------
book/tools/scripts/utilities/validate_epub.py — duplicate of epubcheck
plus two unique checks now owned by _epub_checks.py.
Validation
----------
./binder check epub → 0 issues, 3 scopes run, ~7s
./binder check epub --scope smoke → 0 issues, ~200ms
Utility Scripts
General-purpose utility scripts for validation and checking.
Scripts
check_sources.py- Comprehensive source file validationcheck_ascii.py- Check for non-ASCII characterscheck_images.py- Validate image files and referencesfix_titles.py- Fix title formattinganalyze_footnotes.sh- Analyze footnotescount_footnotes.sh- Count footnotes
Quick Usage
# Validate source files
python check_sources.py
# Check for encoding issues
python check_ascii.py
# Validate images
python check_images.py