Commit df44933
authored
fix(math): preserve italic on variables inside function-wrapped limits (SD-2538) (#2871)
* fix(math): preserve italic on variables inside function-wrapped limits (SD-2538)
Word wraps lim_(n→∞) as m:func > m:fName > m:limLow. convertFunction
was calling forceNormalMathVariant with querySelectorAll('mi'), which
recursed into the <munder> produced by m:limLow and stripped italic
from every variable inside m:lim.
Scope forceNormalMathVariant so it walks only non-structural children
and never overwrites an existing mathvariant — preserves m:sty/m:scr
authored styling on the function name and leaves nested limit,
subscript, superscript, matrix cells, etc. untouched.
* docs(llms): mention native math equation rendering
* test(math): add behavior-level regression for SD-2538
Pins the end-to-end shape of the fix by loading math-limit-tests.docx and
asserting that every <mi> inside a lim-based <munder>'s limit expression
has no mathvariant attribute — i.e. variables in m:lim stay italic when
m:limLow is wrapped in m:func > m:fName. Matches the canonical shape
produced by Word's own OMML2MML.XSL.
* refactor(math): apply review feedback on SD-2538 fix
- Rename STRUCTURAL_MATHML → MATH_VARIANT_BOUNDARY_ELEMENTS; the intent is
"where the walk stops", not "which elements are structural".
- Drop the inner walk closure and the Array.from snapshot — the outer
function already recurses cleanly; neither earned its keep.
Tests:
- Fold the SD-2538 unit test into the adjacent "m:limLow in m:func" test;
the fixture shape was identical, only the assertions differed.
- Extend "m:limUpp in m:func" with the symmetric mathvariant assertions so
the 'mover' entry of the boundary set is pinned, not just 'munder'.
- Add a preserve-branch test (m:sty=i on function name) to pin the
!hasAttribute guard — previously no test would have failed if we'd
removed it.
- Behavior test: assert exact count (5 munder + 1 mover) instead of >0,
and cover both limLow and limUpp in the same sweep.
Review context: Word's own OMML2MML.XSL confirmed as parity target. The
subtree-opaque concern from Codex was checked against the XSL output for
m:func > m:fName > m:sSub (f_i(x)) and matches our post-fix behavior.
* fix(math): restore Array.from on HTMLCollection iteration
The review-driven removal of Array.from broke type-check in CI:
HTMLCollection is not iterable under the default lib.dom.d.ts (needs
`dom.iterable`), so `for…of root.children` fails TS2488. Bun's looser
runtime type-check let it slide locally. Restoring Array.from with a
comment explaining why.1 parent db64892 commit df44933
4 files changed
Lines changed: 134 additions & 7 deletions
File tree
- apps/docs
- packages/layout-engine/painters/dom/src/features/math
- converters
- tests/behavior/tests/importing
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
| 12 | + | |
12 | 13 | | |
13 | 14 | | |
14 | 15 | | |
| |||
Lines changed: 31 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
6 | 27 | | |
7 | | - | |
8 | | - | |
9 | | - | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
10 | 38 | | |
11 | 39 | | |
12 | 40 | | |
| |||
Lines changed: 60 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
861 | 861 | | |
862 | 862 | | |
863 | 863 | | |
| 864 | + | |
| 865 | + | |
| 866 | + | |
| 867 | + | |
| 868 | + | |
| 869 | + | |
| 870 | + | |
| 871 | + | |
| 872 | + | |
| 873 | + | |
| 874 | + | |
| 875 | + | |
| 876 | + | |
| 877 | + | |
| 878 | + | |
| 879 | + | |
| 880 | + | |
| 881 | + | |
| 882 | + | |
| 883 | + | |
| 884 | + | |
| 885 | + | |
| 886 | + | |
| 887 | + | |
| 888 | + | |
| 889 | + | |
| 890 | + | |
| 891 | + | |
| 892 | + | |
| 893 | + | |
| 894 | + | |
| 895 | + | |
| 896 | + | |
| 897 | + | |
| 898 | + | |
| 899 | + | |
| 900 | + | |
864 | 901 | | |
865 | 902 | | |
866 | 903 | | |
| |||
2296 | 2333 | | |
2297 | 2334 | | |
2298 | 2335 | | |
2299 | | - | |
2300 | | - | |
| 2336 | + | |
| 2337 | + | |
| 2338 | + | |
| 2339 | + | |
| 2340 | + | |
| 2341 | + | |
| 2342 | + | |
| 2343 | + | |
| 2344 | + | |
| 2345 | + | |
| 2346 | + | |
| 2347 | + | |
2301 | 2348 | | |
2302 | 2349 | | |
2303 | 2350 | | |
| |||
2565 | 2612 | | |
2566 | 2613 | | |
2567 | 2614 | | |
2568 | | - | |
2569 | | - | |
| 2615 | + | |
| 2616 | + | |
| 2617 | + | |
| 2618 | + | |
| 2619 | + | |
| 2620 | + | |
| 2621 | + | |
| 2622 | + | |
| 2623 | + | |
| 2624 | + | |
| 2625 | + | |
2570 | 2626 | | |
2571 | 2627 | | |
2572 | 2628 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
724 | 724 | | |
725 | 725 | | |
726 | 726 | | |
| 727 | + | |
| 728 | + | |
| 729 | + | |
| 730 | + | |
| 731 | + | |
| 732 | + | |
| 733 | + | |
| 734 | + | |
| 735 | + | |
| 736 | + | |
| 737 | + | |
| 738 | + | |
| 739 | + | |
| 740 | + | |
| 741 | + | |
| 742 | + | |
| 743 | + | |
| 744 | + | |
| 745 | + | |
| 746 | + | |
| 747 | + | |
| 748 | + | |
| 749 | + | |
| 750 | + | |
| 751 | + | |
| 752 | + | |
| 753 | + | |
| 754 | + | |
| 755 | + | |
| 756 | + | |
| 757 | + | |
| 758 | + | |
| 759 | + | |
| 760 | + | |
| 761 | + | |
| 762 | + | |
| 763 | + | |
| 764 | + | |
| 765 | + | |
| 766 | + | |
| 767 | + | |
| 768 | + | |
727 | 769 | | |
728 | 770 | | |
729 | 771 | | |
| |||
0 commit comments