Repository navigation
render-pipeline: per-glyph source spans inside math (needs #161 re-pin) - #165
Merged
Merged
Conversation
…ph-spans) Behind `math-glyph-spans` (off until vendor/math-layout is re-pinned to PR #161), math glyph clusters and rules get the provenance of the compiler atom that produced them instead of the whole formula: scripts, fraction parts, `\left`/`\right` each to its own command (tall extensible delimiters included), radical signs, accents, `\text` runs and grid fences. `MathRec::span_paints` paints leaves by innermost source range, the hook for #150/#158's math colour ranges; cached formulas relocate their tag spans. Four MathBox literals take `..MathBox::empty()` so the crate builds on both pins. Current pin, feature off: all tests green. Scratch copy with #161 vendored and the feature on: all tests green (incl. incremental cached == fresh and tests/math_glyph_spans.rs 3/3); HW1/HW2 display lists identical except 302/416 provenance ranges, each narrowed inside the old formula range; amsmath corpus 59/59 unchanged. Implementation-Agent: Claude Opus 5 (subagent kabir-claude math glyph spans, mac-m5pro-kabir) Commit-Executor: Claude Code direct Git Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Xd5Hmwh5GHNTiAmHUJ1MZu
This was referenced Sep 13, 2026
GoKubar
added a commit
that referenced
this pull request
Sep 13, 2026
Clean merge; supplies MathBox::tag throughout. #157's new squeezed-display MathBox literal takes SourceTag::NONE, like #165's synthetic glue. 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 13, 2026
Main moved 18 commits past this lane's base (bffd168): the `flashtex` CLI, inline-math line breaking (a2f85bf, 2c37374), entry-document command order before `\input` (c1e3bab), thebibliography label geometry (ea4f383) and enumitem keys in a list's own optional argument (ec10bc6). 15 conflicts: 3 in typeset.rs, 12 in adapter.rs. None of the vendored crates changed on main, so the stage-2 re-pin at b1f5791 is still exact. typeset.rs - `MathRec`'s new fields are additive on both sides: this lane's `span_paints` (#165/#158) and main's `inline_breaks`/`continues`. Both kept, in the struct and in the initialiser. - The `AItem::Math` arm was a real disagreement: this lane calls `math_box_sized(.., size)` then paints one `math_run`; main calls `math_box` then `math_pieces`. `math_pieces` already falls back to exactly one `math_run(root, size, span)` when `inline_breaks` is empty, so main's loop subsumes this lane's body. Resolved to main's structure with this lane's size-aware constructor, which is the one thing main's `math_box` drops (it hard-codes `style.body_size_pt`, wrong where the surrounding run is not body size). - `BoxKind::Glue { mu }` no longer matches: this lane's math-layout carries real TeX glue components (tex.web 716 `math_glue`). main's `math_pieces` predates them and derives stretch/shrink from `mu` by plain.tex's muskip values, which is what its pdflatex line-break oracle measured, so the derivation is kept unchanged and the new fields are ignored (`{ mu, .. }`). Replacing it with the real components is a follow-up, not a merge decision. adapter.rs — both sides independently rewrote the list-separation model - Both implemented the *same* enumitem feature: applying the keys of a list's own `\begin[<keys>]` after every `\setlist`. This lane factored it into `class_seps` + `apply_sep_keys` + `list_seps(.., options, ..)`; main inlined it in a `list_seps`/`list_seps_with` pair. This lane's is a superset -- it also resolves `em`/`ex` against the EC body font (93d5573) -- so its structure stands and main's two wrappers are dropped. With that, `list_seps_with` has no callers left. - Main's `gap_has_list_end` reaches only the innermost closed list; this lane's `list_end_skip` walks every list closed in the gap with per-level `begin_vmode` and `\addvspace` max semantics. This lane's is kept. - Main's thebibliography coverage is preserved instead through `LIST_ENVS`, which now takes the union of both sides: `itemize`, `enumerate`, `description` (this lane) and `thebibliography` (main). All four are `\list`s, so all four count for `\@listdepth`. `list_env_after_begin` and `list_end_adjust` now test against `LIST_ENVS` rather than repeating the names, so the three predicates cannot drift apart again. - Main's special case for thebibliography's `\begin{thebibliography}{99}` argument is unnecessary here: `is_key_list("99")` is already false (no `=`, no enumitem key), so this lane's stack passes it through harmlessly. - `\@nbitem` after a heading: took main's ea4f383, which is the deliberate newer decision -- a non-negative `\addvspace{\@outerparskip - \parskip}` adds to the heading's after-skip rather than maxing with it. - `BodyCommand`: both sides add variants (`RunIn`/`SecNumDepth` here, `Input` on main); all kept. - git had also misaligned a doc comment, leaving `body_commands`' docs stranded above `math_title_spans`. `math_title_spans` now carries its own, and `body_commands` gets main's (which documents `\input`/`\include`). Gates after the merge (NixOS PC, TeX Live 2025, bundled symlink-free tree plus the nix-store `ec` for `ectt*`; no committed oracle data regenerated). Every number below was taken with the fixed harness, which fails on any font diagnostic, and all of them report zero: - amsmath 59/59, amssymb 38/39, tabular 59/59, xcolor 28/28, display-placement 33/36 (the 3 are real content differences, not fallback). - HW1 and HW2: 3 pages each, 0 overfull, 0 errors, 0 diagnostics of any kind. - real-world corpus 10/10 recovered (main's a2f85bf adds `inline-math`), every page count equal to its committed MacTeX reference, 0 font-fatal diagnostics. `font_outline_substituted` appears twice on article-twocolumn and once on input-bibliography: advisory only, outlines not metrics. 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
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
Click-to-source, colour and link rectangles inside formulas. Today every math glyph cluster and rule in the display list carries the whole formula's source range. Behind a new
math-glyph-spansfeature (off by default; it needs the vendor re-pin below), each one carries the range of the compiler atom that produced it.convert_math_classedtags every math-layout atom with its compilerMathAtom.span.\left/\rightpairs becomeDelimitedatoms tagged with the whole pair, and each delimiter keeps its own command's span (delimiter_tags). An unclosed\leftkeeps its own span.\textruns (mathtext::substitute) and nested grids (substitute_grids) inherit their handle glyph's tag, so their glyphs, fences and rules map to the\text/environment command. Top-level grids ingrid_formulado the same.math_itemsgives each cluster and ruleleaf_src(tag)(falling back to the formula span, which never happens in the tests below), and splits glyph runs when paint changes.MathRec::span_paints(feature-gated, empty today) pluspaint_of: the innermost source range containing a leaf's span sets its paint. This is where compiler: color/xcolor with pdfTeX-exact colour operators (982/982 oracle) #150/render-pipeline, pdf: paint color/xcolor with pdfTeX's exact operators (28/28 oracle; needs #150 re-pin) #158 plug in: fill it fromInline::Math::color_rangesinstead of painting the whole formula. hyperref (compiler: hyperref options, autoref/nameref, link/destination/bookmark records (35/132) #131) link rectangles can take the hit rects of clusters whose provenance lies in the link's range.incremental::relocate_blockshifts tag spans (andspan_paints) when a cached formula moves.MathBoxstruct literals (mathgrid.rs,mathtext.rs) gain..MathBox::empty(), which compiles against both the current pin and the re-pinned math-layout.No display-list schema change: clusters and rules already carry
provenance, and only the byte ranges get narrower.Dependency / re-pin order
SourceTag). Merge it, or take it into the integration branch.vendor/math-layoutto that commit. This PR builds and tests green on the current pin with the feature off, and it needs no compiler change.math-glyph-spans, ideally promoting it todefaultas was done foramsmath-inline.MathRec::span_paintsfrom the math colour ranges, then add a fixture comparing against pdflatex colour operators.Verification
Current pin, feature off:
cargo test --releaseall green. A scratch copy (uncommitted) with #161 swapped intovendor/math-layoutand--features math-glyph-spans:cargo test --release: all suites green (65 lib unit tests includinginnermost_source_range_paints_a_math_leaf;tests/incremental.rscached == fresh bytes over the edit script with inline and display math, which exercises tag relocation; the newtests/math_glyph_spans.rs3/3).--font-dir apps/mac/Fonts, 3 pages each): every non-provenance value is identical (glyph ids, origins, advances, run text, clusters, hit rects, carets, rules, paints). Provenance changed on 302/2751 (HW1) and 416/2423 (HW2) entries, each narrowed inside the old formula range.crates/compiler/tests/amsmath_corpus/oracle.py check): 59/59 within 0.5 bp, unchanged from main.New fixtures in
tests/math_glyph_spans.rs(skip when Latin Modern is missing):x_i^2,\frac{a}{b},\sqrt{z},\hat{w},\text{if }: each letter and script maps to its own bytes; the √ maps to\sqrt, ˆ to\hat, the\textglyphs to the\text{if }span; the fraction bar and vinculum map to\frac/\sqrt.\left( … \right], plus inline\left\{ y \right.: delimiters map to\left(,\left\{,\right], and no glyph maps to the whole formula.\sum_{k=0}^{n}andcases: the operator maps to\sum, limits and cells to themselves, the cases brace to the environment.Colour inside math is covered by span plumbing plus the paint unit test only: #150/#158 aren't merged, so there are no math colour ranges to compare against pdflatex yet.
Merge notes
Likely textual conflicts: #158 (adds
MathRec::colorandmath_itemspaint), #148/#146 (display math), and the other open pipeline PRs touchingtypeset.rs's math conversion (#124/#125/#126/#127). All changes here are additive andcfg-gated.Implementation-Agent: Claude Opus 5 (subagent kabir-claude math glyph spans, mac-m5pro-kabir)
🤖 Generated with Claude Code
https://claude.ai/code/session_01Xd5Hmwh5GHNTiAmHUJ1MZu