Fix MathTypst grouping changing expression layout - #4935
Open
ramgao wants to merge 1 commit into
Open
Conversation
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.
Overview: What does this pull request change?
Fixes
MathTypstselection groups so adding{{ ... }}metadata no longer changes the grouped expression's math style, spacing, or geometry.Fixes #4931.
Motivation and Explanation: Why and how do your changes improve the library?
The existing
manimgrphelper wrapped selected content in#box(body). That moved the body out of its surrounding math context, which changed display-style operators and glyph styling such as thexindif x.The helper now uses a temporary link with a private marker URL. Typst preserves the original math context and emits SVG link markers after the visible elements. During SVG post-processing, Manim converts only those private markers into labeled wrappers used by
select(), then removes the links and their transparent rectangles before SVG import.A regression test compares every rendered point of the issue's grouped integral with the identical ungrouped expression and verifies that selection still covers the full group.
Links to added or changed documentation pages
No documentation pages changed.
Testing
uv run pytest tests/module/mobject/text/test_typst_mobject.py -q— 35 passeduv run pytest tests/module/mobject/text -q— 114 passeduv run pytest --skip_slow -q— 1035 passed, 73 skipped, 6 xfailed, 2 xpasseduv run pre-commit run --files manim/mobject/text/typst_mobject.py tests/module/mobject/text/test_typst_mobject.py— all hooks passed3.195333371 × 1.559187513, contained 812 points, and had identical point geometry;select("integral")returned all 9 leaves.Further Information and Comments
The implementation relies on the SVG link-marker structure emitted by the supported Typst 0.14 series. The regression and existing Typst selection tests exercise this integration.
Reviewer Checklist