Repository navigation
Conversation
…thing
`\lstset` had no dispatch arm, so it reached `P::unsupported`, whose recovery
policy deliberately leaves a brace group alone when its contents do not look
like a parameter. `{basicstyle=\ttfamily}` does not, so the group fell through
to the paragraph and did two wrong things at once: it typeset the literal
`basicstyle=`, and the `\ttfamily` inside it switched the body font for the
rest of the group. pdflatex of course sets nothing for `\lstset`.
Measured on fixtures/verbatim/28-lstinline.tex's source, this compiler's own
page items (non-space characters):
| | control (origin/main 9a82257) | this branch | pdflatex TL2025 |
|---|---|---|---|
| body glyphs | 125 | 114 | 114 (+1 page number) |
| diagnostics | `\lstset is not supported by this compiler version` | none beyond the `listings` package warning | — |
The 11-glyph delta is exactly `basicstyle=`.
Consumed here, in the same shape as the `\graphicspath` arm above them — and
placed before the preamble catch-all, because every one of these is ordinary
preamble material:
\lstset{<keys>}
\lstdefinestyle / \lstdefinelanguage, which share one argument grammar:
[<dialect>]{<name>}([<base dialect>]{<base>})?{<keys>}[<aspects>]
lstmisc.sty defines both as `\lst@DefDriver ... \lstset` (`\lst@DefStyle`,
`\lst@DefLang`) and listings.sty 294-319 reads exactly that; the optional
parts are `\@ifnextchar[` lookaheads in the package and lookaheads here.
\lstinputlisting[<keys>]{<file>} — consumed and reported: there is no
listing renderer, but the file name is a parameter and must not become
prose.
\lstMakeShortInline[<keys>]{<char>} — consumed and reported: the catcode
shorthand is not modelled (this compiler tokenizes once), so text between
the shorthand characters stays ordinary prose.
\lstDeleteShortInline{<char>} — a real no-op: it restores the state this
compiler is already in.
`\lstnewenvironment` is deliberately left out and is now listed in
`vocabulary.rs` as known-but-unimplemented instead of being misreported as a
typo. Consuming its definition would leave the environment it names unknown
to the lexer, so the listing body would be tokenized as ordinary LaTeX —
macros expanded, `%` starting a comment, braces grouping — with no diagnostic
at all. That needs the lexer to learn a new verbatim environment first.
Diagnostics: `\lstset`, `\lstdefinestyle` and `\lstdefinelanguage` are silent.
That is what the sibling that landed in #188 already does — `lexer.rs` on
`\lstinline[<keys>]` says "The keys are not read here: they set no text, and
the renderer scans them from the source", and listings.sty defines
`\lstinline` as `\lstset{flexiblecolumns,#1}`, so the two are the same key
list in different places. It is also what `\graphicspath` does, for the same
reason: the value is re-read from the source by the consumer that needs it.
The existing `\begin{lstlisting}[<opts>]` warning stays and is not
inconsistent with this: it is attached to a body this compiler does typeset
itself, and typesets wrongly under those options. It reports a wrong
rendering that has already happened, not the mere presence of a setting.
`\lstinputlisting` and `\lstMakeShortInline` warn for that same reason —
content really is missing from the page where they stand.
No parse-tree record is added for the argument spans. `\graphicspath` is the
precedent (`graphics.rs`: "consumed without a diagnostic; its search list is
re-read from the source by a consumer that loads files"), and the render
pipeline already re-reads `\lstset`/`\lstdefinestyle` from the source bytes,
so the commands only need to occupy their span and emit nothing.
Brace nesting is `required_group`'s depth counter, not a scan to the first
`}`, so `basicstyle={\ttfamily\small}`, `literate={x}{y}1` and
`morekeywords={a,b,c}` are one argument each. The optional brackets go
through `bracket_argument`, which splits `[a]text` (one lexer word) instead of
swallowing the text after the `]`.
`\lstinline` lexing is untouched: `src/lexer.rs` has no diff.
cargo test --release in crates/compiler, against a `git archive origin/main`
control of the same base: 469 passed / 0 failed / 4 ignored (control) ->
475 passed / 0 failed / 4 ignored (branch). The +6 are the six new tests here.
`crates/compiler/supported/`, `docs/user/compiler.md` and the Mac app's
bundled byte-copy are regenerated artefacts of the inventory
(`scripts/render_supported_latex.sh`, `apps/mac/scripts/sync-supported-latex.sh`),
required by `tests/supported_latex.rs` and the CI sync gate.
Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Xd5Hmwh5GHNTiAmHUJ1MZu
`Inline::Verbatim` had only `{ text, span, space_before }` and
`Block::Verbatim` only `{ lines, span }`, so the declaration in force where
a `\verb` or a `\begin{verbatim}` was read never left the parser. A consumer
that reads `TextStyle::size` off the compiler's inlines — rather than
re-scanning the source for size declarations, which the render pipeline
deliberately stopped doing (pin b38e188) — therefore had no way to know that
`{\small \verb|x|}` is CMTT9, not CMTT10.
Both variants now carry `style: TextStyle`, not a narrower
`size: Option<FontSizeLevel>`. Every other inline that has a style at all
(`Text`, `Logo`, `Rule`, `Kern`, `Tabular`) carries the whole `TextStyle`
through one group/environment stack; a parallel size-only channel would be a
second mechanism for the same scoping rule. The scoping rule itself is not
new: `self.style` at the construction site, restored by `style_stack` at a
closing brace and by `env_styles` at an `\end` — exactly what bold and italic
already do, `\normalsize` included.
`\begin{small}` needed one more thing to work. latex.ltx's `\begin` opens a
group and runs the macro its argument names; `\end` runs `\end<name>`, which
is undefined for a font declaration and so `\relax`, then closes the group.
So `\begin{small}` IS `\small`, scoped like `{\small ...}`. This compiler had
no such rule, and reported `environment 'small' is not implemented; its body
is typeset as plain text` instead. One branch in `P::environment` applies
`apply_style` for any `style_declaration` name, after `env_styles` has
recorded the style to restore. The two spellings now agree, and a face
declaration (`\begin{bfseries}`) works for the same reason. It adds no
environment-inventory entry on purpose: the name is not an environment of its
own but a declaration already in the command inventory, reached through the
kernel's generic rule, so `tests/supported_latex.rs`'s arm-to-inventory gate
stays exact.
`layout.rs` now reads the size off both, the same one-line `map_or` that
`Inline::Text` and `Inline::Tabular` already use — a size on the wire that
the compiler's own layout ignored would be a new inconsistency. For a
`Block::Verbatim` the declaration also sets the body's baseline-to-baseline
distance, as in real LaTeX. The vertical gap *before* the block
(`VERBATIM_TOPSEP_PT`) still uses the document body size; scaling `\topsep`
with the declaration is a separate change.
Evidence, `fixtures/verbatim/15-verbatim-small.tex`'s source through the
compiler binary. pdflatex TL2025 (`tools/visual-oracle/pdftext.py` on an
uncompressed run) sets the two inline `\verb`s at 8.9664 and 7.9701 bp and
the environment body at 8.9664 against a 9.9626 bp body — 0.9 and 0.8 of the
body size:
| item | control | this branch | ratio to body | pdflatex ratio |
|---|---|---|---|---|
| `{\small \verb\|small inline\|}` | 12 pt (body) | 10.95 pt | 0.9125 | 0.9000 |
| `{\footnotesize\verb\|fn\|}` | 12 pt (body) | 10 pt | 0.8333 | 0.8000 |
| `\begin{small}` verbatim body | 12 pt (body) | 10.95 pt | 0.9125 | 0.9000 |
control also raised `environment 'small' is not implemented`; this branch
raises nothing. The ratios differ from pdflatex's because this Core-14
layout's body size is the fixed `layout::BODY_SIZE_PT` = 12 (an article with
no size option is set at 12 pt here, not 10), so `size_declaration_pt` reads
the 12 pt class table. That is the pre-existing body-size model, untouched
here: `\verb` now takes exactly the size an `Inline::Text` in the same place
takes (`normal` 12 / `{\small small}` 10.95 / `{\footnotesize fn}` 10 /
`{\small \verb|sv|}` 10.95). The declaration *level* on the wire —
`Small`, `FootnoteSize` — is what a consumer with the real class size reads.
Call sites updated: `incremental.rs`'s `shift_block`/`shift_inlines` exhaustive
patterns (a style carries no span) and the two `layout.rs` arms above. No
crate outside `crates/compiler` matches or builds these variants —
`crates/render-pipeline` builds against `vendor/compiler`, which is untouched.
cargo test --release in crates/compiler: 478 passed / 0 failed / 4 ignored,
against 469 / 0 / 4 on a `git archive origin/main` control of the same base.
The +9 are this branch's two commits (6 + 3); no other delta.
Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Xd5Hmwh5GHNTiAmHUJ1MZu
…setup/lstset-consumes-arguments # Conflicts: # docs/user/compiler.md
GoKubar
added a commit
that referenced
this pull request
Sep 14, 2026
…guessed Both remaining `NOT_YET` entries were checked against PR #261's compiler rather than reasoned about: its `crates/compiler` was exported into `vendor/compiler` **uncommitted**, measured, and the tree restored (`git status` clean; the committed pin is untouched, and re-pinning is not this lane's to do). Four pipeline arms are needed for the new `style` field on `Inline::Verbatim`/`Block::Verbatim` — two patterns, one initializer that threads the block's style down to each line, and the lowered `Inline::Text` taking `..*vstyle` instead of `CStyle::default()`. (A fifth, unrelated error comes from `text_builtins::text_kern` having gained an `amsmath` argument on main since the pin; a re-pin carries that too.) With that in place: * **28-lstinline matches**: 115 glyphs, worst 0.005 bp. The 11 stray `basicstyle=` characters are gone. * **15-verbatim-small is left exactly 1.0 pt low, and nothing else.** Its horizontal geometry becomes exact — the body sets in CMTT9 and the line's last glyph lands at 194.964 against pdfTeX's 194.964. `\showoutput` names the residue: pdfTeX's skip above the block is `\glue 10.0 plus 4.0 minus 5.0` (`\topsep` 8+2−4, `\partopsep` 2+1−1, `\parskip` 0+1 — which this pipeline already computes), and its `\glue(\baselineskip) 3.55557` is `\small`'s **11 pt** baselineskip minus the previous line's depth 1.94444 and this line's height 5.49998. The pipeline sets the block at the body's 12 pt. That one difference is the whole remaining pound, and it is the block's baselineskip following its size declaration — the same field the re-pin delivers. Recorded in `NOT_YET` so the lane that does the re-pin starts from the numbers instead of rediscovering them. 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
Merged
Contributor
Author
|
Closed under the old-engine freeze (DESIGN.md D13): this is old-path feature or hand-port work, and the old engine retires at the P5 switch-over. The branch is kept; reopen it if it turns out to be a critical user-facing fix. — kabir-claude (Commander), nightly review 2026-09-30 |
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.
Two separate commits, both compiler-only.
crates/render-pipeline/(vendored mirror included) has no diff in either.1 —
\lstsetand its siblings consume their arguments and set nothing\lstsethad no dispatch arm, so it reachedP::unsupported. That recovery policy deliberately leaves a following brace group alone unless its contents look like a parameter;{basicstyle=\ttfamily}does not, so the group fell through to the paragraph and did two wrong things at once — it typeset the literalbasicstyle=, and the\ttfamilyinside it switched the body font for the rest of the group. pdflatex sets nothing for\lstset.Measured with the compiler binary on the
fixtures/verbatim/28-lstinline.texsource, counting non-space characters in the emitted page items:git archive origin/main, 9a82257)\lstset is not supported by this compiler version; unrestricted TeX math mode is not implementedlistingspackage warning\lstinlinesx = a + b;/int y;/s -- tThe 11-glyph delta is exactly
basicstyle=. Oracle counted withtools/visual-oracle/pdftext.pyon an uncompressedpdflatexrun of the same source (115 glyphs = 114 body + the page number).A second case, the same setup in the preamble with nested braces:
control raises 8 errors (
\lstset is not supported in the document preamble, then\ttfamily/\smallleaking out of the arguments, ...); this branch raises none.What is consumed
Placed beside the
\graphicspatharm and, like it, before the preamble catch-all, because every one of these is ordinary preamble material as well as body material.\lstset{<keys>}\lstdefinestyle/\lstdefinelanguage\lstinputlisting[<keys>]{<file>}\lstMakeShortInline[<keys>]{<char>}\lstDeleteShortInline{<char>}\lstnewenvironment\lstdefinestyleand\lstdefinelanguageshare one argument grammar, so one helper covers both: lstmisc.sty defines them as\lst@DefStyle/\lst@DefLang=\lst@DefDriver{...}...\lstset, and\lst@DefDriver(listings.sty 294-319) readsEach optional part is an
\@ifnextchar[lookahead in the package and is a lookahead here too.Why
\lstnewenvironmentis leftIt defines an environment whose body listings reads under verbatim catcodes. Consuming the definition would leave the environment it names unknown to the lexer, so the listing body would be tokenized as ordinary LaTeX — macros expanded,
%starting a comment, braces grouping — with no diagnostic at all. That is a worse and quieter failure than the one it replaces. It needs the lexer to learn a new verbatim environment first, which is a separate change. It is now listed invocabulary.rsas known-but-unimplemented, so it is at least classified as real LaTeX rather than as a typo.The diagnostic decision
\lstset,\lstdefinestyleand\lstdefinelanguageare silent.lexer.rson\lstinline[<keys>]says "The keys are not read here: they set no text, and the renderer scans them from the source", and its test asserts\lstinline[language=C]!int z!produces no diagnostics. listings.sty defines\lstinlineas\lstset{flexiblecolumns,#1}— the same key list in a different place — so warning about one and not the other would be the inconsistency.\graphicspathdoes, for the same reason (graphics.rs: "consumed without a diagnostic; its search list is re-read from the source by a consumer that loads files"). The render pipeline re-reads\lstset/\lstdefinestylefrom the source bytes, so nothing is dropped.The existing
\begin{lstlisting}[<opts>]warning — "lstlisting options are not implemented; typeset as plain verbatim" — stays, and is not inconsistent with this. It is attached to a body this compiler does typeset itself and typesets wrongly under those options: it reports a wrong rendering that has already happened at that spot, not the mere presence of a setting.\lstinputlistingand\lstMakeShortInlinewarn for exactly that reason — content really is missing from the page where they stand.Information kept
No parse-tree record is added for the argument spans, following
\graphicspath: the commands occupy their source span and emit nothing, and the consumer that needs the keys re-reads them from the source. The spans themselves are untouched.Brace / nesting cases covered
required_groupcounts brace depth rather than scanning to the first}, so these are each one argument (all pinned by tests):basicstyle={\ttfamily\small}— a group inside a valueliterate={x}{y}1— adjacent groups in one valuemorekeywords={a,b,c}— a comma inside braces\lstdefinelanguage[R]{Mine}[ANSI]{C}{...}— the base-dialect/base-language form\lstdefinelanguage{Mine}{...}[keywords,comments]Body.— the trailing aspect list followed immediately by proseThe last one is why the optional brackets go through
bracket_argumentrather thanoptional_bracket_argument:[keywords,comments]Body.is a single lexer word, and onlybracket_argumentsplits it at the]instead of swallowingBody.with it.\lstinlinelexing is untouched —src/lexer.rshas no diff, and the\lstinlinetests from #188 still pass unchanged.Generated artefacts
crates/compiler/supported/supported-latex.json, the generated section ofdocs/user/compiler.mdand the Mac app's byte-identical bundled copy are regenerated outputs of the inventory (crates/compiler/scripts/render_supported_latex.sh,apps/mac/scripts/sync-supported-latex.sh).tests/supported_latex.rsrequires the first two and the CIsync-supported-latex.sh --checkstep requires the third; the Mac file is a generated byte-copy, not hand-written product code.supported/coverage.mdis unchanged — none of these names is in the canonical denominator.2 — verbatim carries the size declaration in force
Inline::Verbatimhad only{ text, span, space_before }andBlock::Verbatimonly{ lines, span }, so the declaration in force where a\verbor a\begin{verbatim}was read never left the parser. A consumer that readsTextStyle::sizeoff the compiler's inlines — rather than re-scanning the source for size declarations, which the render pipeline deliberately stopped doing (pinb38e1884) — had no way to know that{\small \verb|x|}is CMTT9, not CMTT10.Both variants now carry
style: TextStyle, not a narrowersize: Option<FontSizeLevel>: every other inline that has a style at all (Text,Logo,Rule,Kern,Tabular) carries the wholeTextStylethrough one group/environment stack, and a size-only channel would be a second mechanism for the same scoping rule. The scoping rule is not new either —self.styleat the construction site, restored bystyle_stackat a closing brace and byenv_stylesat an\end, exactly what bold and italic already do,\normalsizeincluded.\begin{small}needed one more thing. latex.ltx's\beginopens a group and runs the macro its argument names;\endruns\end<name>, undefined for a font declaration and so\relax, then closes the group — so\begin{small}is\small, scoped like{\small ...}. This compiler had no such rule and reportedenvironment 'small' is not implementedinstead. One branch inP::environmentnow appliesapply_stylefor anystyle_declarationname, afterenv_styleshas recorded the style to restore, so the two spellings agree and\begin{bfseries}works for the same reason. It deliberately adds no environment-inventory entry: the name is not an environment of its own but a declaration already in the command inventory reached through the kernel's generic rule, sotests/supported_latex.rs's arm-to-inventory gate stays exact.layout.rsreads the size off both, with the same one-linemap_orInline::TextandInline::Tabularalready use — a size on the wire that the compiler's own layout ignored would be a new inconsistency. For aBlock::Verbatimthe declaration sets the body's baseline-to-baseline distance too. The vertical gap before the block (VERBATIM_TOPSEP_PT) still uses the document body size; scaling\topsepwith the declaration is a separate change.Evidence —
fixtures/verbatim/15-verbatim-small.tex's sourcepdflatex TL2025 (
tools/visual-oracle/pdftext.pyon an uncompressed run) sets the two inline\verbs at 8.9664 and 7.9701 bp and the environment body at 8.9664, against a 9.9626 bp body — 0.9 and 0.8 of the body size.{\small \verb|small inline|}{\footnotesize\verb|fn|}\begin{small}verbatim bodycontrol also raised
environment 'small' is not implemented; this branch raises nothing.The ratios differ from pdflatex's because this Core-14 layout's body size is the fixed
layout::BODY_SIZE_PT= 12 — anarticlewith no size option is set at 12 pt here, not 10 — sosize_declaration_ptreads the 12 pt class table. That body-size model is pre-existing and untouched:\verbnow takes exactly the size anInline::Textin the same place takes (normal12 /{\small small}10.95 /{\footnotesize fn}10 /{\small \verb|sv|}10.95). The declaration level on the wire —Small,FootnoteSize— is what a consumer with the real class size reads.Parser-level tests pin all three fixture-15 cases plus
\verb|plain|,{\small x}\verb|after|(declaration ends with the group),{\small \normalsize\verb|reset|}, and both spellings acrossverbatim,verbatim*andlstlisting.Call sites updated
incremental.rs'sshift_block/shift_inlinesexhaustive patterns (a style carries no span) and the twolayout.rsarms. No crate outsidecrates/compilermatches or builds these variants —crates/render-pipelinebuilds againstvendor/compiler, untouched.Gates
cargo test --releaseincrates/compiler, against agit archive origin/maincontrol of the same base:Measured twice, each time against a
git archivecontrol of the branch's own base.mainafter the merge commit below)(passed / failed / ignored). The +9 are this branch's nine new tests — 6 for the listings commit, 3 for the verbatim one. No other delta in either run, and the ignored set is unchanged.
mainmoved while this was in flight, so the branch carries a third commit mergingorigin/mainin. Its only conflict wasdocs/user/compiler.md, a generated artefact, resolved by re-runningrender_supported_latex.sh; the resolved file ismain's content plus this PR's six rows. Every number above was re-measured after that merge.🤖 Generated with Claude Code
https://claude.ai/code/session_01Xd5Hmwh5GHNTiAmHUJ1MZu