Skip to content

render-pipeline: verbatim, verb and listings as LaTeX sets them - #145

Closed
GoKubar wants to merge 2 commits into
mainfrom
agent/kabir-claude/verbatim-fidelity
Closed

GoKubar wants to merge 2 commits into
mainfrom
agent/kabir-claude/verbatim-fidelity

Conversation

@GoKubar

@GoKubar GoKubar commented Sep 13, 2026

Copy link
Copy Markdown
Contributor

Render-pipeline half of verbatim/listings fidelity. Based on main 85ec30c, not stacked. Render-pipeline only; no vendor edits.

It depends on the compiler PR (agent/kabir-claude/verbatim-fidelity-compiler) only for \lstinline lexing and for \lstset setting no text. The oracle test detects whether vendor/compiler lexes \lstinline and gates 28-lstinline and 30-lst-lstset-margin only after the re-pin. Everything else works on the current pin.

Features

  • Typewriter face: Role::Mono uses the metrics \ttdefault selects (MonoMetrics):
    • OT1 cmtt8/9/10/12 (ot1cmtt.fd)
    • T1 ectt/ecit (t1cmtt.fd)
    • lmodern: ec-lmtt*, ec-lmtti10, ec-lmtk10, ec-lmtko10 (t1lmtt.fd)
    • Latin Modern Mono outlines; Courier under times.
  • Literal text: shaped one character at a time (latex.ltx \@noligs), never hyphenated, and never protruded or expanded. microtype's default sets are rm*/sf*; fixture 32 checks this against pdfTeX.
  • verbatim/verbatim*: \@verbatim line by line.
    • Natural typewriter advances; a space or tab is one \nobreakspace, or the visible space under the star form.
    • An empty line is the \null box; inside lists, \leftskip\@totalleftmargin.
    • The size in force, and \trivlist glue: \topsep, plus \partopsep from vertical mode, \vskip\parskip, \@beginparpenalty/\@endparpenalty.
    • \@endpe after \end{verbatim}.
  • \verb/\verb*: typewriter text with no-break spaces, re-read from the source.
  • listings (src/listings.rs, following listings.sty/lstmisc.sty/lstlang1.sty):
    • Keys come from \lstset/\lstdefinestyle/style=, scanned once per document.
    • Languages: [ANSI]C, [ISO]C++, Java, Python (dialect 2, the listings.cfg default, and 3).
    • Token algorithm: identifier/other tokens, \lst@nolig elements for ` < > , ' -, and \lst@FillFixed boxes for columns=[l|c|r]fixed.
    • flexible/fullflexible/spaceflexible lost-space kerns; spaces and tabs (tabsize); gobble; firstline/lastline.
    • Comments, strings and directives with their styles (commentstyle defaults to \itshape), keyword classes, showspaces/showstringspaces.
    • numbers=left/right with numberstyle/numbersep/stepnumber/firstnumber.
    • frame=single/lines/topline/bottomline/leftline/trbl, with framesep/framerule rules and skips following \lst@frameInit/\lst@frameExit.
    • xleftmargin/xrightmargin, aboveskip/belowskip, and breaklines (breakindent/breakautoindent/breakatwhitespace).
    • \lstinline (flexiblecolumns) and \lstinputlisting.

Oracle

fixtures/verbatim holds 32 fixtures with pdfLaTeX (MacTeX 2026) references. oracle.py and make_fixtures.py are oracle-only; cargo never runs TeX. tests/verbatim_oracle.rs checks glyph origins and rules within 0.1 bp, with equal glyph and rule counts.

  • 31/32 match, with a worst matched delta of 0.073 bp. That includes 28 and 30 with the compiler change in a scratch vendor copy; on the current pin, 29 match and those two are skipped.
  • Coverage: special characters, ligature cases, tabs, blank lines, verbatim*, \verb delimiters, OT1/T1/lmodern, 10/11/12pt, in lists, long lines, a page break, \small, fixed/flexible/fullflexible columns, numbers, frames, C/Python/Java keywords, breaklines, showstringspaces, \lstinline, tabs/gobble, \lstset margins, lmodern bold/italic, and microtype.
  • Not matching: 25-lst-java-roman. A roman OT1 listing sets " as cmr \char34 and the visible string space as cmr slot 32, which the T1 text metrics do not have. It is documented in the test.

Gates

  • cargo test --release (render-pipeline) is green on the current vendor pin.
  • HW1/HW2 rendering-v2 JSON is byte-identical to main.
  • The real-world corpus (9 fixtures) renders byte-identically to main.

Overlaps and notes

🤖 Generated with Claude Code

https://claude.ai/code/session_01Xd5Hmwh5GHNTiAmHUJ1MZu

GoKubar and others added 2 commits September 13, 2026 07:38
…P: listings next)

- Typewriter face: Role::Mono with the metrics \ttdefault selects
  (MonoMetrics): OT1 cmtt8/9/10/12 (ot1cmtt.fd), T1 ectt (t1cmtt.fd),
  lmodern ec-lmtt/ec-lmtk10 (t1lmtt.fd), Latin Modern Mono outlines;
  Courier under times. fonts/tfm/public/cm is searched for cmtt.
- Literal text (TextStyle::literal): shaped one character at a time (no
  ligatures or kerns, latex.ltx \@noligs), never hyphenated, never
  protruded or expanded (microtype's default sets are rm*/sf*); U+2423 is
  \asciispace (TFM slot 32).
- verbatim/verbatim*: Block::Verbatim laid out line by line (latex.ltx
  \@verbatim): typewriter glyphs at natural advances, a space or tab is one
  \nobreakspace (visible space under the star), empty lines are the \null
  box, \leftskip\@totalleftmargin inside lists, the size in force (source
  scan), the \trivlist glue (\topsep, \partopsep in vertical mode,
  \vskip\parskip, \@beginparpenalty/\@endparpenalty -51) and \@endpe.
- \verb/\verb*: typewriter text with no-break spaces read from the source.
- fixtures/verbatim: 31 pdfLaTeX (MacTeX 2026) references (oracle.py,
  make_fixtures.py; oracle only) and tests/verbatim_oracle.rs (glyph origins
  and rules within 0.1 bp): the 15 verbatim/\verb fixtures pass.
- HW1/HW2 rendering-v2 JSON byte-identical to main.

Implementation-Agent: Claude Opus 5 (subagent kabir-claude verbatim fidelity, mac-m5pro-kabir)
Commit-Executor: Claude Code direct Git
Co-Authored-By: Claude Opus 5 <[email protected]>
…as listings.sty sets them

- listings.rs: the keys of lstlisting/\lstinline/\lstinputlisting, \lstset
  and \lstdefinestyle (read from the source, one scan per document); the
  [ANSI]C, [ISO]C++, Java and Python (2, the listings.cfg default, and 3)
  definitions of lstlang1.sty; and the output algorithm: identifier/other
  tokens, \lst@nolig elements for ` < > , ' - (\lst@do@noligs),
  \lst@FillFixed boxes (columns=[l|c|r]fixed), flexible/fullflexible/
  spaceflexible lost-space kerns, \lst@ProcessSpace/\lst@ProcessTabulator,
  gobble, firstline/lastline, comment/string/directive modes with their
  styles (commentstyle defaults to \itshape), keywords with their classes,
  showspaces/showstringspaces, and breaklines (discretionary after every
  box, breakindent/breakautoindent, \lst@breakProcessOther for ')').
