Repository navigation
math-layout: source spans and attribute ids on placed glyphs and rules - #161
Merged
Merged
Conversation
…d rules
Atoms gain a `SourceTag { span: Option<SourceSpan>, attr: Option<u32> }`
(plus `delimiter_tags` for \left/\right and \genfrac delimiters). Layout
copies it onto every glyph and rule leaf the atom produces that no inner
atom already tagged (innermost first, per field), and `positioned_runs`
exposes it as `PositionedGlyph::tag` / `PositionedRule::tag`. Consumers
can now map math glyphs to their own source bytes (click-to-source,
link rectangles) and paint per-glyph attributes such as colour.
Coverage: scripts, fractions (bar -> \frac), radicals (sign, extensible
pieces and vinculum -> \sqrt), \left/\right (each side its own command,
extensible pieces included), genfrac delimiters, accents (incl. the
scripted-character path), operator text and \operatorname lists, big
operators, extensible arrows, over/underbraces (pieces and fill rules),
subarrays, styled bodies, overline/underline.
Additive only; tags are never read for geometry. tests/source_spans.rs
lays out every fixture (plus ext arrow, substack, brace, binom, \big) in
three styles fully tagged and untagged: box trees equal after stripping
tags and every glyph/rule position bit-identical; goldens 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
…ession handoff) Stage 1 partly done: #131, #137, #153 (incl. #142), #144, #147, #149, #150, #155, #159, #163, #164 merged with conflicts and post-expansion fixes recorded in docs/evidence/integration-2026-09-13b/merge-log.md. Remaining: #166, #169, #148, #161, then the inventory regeneration and stages 2-4. The helper scripts under tools/ hard-code the original worktree path. Implementation-Agent: Claude Opus 5 (subagent kabir-claude integration, 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
GoKubar
added a commit
that referenced
this pull request
Sep 13, 2026
Conflicts against #148: MathBox::glue_flex (SourceTag plus stretch/shrink) and the mathlist.rs imports. math-layout 54 tests pass. 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
Math glyphs currently map only to the whole formula, so colour, hyperlinks and click-to-source can't reach inside math (see #150/#158, #131). This adds provenance to math-layout, additively:
SourceTag { span: Option<SourceSpan { document, start, end }>, attr: Option<u32> }(newsource.rs).Atom::tagandAtom::delimiter_tags(own tags for\left/\rightor\genfracdelimiters), withwith_tag/with_delimiter_tagsbuilders.MathBox::tag(set on glyph/rule leaves),PositionedGlyph::tag,PositionedRule::tag.Layout copies each atom's tag onto the leaves it produces that no inner atom already tagged (innermost first, per field). Result:
\left/\rightdelimiters (extensible pieces included) map to their own commands whendelimiter_tagsare set, otherwise to the atom;attr(colour or link id) inherits independently ofspan, so{\color{red} a {\color{blue} b}}givesared andbblue while each keeps its own bytes.Geometry is untouched
Tags are never read for layout.
tests/source_spans.rslays out every fixture plus\xrightarrow,\substack,\overbrace,\binomand\big(in display, text and script style, fully tagged and untagged. The box trees are equal once tags are stripped, and every glyph and rule position matches bit for bit (f64::to_bits). Goldens are unchanged (10 + 28 pass), plus 11 new span tests; clippy is clean.crates/font-engine(the other consumer of../math-layout) tests pass unchanged.Consumers / merge notes
Atom,MathBox,PositionedGlyphorPositionedRuleoutside this crate need the new field or..Default-style update syntax. On main, onlycrates/render-pipeline(mathtext.rs,mathgrid.rs) buildsMathBoxliterals, and it uses the vendored pin, so nothing breaks until it's re-pinned. The pipeline PR handles that.MathBox::pack_to) touches the sameMathBox/Engine::listcode, so the resolution is to keep both field sets and theinherit_tagcall. math: amssymb symbol table (224/229), msam/msbm TFMs, braces and over/under arrows (compiler + math-layout) #126/compiler: skip the [t]/[b]/[c] position argument of nested grids (#115 split, part 1) #124/render-pipeline: lay out grids nested inside sub-formulas as boxes (#115 split, part 2) #125 are pipeline-side or add nuclei, and new nuclei need no tag handling beyond the generic leaf inheritance.MathAtom.spanalready exists. Colour ranges from compiler: color/xcolor with pdfTeX-exact colour operators (982/982 oracle) #150 (Inline::Math::color_ranges) and link ranges from compiler: hyperref options, autoref/nameref, link/destination/bookmark records (35/132) #131 are source byte ranges, so the pipeline can resolve them per glyph from these spans.attris available for callers that prefer ids.Implementation-Agent: Claude Opus 5 (subagent kabir-claude math glyph spans, mac-m5pro-kabir)
🤖 Generated with Claude Code
https://claude.ai/code/session_01Xd5Hmwh5GHNTiAmHUJ1MZu