Model TeX demerit registers and hyphenation exceptions

This commit is contained in:
gloamxun committed 2026-10-23 01:12:52 +08:00
1 parent 3725cca9d7
commit 24a96d1c7c
5 files changed
+153 -34

No files matched your search

+16 -6
View File
@@ -48,13 +48,16 @@ floats (`\floatsep`, `\textfloatsep`, `\intextsep`, `\topfraction`,
`\bottomnumber`, `\totalnumber`), insertion classes (`\skip`, fraction and
absolute limits, splitting), marks, Rust output hook, multi-page PDF, and the
route-D service endpoints (`/api/route-d/preview|pdf|edit`, project preview and
PDF opt-in with `?engine=route-d`). 288 workspace tests are green and no oracle
PDF opt-in with `?engine=route-d`). 289 workspace tests are green and no oracle
fixture is ignored.
Known gaps, in dependency order:
1. paragraph breaking reproduces TeX's passes and demerits, but not yet
`\parshape`, `\looseness`, spacefactor or explicit `\tolerance` overrides;
1. paragraph breaking reproduces TeX's passes and demerits (including
`\adjdemerits`, `\doublehyphendemerits`, `\finalhyphendemerits`,
`\hyphenpenalty`, `\exhyphenpenalty` and `\hyphenation` exceptions), but
not yet `\parshape`, `\looseness`, `\hangindent`, spacefactor or
`\parfillskip`/fil glue orders;
2. the page builder is a scrolling builder with fraction policies, not a TeX
page builder with badness and an interpreted `\output`;
3. `\insert` classes are data structures, not TeX registers and an output
@@ -170,9 +173,16 @@ overfull breaks. Register fixtures pin `\pretolerance=10000` (pass 0 stops
before hyphenation) and `\hyphenpenalty=10000` (hyphenation illegal, first-fit
overfull lines).
Still open: explicit `\tolerance`/`\pretolerance` overrides, flagged
(hyphenated) demerits, `\parfillskip` variants, `\hangindent`/`\parshape`,
spacefactor, and more width fixtures.
Flagged demerits are now modelled too: the DP state records whether a line
ended in a discretionary break, so `\adjdemerits`, `\doublehyphendemerits`
and `\finalhyphendemerits` all affect the chosen solution, and
`\hyphenation` exceptions are inserted into the pattern trie (unit-tested by
counting the discretionary points they add).
Still open: `\parfillskip`/fil glue orders, `\hangindent`/`\parshape`/
`\looseness`, spacefactor/`\sfcode`, vertical-list skips
(`\baselineskip`, `\lineskip`, `\parskip`), double/final hyphen demerit
oracle fixtures, and more width fixtures.
### P2 — Vertical list, page builder, `\output` (L2)