- Listing blocks: lines at \@totalleftmargin + xleftmargin with strut
  extents, numbers=left/right (\normalfont + numberstyle, numbersep in that
  font), frame=single/lines/top/bottom/left/right rules and skips
  (lstmisc.sty \lst@frameInit/\lst@frameExit: \lineskip, framesep,
  framerule, stacked strut lines), \penalty-50 + aboveskip/belowskip.
- \lstinline: an inline item laid out with flexiblecolumns (kerns and boxes,
  no break points), once the compiler lexes it (compiler PR).
- Typewriter italic (cmitt10/ecit/ec-lmtti10), bold-oblique LM mono;
  BoxRec::Rule carries its top so frame rules sit anywhere in a line.
- fixtures/verbatim: 32 fixtures, 31 match pdfLaTeX within 0.1 bp (glyph
  origins and rules); 28-lstinline and 30-lst-lstset-margin are gated once
  vendor/compiler carries the compiler change. 25-lst-java-roman (OT1 roman
  \char34/\char32 in a roman listing) does not match and is documented.
- 32-verbatim-microtype: microtype leaves typewriter text unprotruded and
  unexpanded, as pdfTeX's default sets do.
- HW1/HW2 and the real-world corpus render byte-identically to main.

Implementation-Agent: Claude Opus 5 (subagent kabir-claude verbatim fidelity, mac-m5pro-kabir)
Commit-Executor: Claude Code direct Git
Co-Authored-By: Claude Opus 5 <[email protected]>
GoKubar added a commit that referenced this pull request Sep 13, 2026
Kept #157's label-only empty line before a display together with main's stretched_left predisplaysize. The merge log also records why #145 was aborted rather than merged.

Implementation-Agent: Claude Opus 5 (subagent kabir-claude integration, nixos-pc-kabir)
Commit-Executor: Claude Code direct Git
Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Xd5Hmwh5GHNTiAmHUJ1MZu
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
@GoKubar

GoKubar commented Sep 15, 2026

Copy link
Copy Markdown
Contributor Author

Closing as superseded — the work is already on main.

Replacement: superseded by #285, whose body says it "takes #145's intent"

Closed by the integration lane while clearing a 219-PR backlog (112 of them drafts). If this is wrong, reopen it and tell me — I would rather be corrected than leave stale work buried.

— orchestrator-astra (Commander)

@GoKubar GoKubar closed this Sep 15, 2026
@GoKubar
GoKubar deleted the agent/kabir-claude/verbatim-fidelity branch September 16, 2026 04:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant