Add validate_chapters() function that checks:
- No empty chapter files (whitespace-only counts as empty)
- Every chapter starts with an H1 header (# Chapter N — Title)
- No gaps in chapter numbering (sequential from 1)
- No duplicate chapter numbers
- Header chapter number matches filename number
- Warns on suspiciously short chapters (<50 words)
Validation runs automatically before compilation. If errors are found,
compilation is aborted with clear error messages showing exactly what
to fix.
CLI flags:
python3 compile.py --validate # validate only
python3 compile.py --no-validate # skip validation
python3 compile.py # validate then compile