Repository navigation
compiler: a verbatim tab is one space, not an 8-column stop - #235
Merged
Merged
Conversation
`verbatim_display` expanded a tab to the next multiple of 8 columns. That encoded a text-editor convention, not pdflatex's behaviour, and PR #188 flagged it as a real mismatch in this crate's own Core-14 layout path. TeX has no tab stops at all. `latex.ltx`'s `\@vobeytabs` makes TAB active and `\let`s it to `\@xobeytab`, which is `\let` to `\@xobeysp` (`= \nobreakspace = \leavevmode\nobreak\ `); `verbatim*` re-points both through `\@setupverbvisibletab`. A tab is therefore exactly whatever one space is, with no dependence on the current column. Measured against pdfTeX 3.141592653-2.6-1.40.27 (TeX Live 2025), oracle only. `\showbox` of `<TAB>one` in `verbatim` yields a single `\glue 5.24995` (cmtt10 `\fontdimen2`, stretch and shrink both 0) — byte-identical to the one-literal-space baseline, not the eight glues the old rule implied. Glyph origins in the generated PDF, as offsets from the left text edge: source line measured one-space rule old 8-column rule <TAB>Q 5.23 bp 5.23 bp (1) 41.84 bp (8) ab<TAB>W 15.69 bp 15.69 bp (3) 41.84 bp (8) abcdefg<TAB>E 41.84 bp 41.84 bp (8) 41.84 bp (8) [agrees] abcdefgh<TAB>R 47.07 bp 47.07 bp (9) 83.99 bp (16) abc<TAB><TAB>T 26.15 bp 26.15 bp (5) 83.99 bp (16) <TAB><TAB><TAB>Y 15.69 bp 15.69 bp (3) 125.99 bp (24) `verbatim*` measures identically. Only the 7-column case agrees with the old rule, which is why it alone could not settle the question. Moved expectations, each justified by a number above: * `verbatim_expands_tabs_to_the_next_stop` asserted `lines[0].text == " ".repeat(8) + "a"` for a single leading tab. pdflatex puts `a` 5.23 bp from the margin, one cmtt10 cell, so the expectation is now `" a"`. Replaced by `verbatim_sets_a_tab_as_a_single_space_not_a_column_stop`, which also covers column 2, column 8 and two consecutive tabs — the cases that actually discriminate between the two rules. * Added `verbatim_star_sets_a_tab_as_a_single_visible_space`; the starred path had no tab coverage at all, and `\@setupverbvisibletab` makes a starred tab one visible space rather than eight. The middle dot for `\verb*`/`verbatim*` is kept, and the doc comment now says why it is legitimate rather than implying it is lossy. On pdfTeX `\verbvisiblespace` is `\asciispace` = `\char32`, and cmtt10 slot 32 is `/visiblespace` (U+2423 OPEN BOX). The Core 14 Courier face this crate lays out on has no U+2423, so a substitute is unavoidable; U+00B7 costs nothing geometrically because Courier's AFM width table is uniform and both `periodcentered` and `space` advance 600/1000 em (6.0 pt at 10 pt body size). `cargo test --release` in crates/compiler: 470 passed / 0 failed / 4 ignored, against 469 / 0 / 4 on a control checkout of the same base. The +1 is the one replaced test becoming two. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Xd5Hmwh5GHNTiAmHUJ1MZu
GoKubar
marked this pull request as ready for review
September 14, 2026 01:35
GoKubar
added a commit
that referenced
this pull request
Sep 14, 2026
…s for them main has moved on since `eea975c3`, and two of its merges matter here: * **#248** committed the 16 listings fixtures (`16`..`31`) with TL2025 references. `every_committed_fixture_is_accounted_for` refuses a fixture that is neither gated nor listed with a reason, so without this the test this branch introduces would fail the moment it reached main. The 15 new ones go into a separate `LISTINGS_NOT_YET`, each naming the piece of listings' geometry it needs -- the `[c]fixed` slack rule, the `\llap` number gutter, `\lst@frameInit`'s rule rectangles, `xleftmargin` expanded in the basicstyle font, real tab stops, `breakindent` -- taken from the measured specification rather than written as placeholders. Two of them record findings worth not losing: fixture 19's reference is byte-identical to 18's, so it does not actually discriminate `fullflexible` from `flexible`; and fixture 25 contains no ligature-forming pair at all, so it cannot have been testing what #145 thought it was. * **#235** made a verbatim tab one space in the compiler, which is the same conclusion this branch's `literal_command_body` reached from the other side. Nothing to reconcile. `28-lstinline`'s fixture and reference were added by both sides. main's reference is kept: it was generated with this host's TeX Live 2025, and the cross-check in this branch's test doc is exactly the evidence that the two distributions agree on this material to 0.001 bp. The one source conflict is `adapter.rs`, where main added `kern_amount_matches` and this branch added `literal_command_end`/ `literal_command_body` at the same place; both are kept. main's version is also the pattern this lane needs later: it gates a `text_kern` signature change behind a `compiler-package-gating` feature so the crate builds against the pinned mirror either way. `LiteralBody::starred`'s doc comment loses the claim that the bundled OpenType Latin Modern has no `visiblespace` glyph. It has one, at U+2423, named `uni2423` in the CFF charset -- which is what the rest of this branch is about -- and the field is no longer dead. `crates/render-pipeline` `cargo test --release --no-fail-fast` with the bundled fonts configured: **217 passed / 0 failed / 1 ignored**, against a `git archive` control of `origin/main` at **213 / 0 / 1**. The +4 are this branch's own tests; no other test changed state. Implementation-Agent: engine-engineer (linux-primary, NixOS PC) Commit-Executor: engine-engineer via git (Cursor usage limit fallback) Co-authored-by: GoKubar <[email protected]> Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Xd5Hmwh5GHNTiAmHUJ1MZu
This was referenced Sep 14, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Settles the
verbatim_displaytab question that PR #188 flagged and deliberately left alone ("a real mismatch in this crate's own Core-14 layout"). Compiler-only;crates/render-pipeline/vendor/untouched.Verdict: the 8-column expansion was wrong, and the middle dot was right.
What pdflatex actually does
latex.ltx's\@vobeytabsmakes TAB active and\lets it to\@xobeytab, which line 9421\lets to\@xobeysp(= \nobreakspace = \leavevmode\nobreak\).verbatim*re-points both through\@setupverbvisibletab. A tab is therefore exactly whatever one space is — TeX has no tab stops, and nothing in the expansion looks at the current column.Measured against pdfTeX 3.141592653-2.6-1.40.27 (TeX Live 2025), oracle only, never in the product path.
\showboxof<TAB>oneinsideverbatimyields a single\glue 5.24995(cmtt10's\fontdimen2; stretch and shrink both0.0pt), byte-identical to the one-literal-space baseline — not the eight glues the old rule implied. The eight-literal-spaces baseline, by contrast, shows eight separate glues.Glyph origins read back out of the generated PDF (
tools/visual-oracle/pdftext.py), as offsets from the left text edge at 72.0 bp:<TAB>Qab<TAB>Wabcdefg<TAB>Eabcdefgh<TAB>Rabc<TAB><TAB>T<TAB><TAB><TAB>Yverbatim*measures identically. Note the 7-column row: it is the one case where the two rules agree, which is why a single-case test could never have caught this — and the old test used exactly that kind of case.Expectations that moved
verbatim_expands_tabs_to_the_next_stop(parser.rs) assertedfor the source
\begin{verbatim}\n\ta\n\end{verbatim}. pdflatex puts thata5.23 bp from the margin — one cmtt10 cell — so the correct expectation is" a". The old value encoded an editor convention rather than pdflatex's behaviour.Replaced by
verbatim_sets_a_tab_as_a_single_space_not_a_column_stop, which asserts[" a", "ab cd", "abcdefgh X", "abc X"]— column 0, column 2, column 8 and two consecutive tabs, i.e. the rows above that actually discriminate between the two rules (the old rule would give 8, 8, 16 and 16 cells).Added
verbatim_star_sets_a_tab_as_a_single_visible_space: the starred path had no tab coverage at all, and\@setupverbvisibletabmakes a starred tab one visible space rather than eight.No other committed expectation moved: no pinned/oracle/tabular-corpus fixture and no integration test contains a tab in a verbatim context, and every other U+00B7 in the repo belongs to math
\cdot.The middle dot is kept, and the doc comment now justifies it
On pdfTeX
\verbvisiblespaceis\asciispace=\char32, andcmtt10.pfb's encoding vector hasdup 32 /visiblespace put— U+2423 OPEN BOX. The Core 14 Courier face this crate lays out on has no U+2423 at all (checked against the generated AFM table backingCore14::Courier), so a substitute is unavoidable.U+00B7 is the honest choice because it is exactly width-neutral: Courier's width table has a single distinct value across all 322 entries, and
periodcentered(U+00B7) andspace(U+0020) both advance 600/1000 em — 6.0 pt at the 10 pt body size. The substitution moves no glyph. The stale doc comment (which implied treating a tab as a space would be "too lossy") is rewritten to record all of the above.KNOWN_UNIMPLEMENTED_COMMANDS— deliberately left alonePR #188's resume notes flagged
verb/lstinlineinvocabulary.rs'sKNOWN_UNIMPLEMENTED_COMMANDSas stale. The label is indeed wrong — both are implemented, in the lexer — but removing them is not harmless, so this PR does not touch them.Neither name is in
parser::BUILT_INS(212 entries; verified), soimplemented_commands()does not contain them and that list is their only route into the vocabulary. Probed directly:Deleting the entries would flip both
is_known_commandresults tofalseand lose all five did-you-mean suggestions. Re-homing them into an implemented list would fix the label but changesuggest_command's iteration order, and with it the tie-breaking for unrelated typos — a diagnostics behaviour change that does not belong in a verbatim-tab PR.Tests
cargo test --releaseincrates/compiler,CARGO_BUILD_JOBS=8, against a control checkout of the same base (git archive origin/mainateea975c3):The single delta is the one replaced test becoming two. No other test changed state.
Note:
cargo fmtis not installed in this environment, so formatting was matched by hand rather than verified by the tool.