Repository navigation
tex-expansion: give TAB catcode 10 (fixes root cause of #839 and #836) - #840
Conversation
…ex.ltx do A literal TAB (U+0009) lexed as a printable "other" character (catcode 12) and reached shaping, which has no glyph for it. Both formats set it to 10: plain.tex:18 and latex.ltx:314 carry the identical `\catcode`\^^I=10 % ascii tab is a blank space`, and `\the\catcode`\^^I` prints 10 under pdftex and pdflatex alike -- so the assignment belongs in plain_initial(), not only in latex_initial(). No lexer change was needed: the Space-arm state handling already implements start-of-line skipping and run collapsing once the catcode is right. Measured on a real-user corpus (20 Ross Mathematics Program problem sets, 19 of which use tabs -- 4,755 lines of tab indentation): set1.tex went from 632 diagnostics, 597 of them `no glyph for '\t' (U+0009)`, to 35 with none mentioning U+0009. All 20 files now emit zero tab diagnostics. This also underlies two filed defects: #839 (a tab-only line failed to end a paragraph, so paragraphs merged -- 14/20 corpus documents) and #836 (a tab between \begin{itemize} and the first \item started an empty paragraph, adding one \baselineskip; replacing that whitespace takes set3 from 10 pages to 9, matching pdflatex). NOTE: this does NOT reach users yet. flashtex-render-pipeline builds against the frozen snapshot crates/render-pipeline/vendor/tex-expansion, which still carries the old table; the CLI binary is byte-unchanged by this commit. A vendor re-pin is required and is tracked separately. Implementation-Agent: muse-spark-1.3-contributor Commit-Executor: daniel-parent Co-authored-by: muse-spark-1.3-contributor <[email protected]> Co-authored-by: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_012c9XLkHjePPGBuarrmE2mz
Both points from the independent review of #840. The comment cited TeXbook p. 341 for TAB=10. That page is the INITEX table, where TAB is 12 -- the reviewer verified `pdftex -ini` prints 12 while plain pdftex and pdflatex both print 10. The value comes from the formats (plain.tex:18, latex.ltx:314), not from INITEX. The comment now says so, and notes that this table already models the post-format state: {, $, &, #, ^, _ and ~ are all assigned here and are all 12 in virgin INITEX. The five existing tests only compared tab against space, so a regression that broke paragraph breaking for BOTH would have kept them green -- exactly the gap the reviewer identified. whitespace_only_line_ends_the_paragraph pins the absolute behaviour instead: a tab-only line, a space-only line and an empty line must all produce 2 blocks. Verified authentic by removing the catcode line and watching it fail. Implementation-Agent: daniel-parent Commit-Executor: daniel-parent Co-authored-by: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_012c9XLkHjePPGBuarrmE2mz
|
Independent review: APPROVE. Both of its findings are now fixed in Placement was right, and the objection was wrong twice over. The reviewer ran three engines: No regressions, verified empirically rather than architecturally. Fixed in this follow-up:
Two things for the Commander, not for this PR:
Merging. |
Give TAB catcode 10, as both TeX formats do
Fixes the root cause behind #839 and #836, found by real-user corpus testing after the owner reported "flashtex doesn't render if you use tabs".
The bug
CatCodeTable::plain_initial()assigned\,%and space but never\t, so a literal TAB kept the array fill valueCatCode::Other(12), lexed as a printable character, and reached shaping — which has no glyph for U+0009.Why
plain_initial()and notlatex_initial()An earlier analysis argued TAB is genuinely catcode 12 in plain TeX and the assignment therefore belonged in
latex_initial(). That is wrong, and it is worth recording why. Both formats set it, with the identical comment:plain.tex:18—\catcode^^I=10 % ascii tab is a blank space`latex.ltx:314—\catcode^^I=10 % ascii tab is a blank space`Confirmed empirically rather than by reading:
\the\catcode^^Iprints **10** underpdftex(plain) and **10** underpdflatex`. TeX Live 2026.No lexer change was needed — the Space-arm state handling already implements start-of-line skipping and run collapsing once the catcode is right.
Evidence
Real-user corpus: 20 Ross Mathematics Program problem sets, 19 of which use tabs (4,755 lines of tab indentation, 49 mid-line tabs).
set1.texdiagnosticsno glyph for '\t')The A/B also proves the live crate really loaded: reverting the single line reproduces the flood.
Two filed defects trace to this one table entry:
\begin{itemize}and the first\itemstarted an empty paragraph, costing one\baselineskip(+13.55 bp measured at 11pt). Replacing only that whitespace takesset3from 10 pages to 9, matching both TeX Live 2024 and 2026.Tests
crates/compiler/tests/tab_whitespace.rs, 5 tests: tab ≡ space in text and math mode, start-of-line collapse, run collapse, group edges, tab-only input, trailing tab. Authentic pre-fix failure: all 5 failed before the change with the U+0009 glyph error.crates/compiler: 1,055 passed, 0 failed (86 binaries).crates/tex-expansion: all green.flashtex-render-pipelinebuilds against the frozen snapshotcrates/render-pipeline/vendor/tex-expansion, which still carries the old table. The CLI binary is byte-unchanged by this commit — I rebuilt it and confirmed the repros still fail through the renderer. A vendor re-pin is required and is tracked separately; I'll fold it into the pending consolidated re-pin.Provenance
Implemented by a sandboxed Muse lane (
muse/ross-tab-whitespace). The lane hit an expected sandbox denial — its worktree.gitpointer resolves outside the sandbox root, sogitandmuse.write_filewere unusable — reported it, made no commits, and never touched.gitor renamed anything to work around it, which is the required behaviour. I committed and published on its behalf after verifying the change and re-running the tests.🤖 Generated with Claude Code