Repository navigation
Conversation
…le-material' into agent/kabir-claude/listings-engine # Conflicts: # crates/render-pipeline/fixtures/verbatim/reference/28-lstinline.json
`lstlisting` and `\lstinline` set the way listings.sty sets them: the column algorithm, the skips, the gutter, the frames, `tabsize`/`gobble`, `xleftmargin`, `breaklines` and the language styles. Draft PR #145's 1623-line `listings.rs` was written against a `Role::Mono`/`MonoMetrics` font model main has since replaced; this takes its intent and its test material and writes the mechanism against NFSS. `src/listings.rs` is the source scan and the character machine, all of it transcribed from TeX Live 2025's listings.sty 1.10b / lstmisc.sty and checked against pdflatex on this host: * A listing is **not** a `\trivlist`. `\lst@Init` is `\par\penalty-50 \vspace\lst@aboveskip ... \normalbaselines`, `\lst@DeInit` the mirror image; `\vspace` is the unstarred LaTeX one, so two adjacent listings add both skips (27-lst-showstringspaces: 6+6+12 = 24 pt). * One `\hbox to <N>\lst@width` per *token*, not per character, filled `\lst@lefthss c1 \hss c2 ... cN \lst@righthss`. `\lst@width` is fixed once at `InitVars` from `basicstyle` and `fontadjust` is false, so a `keywordstyle`/`commentstyle` switch moves glyphs *inside* a cell (`[c]` divides the slack the natural widths leave) but never the grid. * The "comma anomaly" #145 recorded and could not explain is `\lst@do@noligs`. `\lst@SelectCharTable` rewrites each character of `\verbatim@nolig@list` as `\lst@NoLig <old meaning>`, and `\lst@NoLig` appends a zero-width `\lst@nolig` to whatever token is *open* before the character's own processing flushes it: same `\lst@length`, one more item, so `[c]` divides by N+2. Measured here: of `! " ( ) + . / : ; = ? [ ] * 0 Z` after a 12-letter token only `,` and `-` change the divisor, and `ab,,cd` puts both commas in one two-cell box -- both are what the `\lst@NoLig` reading predicts. * `\lst@ProcessTabulator` really does keep absolute tab stops, unlike `\@verbatim` (PR #235); `\lst@GotoTabStop` splits at beginning-of-line. * `\lst@frameInit`'s box is `framesep + framerule` high, so the measured above-gap `aboveskip + \lineskip + framesep + framerule + 0.7bls` falls out of the ordinary interline rule with no `\prevdepth` term -- listings' own `\ifdim\prevdepth<\@cclvi\p@` guard never fires. * listings suppresses ligatures and kerns unconditionally, roman `basicstyle` included: every character is its own box here. `\verb` and `\@verbatim` keep `Shaper::shape_with`'s `\@noligs` split, which is the right mechanism *there*; the two are deliberately not unified. The compiler has no `\lstset` and drops `lstlisting`'s option list, so the pipeline reads both from the source bytes (the arrangement PR #188 anticipated) and the adapter drops the inlines the compiler made of a `\lstset` argument -- the same treatment `Block::Picture` gives a `tikzpicture`'s body text. That unblocks 28-lstinline and 30-lst-lstset-margin without touching `crates/compiler` or the vendored mirror. `verbatim_oracle`: 30 of 34 fixtures gated (13 before), worst 0.062 bp, no substitution diagnostics. 33-lst-columns-lr and 34-lst-roman-ligatures are new, with their own TeX Live 2025 references, for the `[l]`/`[r]` alignments and for the ligature finding above (`office` sets as six glyphs in a roman `basicstyle`). 25-lst-java-roman stays out: listings sets `"` as `\char34` and the `showstringspaces` space as `\verbvisiblespace` = `\asciispace` = `\char32` of the current font, and in a roman `basicstyle` those are cmr10's own OT1 slots (0.500002 em and 0.277779 em by `tftopl`) which the pipeline's T1/EC addressing cannot reach; 3 of its 231 glyphs land 0.62-1.10 bp out. Implementation-Agent: Claude Opus 5 (listings lane, linux-primary / NixOS) Commit-Executor: Claude Opus 5 via Claude Code (direct-agent Git execution after the observed Cursor usage limit) Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Xd5Hmwh5GHNTiAmHUJ1MZu
…ub.com:flash-tex/flashtex into agent/kabir-claude/listings-engine # Conflicts: # crates/render-pipeline/fixtures/verbatim/reference/28-lstinline.json
The listings engine branched from PR #262 and so did not carry #268 (`\@verbatim`'s `\trivlist` inside a list) or #271 (microtype's verbatim patch, and `\frenchspacing` inside `\verb`). Merging them makes the stack linear -- #262 -> #268 -> #271 -> this -- and moves both of their fixtures into `GATED` alongside the seventeen listings ones. The only conflict is `tests/verbatim_oracle.rs`'s three lists, resolved by taking every name both sides gate: * `GATED` 32 = the 15 verbatim/`\verb` fixtures (`10-verbatim-itemize` and `32-verbatim-microtype` from this merge) plus the 17 listings ones. * `NOT_YET` 2: `15-verbatim-small` keeps the `\showoutput` measurement from #271, `25-lst-java-roman` keeps the OT1-slot measurement from the listings lane. * `LISTINGS_NOT_YET`, added in #262 so `main`'s freshly merged #248 fixtures were accounted for rather than failing the accounting test, is gone: every name in it is now either gated or in `NOT_YET`. One fixture got better from the merge rather than from either side alone. **`28-lstinline` goes from 0.062 bp to 0.005 bp**: #271 carries the fix for the interword space that was being dropped after an inline `\verb` or `\lstinline` (`after_control_word` stayed set even though `prev_end` had already advanced past the closing delimiter), and that space is in this fixture's first line. Gates, control-compared against a `git archive` checkout of the listings branch's own base `b7a1e530`, built and measured identically: | gate | control | merged | |---|---|---| | `crates/render-pipeline` `cargo test --release --no-fail-fast` | 217 / 0 / 1 | 229 / 0 / 1 | | amsmath oracle corpus | -- | 59/59 within 0.5 bp | | real-world corpus, 22 fixtures x 2 producers | 739 diagnostics | 724 | | real-world corpus status and page count | -- | identical, every entry | | real-world corpus font-substitution diagnostics | 0 | 0 | | HW1 / HW2 render | -- | 3 / 3 pages, 0 errors, 0 overfull | | verbatim + listings fixtures matching pdfLaTeX | 30 of 34 | **32 of 34** | The +12 are the listings lane's unit tests. The two corpus entries that differ are the ones #271 already documents (`twelvept-plain` and `listings-manual`, both losing `unsupported_block` limitations; the three `overfull_hbox` in `listings-manual` are pdfLaTeX's own behaviour minus `breaklines` inside `\lstinline`). The listings engine itself adds no corpus diagnostic in either direction. 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
changed the base branch from
agent/kabir-claude/verbatim-listings-relanding
to
agent/kabir-claude/verbatim-microtype-frenchspacing
September 14, 2026 02:25
This was referenced Sep 15, 2026
Contributor
|
Superseded — reimplemented independently and landed via #453 ( Verified on Closed by the Commander after a stale-draft screening pass that required evidence in both directions — a landing SHA to close, an empty grep to keep open. If this verdict is wrong, say so on issue #2 and I will reopen: an asymmetric bar has produced wrong calls here in both directions before. |
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.
Stacked on #262 (
agent/kabir-claude/verbatim-listings-relanding, baseb7a1e530), which already carries the merge ofmainwhere #248's sixteenlistingsfixtures and their TeX Live 2025 references landed. Head is70dab5ba; the only substantive commit afterb7a1e530is972ee828, and the diff against the base iscrates/render-pipelineonly.Draft PR #145's 1623-line
listings.rswas correctly not merged — it was written against aRole::Mono/MonoMetricsfont modelmainhas since replaced with NFSS. This takes #145's intent and #248's test material and writes the mechanism against the current model.What it does
lstlistingand\lstinlineset the waylistings.stysets them: the column algorithm, the vertical skips, thenumbersgutter, the frames,tabsize/gobble,xleftmargin,breaklines, and thelanguagestyles.src/listings.rs(new) — the source scan (\begin{lstlisting}[…],\lstset{…}), the option list, and the character machine that decides which output box every code character lands in. No metrics: it is a pure function of the source.src/typeset.rs—Context::listing_blocksturns that plan into glyphs, kerns and rules once NFSS has selected the face.src/adapter.rs—Block::Listing, found from the source bytes the wayBlock::Picturefinds atikzpicture; the compiler's flush-left lowering of the body is dropped.Everything below is transcribed from TeX Live 2025's
listings.sty1.10b /lstmisc.styand checked against pdflatex on this host. pdflatex is an oracle only; it is not in the product path.A listing is not a
\trivlist\lst@Initis\par\penalty-50 \vspace\lst@aboveskip … \normalbaselines;\lst@DeInitis the mirror image. No\topsep, no\partopsep, no\@totalleftmargin.\vspaceis the unstarred LaTeX one — a plain\vskipthat does not\addvspace-merge — so two adjacent listings add both skips (27-lst-showstringspaces: 6 + 6 + 12 = 24.0 pt between them, not 18).\normalbaselinesruns beforebasicstyle, so a size-changingbasicstylesets\baselineskipfor the listing: the above gap uses the listing's, the below gap the following text's.One box per token, not per character
\lst@OutputTokensets\hbox to <N>\lst@width{\lst@lefthss c1 \hss c2 \hss … cN \lst@righthss}for a maximal run of letters or of "other" characters.\lst@widthis fixed once atInitVarsfrombasicstyleandfontadjustis false by default, so akeywordstyle/commentstyleswitch moves glyphs inside a cell —[c]divides the slack the natural widths leave — but never the grid.The "comma anomaly" is
\lst@do@noligs#145 recorded that a token immediately followed by a comma has its slack divided into N+2 parts instead of N+1, and could not explain it. It is
\lst@SelectCharTable's\let\do\lst@do@noligs \verbatim@nolig@list, which rewrites every character of\@noligsas\lst@NoLig <old meaning>;\lst@NoLigis\advance\lst@length\m@ne \lst@Append\lst@nolig, so it appends a zero-width box to whatever token is currently open, before that character's own processing decides to flush it. Same\lst@length, one more item, one more\hss.Measured on this host to confirm and bound it:
abcdefghijklfollowed by each of! " ( ) + . / : ; = ? [ ] * 0 Zkeeps the N+1 divisor; only,and-— the two\@noligscharacters that occur in the fixtures — change it.abcdefghijkl ,(a space between) keeps N+1: the space flushed the token first.ab,,cdputs both commas in one two-cell box (,+\lst@nolig+,, 4\hss), at 146.8441 / 153.1205 bp against a measured 146.8439 / 153.1203.All three are what the
\lst@NoLigreading predicts and none is what "a following comma" alone predicts. The\lst@Delay/\lst@MergeTokenhypothesis in the specification is refuted: those macros are not on this path.listings suppresses ligatures unconditionally
#187 assumed a roman
basicstylekeeps its ordinary ligatures because listings applies only\@noligs. It does not. New fixture34-lst-roman-ligaturessetsoffice fluffy affix wafflewith nobasicstyleat all: pdflatex emitso f f i c eas six separate CMR10 glyphs, nofi, noffi. Every character is its own box here, which is why.\verband\@verbatimkeepShaper::shape_with's\@noligssplit, which is the right mechanism there; the two constructs are deliberately not unified.tabsize, frames,xleftmargin\lst@ProcessTabulatorreally does keep absolute tab stops, unlike\@verbatim(compiler: a verbatim tab is one space, not an 8-column stop #235):\lst@GotoTabStopsplits at beginning-of-line into pure lost space, and elsewhere into a box one\lst@outputspacewide with the remainder inserted around it.\lst@frameH's box is exactlyframesep + framerulehigh, so the measured above-gapaboveskip + \lineskip + framesep + framerule + 0.7·blsfalls out of the ordinary interline rule with no\prevdepthterm — listings' own\ifdim\prevdepth<\@cclvi\p@guard is inverted and never fires for a real previous depth, so the\advance\@tempdima\prevdepthinside it is dead code. The regime whereframesep + framerule >= \baselineskip(no\vskipat all) is not modelled and is flagged in the source; no committed fixture is in it.xleftmargin=2emis expanded inside the listing afterbasicstyle, so30-lst-lstset-margin's2emis 2 × cmtt8's quad. cmtt8's em is 8.5 pt, not 8.4 —ec-lmtt8'sQUADis1.0625bytftopl, matching.The
\lstsetblocker, worked around in the pipelineThe compiler has no
\lstsetand dropslstlisting's option list, so the pipeline reads both from the source bytes — the arrangement #188 anticipated — and the adapter drops the inlines the compiler made of a\lstsetargument, the same treatmentBlock::Picturegives atikzpicture's body text. That unblocks28-lstinlineand30-lst-lstset-marginwithout touchingcrates/compileror the vendored mirror, and without waiting for a re-pin. Novendor/or font file is touched.Fixtures: 30 of 34 gated, 13 before
16–24,26–31,33,34join the thirteenverbatimfixtures already gated. Worst error 0.062 bp (28-lstinline), every other listings fixture ≤ 0.006 bp, zero font-substitution diagnostics.LISTINGS_NOT_YETis emptied and removed;25-lst-java-romanmoves intoNOT_YETwith a measured reason.Two fixtures are new, with their own TeX Live 2025 references, for options #248's material left uncovered:
33-lst-columns-lr—columns={[l]fixed}andcolumns={[r]fixed}(adjacent advance exactlyW, first glyph at 0 and atW−w).34-lst-roman-ligatures— the ligature finding above.25-lst-java-romanstays out for a reason that is not about listings: 228 of its 231 glyphs are exact, and the three that are not are OT1 slot lookups the pipeline's T1/EC addressing cannot reach. listings sets"as\char34and theshowstringspacesspace as\verbvisiblespace, which under pdfTeX is\asciispace=\char32of the current font; in a romanbasicstylethose are cmr10's own slots, 0.500002 em (quotedblright) and 0.277779 em (suppress) bytftopl, against T1'squotedblandvisiblespace(0.5 em inec-lmr10). They land 0.62, 1.10 and 0.62 bp out.Gates, each against a
git archive b7a1e530control measured the same waycrates/render-pipelinecargo test --release --no-fail-fast, bundled fonts exportedlistingsunit tests)verbatim_oraclefixtures gated--no-oracle --no-pixels), 22 fixtures × 2 producerslistings-manual(new onmain) exercises this change hardest: its display-list item count goes 286/233/278 → 662/752/238 as the two listings move onto the real cell grid in the typewriter face, and its page count, status and every one of its fifteen diagnostics are unchanged — the threeoverfull_hboxit already had stay at 9.82, 118.42 and 52.24 pt, andbreaklineskeeps the listing bodies from adding any.Known gaps
breaklinesinside\lstinline.\lstinlineitself is exact (28-lstinline, 115 glyphs), but it still goes through the base's literal-text path, which has no break points. pdflatex breaks inside an inline listing whenbreaklinesis on; that is the remaining 118.42 pt overfull inlistings-manual. It needs a break-point item inadapter::Itemand is deliberately left to a follow-up rather than bolted on at the end of this change.columns=spaceflexible,fontadjust,frameround,framex*margin,shadowbox(drawn assingle),rulecolor/backgroundcolor,stepnumber/firstnumber/numberblanklines(implemented, untested),keepspaces/showspaces/showtabs(implemented, untested),breakatwhitespace(implemented, untested),prebreak/postbreak,emph/morekeywords/literate,escapechar/texcl/mathescape,caption/label/float,firstline/lastline, a listing that breaks across a page. Unmodelled keys are reported as anunsupported_blocklimitation rather than silently ignored.\vrules are emitted per line rather than merged into one rectangle; the oracle compares glyphs, not rules, but both framed fixtures' rules were checked by hand and agree with the committed rectangles to 0.001 bp once the segments are joined (21-lst-frame-single: 153.6936 → 208.2889, against 153.694 + 54.595).🤖 Generated with Claude Code
https://claude.ai/code/session_01Xd5Hmwh5GHNTiAmHUJ1MZu
Integration update — merged with #268 and #271, now 32 of 34
This PR now sits at the top of the lane's stack: #262 → #268 → #271 → #285, and its base has been repointed accordingly. The last commit merges #268 (
\@verbatim's\trivlistinside a list) and #271 (microtype'sverbatimpatch, and\frenchspacinginside\verb), which this branch had forked below.Everything below was re-measured by the integrating lane on the merged result, not taken on report.
32 of 34 fixtures match pdfLaTeX exactly, worst 0.006 bp. The 17 listings fixtures gated here, plus all 15 verbatim/
\verbones —10-verbatim-itemizeand32-verbatim-microtypearrive with the merge.NOT_YETis down to two, each with a measurement rather than a plan:15-verbatim-small— needs the compiler'sstyleonInline::Verbatim/Block::Verbatim(PR compiler: listings setup commands set nothing; verbatim carries the size declaration #261) plus a vendor re-pin. Verified by an uncommitted vendor swap: with it the horizontal geometry is exact and the block is left exactly 1.0 pt low, which\showoutputattributes to the block taking the body's 12 pt baselineskip instead of\small's 11 pt.25-lst-java-roman— 228 of 231 glyphs exact; the three that miss are OT1 slot lookups (\char34= cmr10quotedblright0.500002 em,\char32=suppress0.277779 em) that the T1/EC font model cannot address.One fixture got better from the merge than from either side alone
28-lstinline: 0.062 bp → 0.005 bp. #271 carries the fix for the interword space that was being dropped after an inline\verb/\lstinline—after_control_wordstayed set even thoughprev_endhad already advanced past the closing delimiter — and that space is in this fixture's first line. Worth noting because it was the one listings fixture an order of magnitude off the rest.Gates on the merged result
Control is a
git archivecheckout of this branch's own baseb7a1e530, built and measured identically with the bundled fonts exported.crates/render-pipelinecargo test --release --no-fail-fastThe +12 are this branch's listings unit tests. The two corpus entries that differ from
mainare the ones #271 already documents (twelvept-plainandlistings-manual, both losingunsupported_blocklimitations); the listings engine itself adds no corpus diagnostic in either direction, andlistings-manual's threeoverfull_hboxstay at exactly 9.82 / 118.42 / 52.24 pt.Relaying the note this branch could not deliver
The three specification corrections are received and stand as the record —
\lst@do@noligs(not\lst@Delay/\lst@MergeToken) as the comma anomaly,\lst@breakProcessOthermaking)end its token underbreaklines, and\lst@frameInit's\prevdepthadvance being dead code against\@cclvi\p@.34-lst-roman-ligaturesconfirming unconditional ligature suppression with nobasicstyleat all is the right way to have closed that one.breaklinesinside\lstinlineis agreed as the next step and is the remaining 118.42 pt overfull inlistings-manual: reduced to one paragraph with that fixture's preamble, pdflatex overfulls the same line by 113.38 pt withoutbreaklinesand by nothing at all with it.