Repository navigation
Description
A read of the hyphenation pass against tex.web §§891-966. Nine divergences, each with its tex.web place and the Go line. Hyphenation decides where lines break, and lines decide pages, so this is on the same channel the corpus deviation is measured through.
⚠ Provenance. This came out of a bibliography pass. I verified (1) myself — hyphenation.go:136-150 starts a word at any charNode with no test of what precedes it. The other eight I am relaying with their citations rather than having re-derived each; treat them as leads with addresses.
⚠ Where the code is. go-typeset/hyphenation is 97 lines and is Liang's algorithm alone. Everything TeX-specific — word gathering, \patterns, \language, the min-lengths — lives in this repository's own hyphenation.go. Eight of the nine below are therefore ours to fix, not upstream's.
(1) The glue precondition — verified
§891 and §894 are explicit: hyphenation is attempted only where cur_p points to a glue node, and §899 lists what may follow a word (glue, penalty, ins, adjust, mark, whatsit, explicit kern). hyphenateList (hyphenation.go:129-191) gathers every maximal run of charNode and hyphenates it, whatever sits on either side.
Two consequences, both of which change line counts:
- TeX never hyphenates a paragraph's first word, because it is preceded by the
\parindentbox and not by glue. We always do. - TeX never hyphenates next to a box, math, or a user discretionary (§891:17476). We do.
(2) \hyphenchar does not exist
§896 is if hyf_char<0 then goto done1 — a font whose \hyphenchar is −1 is not hyphenated at all. There is no such primitive here; only an unused defaulthyphenchar in texparams.go, and the hyphen is hard-coded as pre: "-" (hyphenation.go:185).
plain.tex's \hyphenchar\tentt=-1 is therefore inexpressible, so \texttt and code are hyphenated where TeX refuses. That is visible damage in a corpus full of listings and identifiers.
(3) \lccode does not classify letters
§891:17480-17483 and §897:17601 (if lc_code(c)=0 then goto done3) make \lccode the definition of "letter". The library lowercases with strings.ToLower and the engine treats any charNode as a letter (hyphenation.go:147-150), so punctuation, digits and apostrophes stay inside the word and change the pattern match.
(4) No exception list
§925-§933, consulted before patterns (§923:18147). \hyphenation{...} is stubbed out entirely (amssubstrate.go:505-506: \def\hyphenation#1{}). A document that corrects a word's break points is silently ignored.
(5) \uchyph has no concept
§236 and §896:17585: \uchyph=0 forbids hyphenating a word that begins with a capital. We always hyphenate.
(6) The 63-letter rule is inverted
§897:17602 is if hn=63 then goto done3 — TeX truncates at 63 letters and still hyphenates the first 63. We skip the word entirely (hyphenation.go:174).
⚠ And capacity_test.go:82-85 pins that behaviour citing "tex.web §891". The line it quotes (if l > max_hyphenatable_length) is not in tex.web — it is a LuaTeX/XeTeX spelling. TeX's own limit is §894:17548, if l_hyf+r_hyf>63.
(7) Points mixes byte and rune indices
hyphenation.go:56-66 indexes w[i:j] and val[i+k] by byte while L and the result are by rune (71-77). Any accented letter — every French, German, Czech or Polish word in the bibliography — yields wrong break positions, silently. This one is in the library.
(8) \language mapping
§934:18261-18263 maps \language ≤ 0 or > 255 to 0; we return nil for any non-zero (hyphenation.go:63), so a document setting \language to anything we do not know loses hyphenation rather than falling back to the default.
(9) No reconstitution
§§904-918 rebuild ligatures and kerns around an inserted hyphen, with hyf_bchar, the init_list punctuation context and the exponential-growth guard of §918. We insert a bare discNode between charNodes and keep the pre-hyphen ligatures — §904's "difficult" case, unhandled.
PRESENT, so that this reads as a census and not a complaint
Liang matching with max-wins and odd-means-break (hyphenation.go:52-79 ≡ §919, §923); \lefthyphenmin/\righthyphenmin as the exact l_hyf … hn-r_hyf range (:73 ≡ §902); second-pass-only gating (paragraph.go:201-209 ≡ §891, §894); \patterns (:77-109 ≡ §951); \language selection (:60-73).
⚠ Not claimed
That any of these accounts for a particular part of the corpus deviation. Each has an address; none has a measured cost. (1) is the one I would measure first, because "never hyphenate the first word of a paragraph" is a rule that fires on every paragraph of every document and is cheap to implement.
Possibly related and worth re-measuring now: #381 ("our lines hold 69 characters where the reference holds 66, with the font and the measure controlled"). The font is no longer controlled the way it was — #764 replaced one scaled face with the reference's eight optical sizes — so that count may have moved for a reason unrelated to hyphenation.
Refs #754.
🤖 Generated with Claude Code
Prior art: priorart "hyphenation glue precondition hyphenchar lccode uchyph exception list" at 2026-11-12 20:51 CET reported prior art; checked: 460 entries. #754 (open) is my earlier audit of the delegated layers and names no hyphenation rule. #381 (open, lines hold 69 chars vs 66) is adjacent and flagged in the body as worth re-measuring after #764. #583/#441 are line-breaker and interline-glue issues, not the hyphenation pass. None states any of the nine.
Activity
a word is hyphenated only after a glue, as tex.web §894 says (#766)
\texttt is not hyphenated, because \hyphenchar now exists (#767)
\hyphenation{…} was a stub that threw the document's words away (#775)
tannevaled commentedon Nov 15, 2026
Item (3) has a witness now, with the reference controlled: a trailing period creates an extra hyphenation point that
\righthyphenminwould forbid, and we take it where the reference declines.I arrived at this from the other end — looking for a
\sloppywitness for #768 whose badness is not saturated — andpriorartlanded me here, so this is a measurement for an item already filed rather than a new finding.The extra point
Asked of the hyphenator this engine actually uses, with
\lefthyphenmin=2and\righthyphenmin=3:⛔
complete-lyis not a legal break and the hyphenator knows it — without the period it offers onlycom-pletely, because two letters after the hyphen is under\righthyphenmin. With the period the fragment counts three characters, the limit is satisfied arithmetically, and the break appears.paragraph.is the control: a word whose points do not sit near the end is unaffected, so this is the min-affix arithmetic and not the pattern match.And the period really is inside the word the engine passes. Read off the node list for
\hbox{ completely. }:one run of
charNodes, period included — which ishyphenation.go:147-150treating anycharNodeas a letter, exactly as this issue's item (3) says. §891:17480-17483 is the rule it departs from: "Each charactercis now classified as either a nonletter (iflc_code(c)=0)… TeX looks ahead for as many consecutive letters as possible", with §897:17601'sif lc_code(c)=0 then goto done3ending the word at the period.What it costs, against tectonic 0.17.0
Typographical incomprehensibilities overwhelm every paragraph completely.at\hsize=100pt,\parindent=0pt:incompre-incompre-,complete-lySo the illegal break is not cosmetic: the reference accepts a 20.93pt overfull line rather than take it, and we take it and come out with a third bad box. ⚠ Note the direction — our worst overflow is smaller. A metric that rewards narrower overflow would score this engine better for making a break TeX forbids.
⭐ And the control, which is the half worth having
The same paragraph at
\hsize=120pt, where no illegal point arises:Three lines, the same two hyphens, and both engines report the same two overfull boxes with the same worst overflow, 14.63pt — to the hundredth of a point. I nearly published that agreement as a divergence, having read our
overfull=2without first reading the reference's log.So in this regime the two agree exactly, and the defect shows only where a word with punctuation sits near a break. That is a far smaller population than "every hyphenated word", which is worth knowing before anyone prices item (3).
⚠ Not claimed: that this is the whole of item (3). Digits and apostrophes are in its text too and I measured neither; and the pattern-match half — a period changing which patterns apply — is not exercised by this witness, where the arithmetic alone explains the extra point.
🤖 Generated with Claude Code
tannevaled commentedon Nov 15, 2026
Item (7) is already fixed in the version this engine requires. Measured, not read off a comment.
The item says
Pointsmixes byte and rune indices, that any accented letter yields wrong break positions silently, and that it is in the library.go-typeset/hyphenationv1.0.1 — whichgo.modrequires today — works in runes throughout (w := []rune("." + strings.ToLower(word) + ".")), and its own comment cites the old symptom:Points("éaby")returning [3] where"xaby"returned [2].A measurement printed in a comment is not a check, so I re-ran that witness against v1.0.1:
Identical, as they must be — a break position is a count of LETTERS — despite four bytes against five. The defect is gone.
⚠ And my first attempt measured the wrong thing, which is worth a line because it would mislead anyone repeating this: with the default mins (left 2, right 3) a four-letter word cannot break at all, 2+3 being more than 4, so both words answered
[]and the indexing was invisible. The probe needsSetMins(1, 1)before it measures anything.So (7) can be struck from the nine. Nothing else in the census is touched by this — I measured item (3) separately (the comment above) and none of the other seven.
🤖 Generated with Claude Code
tannevaled commentedon Nov 15, 2026
Three more of the nine, read against
mainat b20d14a: (4) is fixed, (5) stands, and (6) stands with a test pinning it — citing the reference for the behaviour the reference does not have.(4) No exception list — fixed, strike it
The item says
\hyphenation{…}is\def\hyphenation#1{}inamssubstrate.go. Onmainit is a real primitive:with
hyphexception_test.gobeside it, whose own comment refers back to the old stub. #775 did it. The only remaining mentions of the stub are in that test's prose.(5)
\uchyphhas no concept — standsOne occurrence in the whole tree:
Accepted as a named count with TeX's default, and read by nothing. So
\uchyph=0is silently ignored, as the item says. (For scale:\uchyphappeared in 9 of 2935 corpus papers, 0.3%, in the census on #769 — the smallest population of the five commands measured there.)(6) The 63-letter rule — stands, and a test pins it
Confirmed against the source, and the item's reading is right:
done3is the EXIT of the letter-collecting loop, not an abandonment of the word: thehnletters already collected are what gets hyphenated. §891:17491-17492 says it in prose — "however,nmust be less than 64, so a character that would otherwise bec_64is effectively not a letter" — a nonletter ends the word, and the first 63 letters are hyphenated.⛔ And the new part: a test asserts our behaviour and cites the reference for it.
capacity_test.go:91-94:want 0 (tex.web §891)— and §891 says the opposite. The citation makes the divergence look verified, which is worse than an uncited assertion: the next reader has no reason to check it. It is the shape ofa-test-that-pinned-our-own-divergence, with a reference attached.⚠ Said fairly, because that test has a real job: it lives in
capacity_test.goamong the expansion-bomb guards, and bounding the work a pathological word can cause is correct. The point is that TeX's own behaviour is equally bounded — 63 letters, then stop collecting — so the ceiling can be kept exactly as it is while matching the reference. What has to change is the branch at the ceiling and that test's expectation, not the ceiling.Where that leaves the nine
\hyphenchar\lccodecompletely.→ an extra illegal point)\uchyph\language⚠ Not claimed: anything about (2), (8) or (9). I read the source for the four I report and ran the two that have witnesses; the rest are the issue's own text, unverified by me.
🤖 Generated with Claude Code
tannevaled commentedon Nov 15, 2026
(2) is fixed as well, and (8) is narrower than filed — the divergence is the OUT-OF-RANGE mapping, not
\languagein general. That leaves (9) as the only one of the nine I have not measured.(2)
\hyphenchardoes not exist — fixed, strike itIt does.
\hyphenchar\fontis assignable since #767 and readable now (fontquery_test.go:117-127reads\the\hyphenchar\fontas 45 and as −1 after assignment),e.hyphenCharOfexists, andhyphenchar_test.gopins the rule the item cites — a font whose\hyphencharis negative is never hyphenated, §896 — withtulmtt.fd:51's\hyphenchar\font\m@nefor the typewriter family as its witness.(8)
\languagemapping — stands, but say which halfMeasured, four values, one engine each:
against tex.web:18261-18263:
⭐ So the defect is the out-of-range cases, and only those.
\language=-1and\language=300are mapped by TeX to 0 — English — and we hyphenate them not at all. That is a two-line fix athyphenation.go:98: clamp before comparing.⚠ And
\language=5is NOT the same thing, which the item's wording runs together. There TeX would use language 5's patterns, which this engine does not embed; returning nil is then a deliberate choice and arguably the right one, since hyphenating French with English patterns breaks words in places no reader would accept. Worth keeping as a documented choice rather than fixing into a wrong answer — which is why I am reporting (8) as half a defect rather than one.Where the nine stand now
\hyphenchar\lccodecompletely.gains a point\righthyphenminforbids\uchyphcapacity_test.go:91-94pins it citing §891 for the opposite\languageFour of the nine were already closed by work that landed after the census (#766, #767, #775, and hyphenation v1.0.1), which is the main thing this adds: the issue reads as nine open divergences and four of them are done.
⚠ Not claimed: anything about (9). §§904-918's ligature reconstitution is the largest of the nine and I did not look at it.
🤖 Generated with Claude Code
tannevaled commentedon Nov 15, 2026
Item (9)'s root cause sits one step UPSTREAM of reconstitution, and it is much larger than "§904's difficult case is unhandled": a ligature is formed before the paragraph is broken, so the word this engine hyphenates is not the word the author wrote. Nineteen of twenty ordinary technical words are hyphenated wrongly or not at all.
Found doing the bibliography the issue asks for, reading §§904-918 as filed.
What the reference does
tex.web:17478-17479, describing what the hyphenation pass is handed:
So TeX hyphenates letters, having undone the ligatures, and only then does$x_{k+1}$ had been
reconstitute(:17747-17758) rebuild them around the break it chose — settinghyphen_passedfor exactly the break whose translation "would have been different ifhchar" (:17769-17772).What this engine does
The ligature is already one
charNodewhen the paragraph pass runs:and the hyphenator is then asked about that. Twenty words an arXiv paper cannot avoid, each carrying
fi,fl,ff,ffiorffl, comparing the points for the word as written against the word as held:The one "unaffected" is
affine, which has no points either way — so it is untestable rather than correct.⭐ The control, because the table above is a proxy
Those rows compare
Points(collapsed)withPoints(written). Asking the engine itself, throughhyphenateList, gives the same answer:So
clas-sifi-ca-tionis what this engine sets, anddif-fer-entis setdiffer-ent— one break instead of two, in a place the patterns do not name.⚠ And my own instrument had the same class of bug
The first run of that table reported "6 lost, 9 moved, 5 unaffected". Its classifier compared
len(asSet) != len(w)in bytes, and"efficient"(9 bytes) against"efficient"(7 runes, 9 bytes) compares equal — so four words that had lost a break point were counted as unaffected. Corrected to compare the point lists directly, it is 6 and 13 and 1. The same byte/rune confusion as item (7), in the measuring tool this time, an hour after I measured that one fixed.Why this is worth more than its place in the list
These are not edge-case words:
definition,different,classification,coefficient,final,difficultare the vocabulary of the corpus. A systematically wrong hyphenation changes how much text a line holds, which is the channel #381 reads (our lines holding 69 characters where the reference holds 66) and the kind of defect #716 showed the fidelity metric is blind to.⚠ Not claimed: a corpus figure. The population over the 2935 papers needs a run, and the host's 1-minute load average has been 8.9 to 133 all day, never under the ~8 threshold this repository measures under. Twenty hand-picked words are a demonstration, not a measurement of the corpus.
⚠ Also not claimed: that fixing it is only "expand before hyphenating". That half is small; the other half is §§904-918 — rebuilding the three lists around the chosen break — which is item (9) as filed and is not small.
🤖 Generated with Claude Code
a \hyphenation entry does not escape \lefthyphenmin and \righthyphenm…
a word ends where \lccode says it does, not at the next non-character (…
tannevaled commentedon Nov 17, 2026
Where the nine stand, 2026-11-17
Eight are closed. This census has been read as an open list of nine since it was
filed, and tonight that nearly cost a rebuild: I opened it to pick the next item,
took (1) — the one the body itself names as "the one I would measure first" —
and only
priorartstopped me, by printing #766 merged. The body is the thinga reader believes, so it is the thing that has to carry the state.
\hyphenchardoes not exist\lccodedoes not classify letters\uchyphhas no concepthyphenation.go:404truncates, and the citation that was not in tex.web is gonePointsmixes byte and rune indices\languagemappinghyphenation.go:91-110What remains
(9) alone. It is also the largest by a long way:
reconstitute(§§904-918)rebuilds ligatures and kerns around each inserted hyphen, with
hyf_bchar, theinit_listpunctuation context, and §918's guard against exponential growth. Weinsert a bare
discNodebetweencharNodes and keep the pre-hyphen ligatures —§904's "difficult" case, unhandled.
⚠ Its cost is unmeasured, and I am not asserting it is small. It fires only
where a hyphen lands inside a ligature or a kern pair, which in English is rarer
than the other eight but not negligible (
off-ice,shelf-ful). The witness itwants is a word list crossed with break positions, not a page.
⚠ What this comment is not
It is not a claim that the hyphenation pass now matches tex.web. Eight items
from one read of §§891-966 are closed; a second read would find more, and two
things this very body already flags are still open and unquantified: #381 (69
characters to the reference's 66) and the
\lccode-lowered letters thatlcCodeOf's own header says are not fed to the hyphenator — the library stilllowercases with
strings.ToLower, so a document that remaps\lccodeto makeone character hyphenate as another is still unobeyed.
Refs #828, Refs #381, Refs #766, Refs #767, Refs #770, Refs #809, Refs #824.
Refs go-typeset/hyphenation#8.
🤖 Generated with Claude Code
\uchyph decides whether a capitalised word is hyphenated (tex.web:175…