feat(math): implement m:limLow and m:limUpp limit converters#2771
feat(math): implement m:limLow and m:limUpp limit converters#2771caio-pizzol merged 6 commits intosuperdoc-dev:mainfrom
Conversation
…, SD-2378) Add lower limit (m:limLow → <munder>) and upper limit (m:limUpp → <mover>) OMML-to-MathML converters per ECMA-376 §22.1.2.54 and §22.1.2.56. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
@caio-pizzol pls take a look |
Remove duplicate m:rad test block that was cleaned up upstream. Preserve m:limLow and m:limUpp test suites.
ECMA-376 §22.1.2 defines m:sty (style: p/b/i/bi) and m:scr (script: roman, script, fraktur, double-struck, sans-serif, monospace) on math run properties. Word emits m:sty="p" on function names like "lim", "max", "sup" — without this handling those names rendered italic instead of upright when they appear outside an m:func wrapper. Precedence: m:sty > m:scr > m:nor. m:nor stays as the legacy normal flag, equivalent to m:sty="p" when no explicit style or script is set.
- Tighten "handles missing m:e/m:lim gracefully" tests: assert arity-2 <munder>/<mover> with an empty <mrow> on the missing side (was only checking the present side). - Add multi-run base tests for both converters — existing tests only exercised multi-run m:lim, leaving the m:e base-wrapping path untested. - Add nested-math tests (fraction inside m:lim) for both converters. - Add m:func-wrapped tests (m:func > m:fName > m:limLow/m:limUpp) — the shape Word actually emits when the base is a function keyword. - Add full coverage for m:sty (p/b/i/bi), m:scr (6 variants), and m:sty > m:scr precedence per ECMA-376 §22.1.2.
…/2378) New fixture math-limit-tests.docx contains 8 Word-native limit shapes: m:limLow in m:func, bare m:limUpp, m:limLow with fraction in m:lim, bare m:limLow, m:limUpp in m:func, multi-char non-lim function bases (max, sup), and m:limLow with a nested m:sSub in the limit expression. Seven new it blocks assert: - arity of <munder> (6) and <mover> (2) - nested <mfrac> inside <munder> (case 3) - nested <msub> inside <munder> (case 8) - mathvariant=normal on function keywords via m:sty val=p - bare identifiers keep italic default (no stray mathvariant) - property elements (m:limLowPr/m:limUppPr/m:ctrlPr) don't leak to DOM The same fixture is uploaded to the shared R2 corpus as sd-2377-limlow-limupp-showcase-all-cases.docx so test:layout and test:visual cover these shapes automatically.
|
@gpardhivvarma nice work! pushed a few commits to tighten things up. added handling for two word-specific markers that make function names like "lim", "max", "sup" render upright instead of italic — word puts these on by default but we weren't reading them. also beefed up the tests: tightened the "missing input" cases, added tests for bases with multiple parts, nested math inside the limit, and the wrapping word uses in real documents. dropped in a fixture with 8 real word equations + uploaded them to the test corpus so layout and visual regressions pick them up. two things out of scope i'll open separate tickets for: variables inside wrapped limits come out upright when they should be italic, and multi-letter operator names end up as identifiers. both live elsewhere. verified in the dev app. good to merge once CI is green. |
|
🎉 This PR is included in @superdoc-dev/react v1.2.0-next.2 The release is available on GitHub release |
|
🎉 This PR is included in template-builder v1.5.0-next.5 The release is available on GitHub release |
|
🎉 This PR is included in vscode-ext v2.3.0-next.5 |
|
🎉 This PR is included in esign v2.3.0-next.5 The release is available on GitHub release |
|
🎉 This PR is included in superdoc-cli v0.7.0-next.5 The release is available on GitHub release |
|
🎉 This PR is included in superdoc v1.26.0-next.5 The release is available on GitHub release |
|
🎉 This PR is included in superdoc-sdk v1.6.0-next.2 |
Summary
m:limLow(lower limit) →<munder>converter per ECMA-376 §22.1.2.54m:limUpp(upper limit) →<mover>converter per ECMA-376 §22.1.2.56MATH_OBJECT_REGISTRYand export from barrel fileCloses #2599 (SD-2377)
Closes #2600 (SD-2378)
Changes
converters/lower-limit.tsm:limLow→<munder>withm:ebase +m:limlimitconverters/upper-limit.tsm:limUpp→<mover>withm:ebase +m:limlimitconverters/index.tsomml-to-mathml.tsMATH_OBJECT_REGISTRYomml-to-mathml.test.tsTest plan
pnpm exec vitest run src/features/math/omml-to-mathml.test.ts— 69/69 passing