Repository navigation
render-pipeline: verbatim is typewriter, literal, and keeps its indentation - #398
Merged
Merged
Conversation
…tation `\verb`/`\verb*`, the `verbatim`/`verbatim*` environments, `lstlisting` and `\lstinline` were set in the roman body face. The compiler already marked them mono (`Inline::Verbatim`, `Block::Verbatim`), but the pipeline re-derives NFSS by scanning the source and none of the three tables in `style_intervals` listed them -- the same bug class PR #378 fixed for `\url`. Three things were wrong, not one, and the family alone fixes only the first. 1. **Face.** `literal_spans` finds every verbatim construct and `style_intervals` gives it a `Family(Tt)` interval over the whole command, skipping its bytes rather than scanning them. The skip matters on its own: a `%` inside `\verb|100%|` used to start a comment and eat the styles of the rest of the line, and a lone `{` in a listing corrupted the group stack that decides where a declaration ends. 2. **Ligatures and kerns.** Verbatim runs under `\@noligs`, `\texttt` does not, so this cannot ride on the family. `TextStyle::literal` now marks the text; it suppresses the pipeline's source-level `tex_ligatures` pass *and* the font's own program (`tfm::literal_run`, `Shaper::shape_literal`, `ShapeOptions` for the OpenType path). `ectt` does carry the `--` ligature, and `\ttfamily` is right to use it. 3. **Blanks.** A verbatim blank is `\@vobeyspaces`' control space: rigid (the typewriter families set `\fontdimen3`/`\fontdimen4` to zero, so interword glue in that style is already rigid), never breakable, and preceded by `\leavevmode` -- without that empty box the glue opening an indented line is discardable (TeX §879) and every listing lost its indentation. Measured against pdflatex (TeX Live 2025, oracle only), 12pt article, T1, `ectt1200`, every character 6.1735pt: \verb"ftxc --version" 86.4289 pt ours 86.4289 \ttfamily ftxc --version 80.2554 pt ours 80.2554 (ligature kept) \verb|x--y| 24.69397pt = 4 characters \ttfamily x--y 18.52048pt = 3 characters verbatim body "a b-c" 30.86746pt ours 30.8675 A four-line indented `verbatim` block matches the oracle to 0.0044 bp on every word, baselines included. Real-world corpus (22 documents, aligned words within 0.5 bp): dx 84.5% -> 85.0%, dy 65.2% -> 65.7%, both 58.7% -> 59.5%. twelvept-plain dx 78.0 -> 84.2%, dy 68.3 -> 82.4%, both 53.4 -> 73.2%; listings-manual dx 42.7 -> 48.4%. No fixture regressed. The `\verb` limitation is gone and the block one now names what is actually missing (the `listings` keys), instead of claiming there is no monospaced face. Gates: render-pipeline 258 tests / 54 suites green, amsmath 59/59, tabular 106/106, HW1 and HW2 3 pages 0 errors, zero font-FAILURE diagnostics. Implementation-Agent: Claude Opus 5 (lane nixos-verbatim-face, linux-primary) Commit-Executor: Claude Opus 5 (direct git, observed Cursor usage limit) Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Xd5Hmwh5GHNTiAmHUJ1MZu
d-q222
added a commit
that referenced
this pull request
Sep 14, 2026
…s Item::LeaveVmode adapter.rs and incremental.rs conflicts were two additive Item variants (and their hash_items arms) at the same place; kept both. Claude-Session: https://claude.ai/code/session_012c9XLkHjePPGBuarrmE2mz
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.
\verb/\verb*, theverbatim/verbatim*environments,lstlistingand\lstinlinewere set in the roman body face. The compiler already marked themmono (
Inline::Verbatim,Block::Verbatim); the pipeline re-derives NFSS byscanning the source, and none of the three tables in
style_intervalslistedthem — the same bug class PR #378 fixed for
\url.pdflatex (TeX Live 2025) is an oracle only here; nothing in this diff runs TeX
in the product path. Only
crates/render-pipeline/src/*is touched — nocrates/render-pipeline/vendor/*.Two corrections to the brief, both measured
1.
\langle/\ranglewere already fixed before this branch started. Zeromath_limitationdiagnostics at this HEAD;$\langle a,b\rangle$,\Biggl\langleand\left\langleall paint real U+27E8/U+27E9. The evidencethe task quoted contains the deprecated U+2329 (bytes
e2 8c a9), adifferent character that PR #339 replaced. No change was needed and none was
made. The task's expectation that fixing this would help
twelvept-plaincouldnot hold, because there was nothing left to fix.
2.
\urlonly ever got the face half, so there was no literal path to routeinto. The brief said
\url"correctly keepsx--yliteral". It looks literalbut is not: our
\url{...x--y}emitted 20 glyphs for 21 characters (gid 279= en dash).
tex_ligaturesis called unconditionally (adapter.rs:4853). PR#378 built the typewriter face and the literal-byte argument scan, but never
a ligature-suppressing path. So this PR builds that half rather than reusing it.
\urlitself still ligates and is not fixed here: pdflatex gives\url{x--y}= 25.69397 pt (4 characters + url.sty's two 0.5 pt hyphen kerns)against our 3 characters. Out of scope, and compiler-side per #378's own note.
Three things were wrong, not one
The family alone fixes only the first.
Face routing.
literal_spansfinds every verbatim construct andstyle_intervalsgives it aFamily(Tt)interval over the whole command,skipping its bytes rather than scanning them. The skip matters on its
own: a
%inside\verb|100%|used to start a comment and eat the styles ofthe rest of the line, and a lone
{in a listing corrupted the group stackthat decides where a declaration ends.
Ligature and kern suppression. Verbatim runs under
\@noligs;\textttdoes not. So this cannot ride on the family —
ecttdoes carry the--ligature and
\ttfamilyis right to use it.TextStyle::literalnow marksthe text and suppresses both the pipeline's source-level
tex_ligaturespassand the font's own program (
tfm::literal_run,Shaper::shape_literal, andShapeOptions{ligatures,kerning,cmap_ligature_fallback}on the OpenTypepath).
The
\leavevmodebox. A verbatim blank is\@vobeyspaces' controlspace: rigid (the typewriter families set
\fontdimen3/\fontdimen4tozero, so interword glue in that style is already rigid), never breakable, and
preceded by
\leavevmode. Without that empty box the glue opening anindented line is discardable (TeX §879) and every listing loses its
indentation. This was worth 26 bp per indented line on
listings-manual.pdflatex box widths measured against
12 pt
article, T1,ectt1200, every character 6.1735 pt,\fontdimen2/3/4= 6.1735/0/0:\verb"ftxc --version"\ttfamily ftxc --version\ttfamily x--yverbatimbodya b-c\showboxof\verb*"a b-c"gave the structure directly: a leading\hbox(0.0+0.0)x0.0(\leavevmode), a\kern 0.0betweenband-(
\@noligs), and the space as a character. At 11 pt,\verb|a b|shows\penalty 10000+\glue 5.65837— rigid, unbreakable.A four-line indented
verbatimblock now matches the oracle within 0.0044 bpon every word, baselines included.
Per-fixture before → after (all 22)
Aligned words within 0.5 bp,
fixtures/real-worldvs pinned pdflatexreferences, via
tools/visual-oracle/rank.py.The other 20 fixtures are byte-identical to baseline. Nothing regressed. The
baseline reproduced the task's figures exactly (84.5 / 65.2 / 58.7, 20/22), so
the metric matches.
The next lane's starting points
1.
listings-manualdy barely moved (3.9% → 3.8%) becausebasicstyle=\ttfamily\smallis not applied — and behind that,\baselineskipdoes not follow a size declaration anywhere in the pipeline.Indentation errors dropped from −25.97 bp to −3.4 bp, but line spacing is still
wrong: reference 11.956 bp (12 pt, i.e.
\smallat an 11 pt body), ours13.550 bp (13.6 pt, the body's). This is not a listings bug: a plain
{\small\ttfamily ...}paragraph drifts +4.78 bp over two lines againstpdflatex. That general leading bug should be fixed before
\lstsetkey parsing(
basicstyle,frame,numbers,caption) is worth attempting.2.
twelvept-plainstays at 4 pages for a third reason: list verticalspacing, +26.58 bp cumulative across one
itemize→enumeratesequence, ofwhich +16.2 bp lands at the boundary between the two. Pages 1–2 are now
near-exact (median shift ~0; 234/236 words within 0.5 bp on page 2). Page 3 is
exact down to y≈392, then drifts: +3.5 bp at the first
itemize\item,~+0.53 bp per further item, +16.2 bp at the
itemize→enumerateboundary,+4.3 bp closing the list. That pushes the closing paragraph's last two lines
into the footnote, so the page builder moves them to page 4. Our page 3
otherwise ends exactly where the reference's does. Neither verbatim nor math
glyphs are involved, so the task's expectation that this PR would restore 3
pages does not hold.
Diagnostics
The
\verblimitation is deleted (it claimed "the pipeline has no monospacedface", now false). The block limitation now names what is actually missing — the
listingskeys — instead of the same false claim.Gates
cargo test --release --no-fail-fastoncrates/render-pipeline: 258 tests/ 54 suites, 0 failed (4 new tests).
Worth flagging for anyone re-running these: the first suite run showed 25
failures purely because the font env was unset. The
lm_available()guard turnsthat into a loud failure rather than the silent skip the harness used to give.
Every number above is from runs with
FLASHTEX_FONT_DIRS/FLASHTEX_TFM_DIRSset.
🤖 Generated with Claude Code
https://claude.ai/code/session_01Xd5Hmwh5GHNTiAmHUJ1MZu