Repository navigation
compiler: a paragraph records the \baselineskip its \par read - #436
Merged
Merged
Conversation
TeX reads `\baselineskip` in `append_to_vlist` (§679), which `post_line_break`
(§877) calls once per line at `\par` time. One value therefore governs every
line of a paragraph, and it is the register's value when the paragraph
*ended* — not the one in force where its words were typed. `Parsed` now
carries that value per block as `block_par_leading`, a `ParLeading`
(`Option<FontSizeLevel>`, `None` = `\normalsize`), read from the parser's own
style at the moment it flushes the paragraph.
Measured with pdfTeX 3.141592653-2.6-1.40.27 (TeX Live 2025) on
`\documentclass[11pt]{article}`, baseline-to-baseline in the shipped page
(`\normalsize` 13.549 bp, `\small` 11.955 bp, `\footnotesize` 10.959 bp,
`\large` 13.948 bp):
{\small ...}<blank line> 13.549 the `}` restores it first
{\small ...\par} 11.955 `\par` is inside the group
words {\small more} words 13.549 a switch mid-paragraph
never moves the leading
\begin{quote}\small ...\end{quote} 11.955 `\endtrivlist` pars before
\begin{itemize}\small \item ... 11.955 `\end` closes the group
\begin{minipage}{3in}\small ... 11.955
The last three needed one more change: `\end{...}` restored the text style
from `env_styles` *before* the flushes that close the environment's last
paragraph, so that `\par` saw the outer size. It now restores after them,
next to — and for exactly the same reason as — the `\centering`/`\raggedright`
restore that already sat there ("environments that end their paragraph do so
while their own declarations are still in force").
No block gains or loses a field and nothing existing reads the new vector, so
this is additive: `crates/render-pipeline`, which builds against a pinned
`vendor/compiler`, is unaffected until that mirror is re-pinned. The pipeline
half is a separate PR.
`crates/compiler`: `cargo test --release --no-fail-fast` 0 failed (327 in the
lib plus every integration binary). New `tests/par_leading.rs`, 7 tests; on
main before this change two of them report
`left: [("Alpha", None), ("Epsilon", None)]` against
`right: [("Alpha", Some(Small)), ...]` — the `\end`-ordering cases.
Implementation-Agent: Claude Opus 5 (lane nixos-leading, linux-primary)
Commit-Executor: Claude Opus 5 (direct git, observed Cursor usage limit)
Co-authored-by: GoKubar <[email protected]>
Contributor
Author
|
Pipeline half: #437. It is blocked on re-pinning |
This was referenced Sep 14, 2026
GoKubar
added a commit
that referenced
this pull request
Sep 14, 2026
…n `par-leading` on `vendor/compiler` is re-pinned to `faa7d484` (WIP commit df05f74); this makes the pipeline compile against what it finds there and switches `par-leading` on. `par-leading` was inert: #437's `Block::Paragraph::leading_pt` needs #436's `Parsed::block_par_leading`, which the old pin did not carry. Measured end to end from a clean checkout, not inferred from a green build: `{\small ...\par}` in an 11pt article now sets baselines 11.955 bp apart, exactly pdflatex's 11.955 bp (`\small` = 12pt in size11.clo); the old pin gave 13.549 bp, i.e. `\normalsize`, wrong by 1.594 bp per line. Three moved compiler APIs, none swallowed by a wildcard arm: * `Inline::HFill { leader }` (#320). The glue is set exactly — `\hrulefill` and `\dotfill` are `\leavevmode\leaders<box>\hfill\kern\z@`, so all three parts are emitted. Both extras are load-bearing: `\leavevmode` keeps a lone `\hrulefill` paragraph from being dropped along with the `\vspace` before it (that took `enumitem-worksheet` from 3 pages to 2), and `\kern\z@` stops TeX's end-of-paragraph final-glue deletion (tex.web §816) from eating a trailing fill. The leader box is *not* painted — this pipeline has no leaders outside `typeset/toc.rs`, and paragraph-layout reports no per-glue set width — so every occurrence is lowered with a typed `unsupported_inline` warning naming the command. `fixtures/divergence-probes/min-hrulefill`, which recorded `Date:` 198.51 bp left of pdflatex, is now 0.55 bp from the oracle. * `Diagnostic.labels`/`.notes`/`.help` (#346/#389). display-list-v2's diagnostic is `additionalProperties: false` over `{code, message, severity, sources}`, so rather than invent wire fields, `from_compiler` folds them onto the fields that already mean the same thing: label spans join `sources`, their texts plus notes and help become `[note: …]`/`[help: …]` clauses on `message`, and `help.replacement` back-fills `suggestion`. One line only — `flashtex-render --tex` prints `severity[code] message (line:col)` per line. * `Inline::Underline` (#328/#390). PR #329 was written for this re-pin, is pipeline-only and applied cleanly; its only integration gap was a `VBlock` literal predating `broken_penalty`. The pin itself also starts warning `unsupported_feature` for `\usepackage{amsmath}`, which `e44d5917` did not. That line is user-visible on every amsmath document and claims "not implemented" about constructs this pipeline does set — a cross-crate disagreement for the owners, not something a re-pin settles. `tests/amsmath_inline.rs` excludes that one wording by a documented predicate and stays strict about everything else. Gates: render-pipeline 295 passed / 0 failed / 2 ignored (254 before); compiler 588 / 0 / 4; amsmath 59/59; tabular 106/106; HW1 and HW2 3 pages, 0 errors, 0 font-FAILURE diagnostics; corpus page counts 22/22. Corpus geometry (rank.py, same pdf-exact, only the producer varying), before → after: dx 85.74% → 85.61%, dy 75.04% → 75.73%, both 68.97% → 69.11%, aligned words 15073 → 15099, reflowed 131 → 129. 21 of 22 fixtures are bit-identical; all movement is `enumitem-worksheet` (dy +34.14 pp, aligned 332 → 357) plus one word in `unicode-accents`. That fixture's dx percentage falls 2.75 pp while its absolute count rises 157 → 159: 25 more words are measured, and the new ones sit outside 0.5 bp because the leader rule is still unpainted. No other vendor directory needed re-pinning; the four that differ from `main` do so by their own rows' deliberate choices, and the vendored compiler type-checks against them. Implementation-Agent: Claude Opus 5 (lane vendor-repin-2, 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
GoKubar
added a commit
that referenced
this pull request
Sep 14, 2026
… catch the pipeline up to it (#451) * WIP: vendor/compiler re-pinned to faa7d48 + par-leading enabled (does not compile yet) * render-pipeline: build against the re-pinned vendor/compiler, and turn `par-leading` on `vendor/compiler` is re-pinned to `faa7d484` (WIP commit df05f74); this makes the pipeline compile against what it finds there and switches `par-leading` on. `par-leading` was inert: #437's `Block::Paragraph::leading_pt` needs #436's `Parsed::block_par_leading`, which the old pin did not carry. Measured end to end from a clean checkout, not inferred from a green build: `{\small ...\par}` in an 11pt article now sets baselines 11.955 bp apart, exactly pdflatex's 11.955 bp (`\small` = 12pt in size11.clo); the old pin gave 13.549 bp, i.e. `\normalsize`, wrong by 1.594 bp per line. Three moved compiler APIs, none swallowed by a wildcard arm: * `Inline::HFill { leader }` (#320). The glue is set exactly — `\hrulefill` and `\dotfill` are `\leavevmode\leaders<box>\hfill\kern\z@`, so all three parts are emitted. Both extras are load-bearing: `\leavevmode` keeps a lone `\hrulefill` paragraph from being dropped along with the `\vspace` before it (that took `enumitem-worksheet` from 3 pages to 2), and `\kern\z@` stops TeX's end-of-paragraph final-glue deletion (tex.web §816) from eating a trailing fill. The leader box is *not* painted — this pipeline has no leaders outside `typeset/toc.rs`, and paragraph-layout reports no per-glue set width — so every occurrence is lowered with a typed `unsupported_inline` warning naming the command. `fixtures/divergence-probes/min-hrulefill`, which recorded `Date:` 198.51 bp left of pdflatex, is now 0.55 bp from the oracle. * `Diagnostic.labels`/`.notes`/`.help` (#346/#389). display-list-v2's diagnostic is `additionalProperties: false` over `{code, message, severity, sources}`, so rather than invent wire fields, `from_compiler` folds them onto the fields that already mean the same thing: label spans join `sources`, their texts plus notes and help become `[note: …]`/`[help: …]` clauses on `message`, and `help.replacement` back-fills `suggestion`. One line only — `flashtex-render --tex` prints `severity[code] message (line:col)` per line. * `Inline::Underline` (#328/#390). PR #329 was written for this re-pin, is pipeline-only and applied cleanly; its only integration gap was a `VBlock` literal predating `broken_penalty`. The pin itself also starts warning `unsupported_feature` for `\usepackage{amsmath}`, which `e44d5917` did not. That line is user-visible on every amsmath document and claims "not implemented" about constructs this pipeline does set — a cross-crate disagreement for the owners, not something a re-pin settles. `tests/amsmath_inline.rs` excludes that one wording by a documented predicate and stays strict about everything else. Gates: render-pipeline 295 passed / 0 failed / 2 ignored (254 before); compiler 588 / 0 / 4; amsmath 59/59; tabular 106/106; HW1 and HW2 3 pages, 0 errors, 0 font-FAILURE diagnostics; corpus page counts 22/22. Corpus geometry (rank.py, same pdf-exact, only the producer varying), before → after: dx 85.74% → 85.61%, dy 75.04% → 75.73%, both 68.97% → 69.11%, aligned words 15073 → 15099, reflowed 131 → 129. 21 of 22 fixtures are bit-identical; all movement is `enumitem-worksheet` (dy +34.14 pp, aligned 332 → 357) plus one word in `unicode-accents`. That fixture's dx percentage falls 2.75 pp while its absolute count rises 157 → 159: 25 more words are measured, and the new ones sit outside 0.5 bp because the leader rule is still unpainted. No other vendor directory needed re-pinning; the four that differ from `main` do so by their own rows' deliberate choices, and the vendored compiler type-checks against them. Implementation-Agent: Claude Opus 5 (lane vendor-repin-2, 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 * render-pipeline: an appended `[help: …]` clause must not defeat the package supersede Regression in this branch, found in review of #451. `from_compiler` appends the compiler's structured `help`/`notes` to `message` as ` [help: …]` clauses; `packages::supersede_message` ends its match with strip_suffix(" are recognised but not implemented") so with a clause on the end the match failed, the `else` branch returned the message unchanged, and every superseded `\usepackage` diagnostic leaked into the render output. Not just amsmath: every package in `implemented_by_pipeline` — amsfonts, lmodern, microtype, geometry, graphicx, tikz — and the mixed list too, where `packages amsmath, booktabs, …` should be trimmed to `booktabs` and was instead shown in full, telling the reader this pipeline does not implement things it does. `split_clauses` now peels trailing clauses off the body before matching and re-attaches them to whatever survives a trimmed list. It keys on the clause *shape* — ` [<label>: <text>]` with a plain-word label, bracket-depth aware so clause text may contain brackets and a body merely ending in `]` is not eaten — rather than on the two labels that exist today, so a third kind appended later needs no further fix. `preamble_command_superseded` reads the body too: `lib.rs` calls it on the compiler's diagnostic *before* the conversion, so it was not leaking, but it compares the whole message for equality and would the moment that call moved. Measured on the owner's fixtures, before → after: HW1 6 → 4 diagnostics, HW2 9 → 7, `unsupported_feature` leaks 2 → 0 in each; what remains is `math_resource_profile`, which is informational. This also retracts a wrong conclusion in the previous commit. I had reported the amsmath warning as purely a consequence of the re-pin and loosened `tests/amsmath_inline.rs` to tolerate it. The pin does newly emit it, but it never reaches a consumer — the supersede drops it — so it was visible only because of the bug above. That test is restored to `main`'s strict assertion and passes 11/11 on its own. Tests: `packages` unit tests for a superseded message with a clause (each of the eight packages), the mixed list with a clause, several clauses, clause text holding brackets, and bodies that merely end in `]`; plus two end-to-end tests in `compiler_diagnostic_forward` covering the real render path, which is where the clause actually gets appended. The existing `supersede_message` tests all used bare messages, which is why this got through. Gates re-run: render-pipeline 303 passed / 0 failed / 2 ignored; amsmath 59/59; tabular 106/106; HW1 and HW2 3 pages, 0 errors, 0 font-FAILURE diagnostics; corpus page counts 22/22. Corpus geometry is unchanged by this commit (dx 85.61%, dy 75.73%, both 69.11%, aligned 15099) — the supersede moves diagnostics, not glyphs. Implementation-Agent: Claude Opus 5 (lane vendor-repin-2, 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 --------- Co-authored-by: Claude Opus 5 <[email protected]>
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.
What
Parsedrecords, per block, the\baselineskipTeX's\parwould have readfor it:
block_par_leading: Vec<ParLeading>, whereParLeadingisOption<FontSizeLevel>andNoneis\normalsize.This is the compiler half of a two-PR split. The
render-pipeline half (
agent/nixos-leading/par-leading-pipeline) consumes it and cannot land untilcrates/render-pipeline/vendor/compileris re-pinned past this commit(
vendor/VENDORING.md); it is written behind an off-by-defaultpar-leadingfeature so it builds and behaves identically against the current pin in the
meantime.
The rule, and why the obvious version of it is wrong
\smalland friends are not font changes — each calls\@setfontsizewith asize and a
\baselineskip. But TeX reads\baselineskipinappend_to_vlist(§679), whichpost_line_break(§877) calls once per lineat
\partime. One value governs every line of a paragraph, and it is theregister's value when the paragraph ended.
So the leading does not follow "the size the words were typed at". Measured
with pdfTeX 3.141592653-2.6-1.40.27 (TeX Live 2025) on
\documentclass[11pt]{article}, baseline-to-baseline in the shipped page:{\small ...}then a blank line}restores it before the\par{\small ...\par}{\large ...\par}{\footnotesize ...\par}words {\small more} words\begin{quote}\small ...\end{quote}\begin{itemize}\small \item ...\begin{minipage}{3in}\small ...Row 2 is the one that matters: a fix that read the paragraph's run sizes
("every glyph is
\small, so use\small's leading") would get it wrong, andit is a case the engine already handled correctly.
The one behaviour change
Rows 7–9 needed
\end{...}to stop restoring the text style fromenv_stylesbefore the flushes that close the environment's lastparagraph —
\endtrivlistruns\ifhmode\unskip\par\fibefore\end's\endgroup, so that\paris still inside the declaration. The restore nowsits next to the
\centering/\raggedrightone that was already deferred forexactly this reason, under the comment that already said so:
Everything else is additive: no block gains or loses a field, and nothing
existing reads the new vector.
Tests
New
crates/compiler/tests/par_leading.rs, 7 tests, one per row above plus aninvariant test that
block_par_leadingstays one-entry-per-block acrossheadings,
tabular,verbatim, displays and footnotes.On
mainbefore this change, the two\end-ordering tests reportcargo test --release --no-fail-fastoncrates/compiler: 0 failed.pdflatex is an oracle only and never runs in the product path.
🤖 Generated with Claude Code
https://claude.ai/code/session_01Xd5Hmwh5GHNTiAmHUJ1MZu