feat: implement m:rad radical/sqrt converter#2784
feat: implement m:rad radical/sqrt converter#2784caio-pizzol merged 5 commits intosuperdoc-dev:mainfrom
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c680cca804
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
|
|
||
| if (degreeHidden || !deg) { | ||
| // Use msqrt if degree is explicitly hidden OR if m:deg is missing/empty | ||
| if (degreeHidden || !deg || (deg.elements ?? []).length === 0) { |
There was a problem hiding this comment.
Honor degHide=false when degree node is empty
The new || (deg.elements ?? []).length === 0 branch makes this converter emit <msqrt> even when m:degHide is absent or explicitly m:val="0" (degree should be visible). In documents with an intentionally visible but currently empty degree (for example, an unfinished n-th root placeholder), this now collapses the structure to a square root and drops the index slot semantics; <mroot> should still be preserved whenever degree visibility is on.
Useful? React with 👍 / 👎.
- Dedupe duplicate `m:rad converter` describe block in omml-to-mathml.test.ts - Add unit test for empty <m:deg/> with no <m:degHide> — Word's round-trip canonical form for "no explicit degree". Without the empty-deg check this case produced an invalid <mroot> with an empty index. - Add unit tests for ST_OnOff "on" / "off" variants on m:degHide (ECMA-376 §22.9.2.7) — Word normalizes these on save but other DOCX producers (Google Docs, LibreOffice, Pages) may emit them. - Treat m:degHide val="off" as not hidden — previously interpreted as true. - Restore correct spec citation §22.1.2.88 for m:rad (the prior change to §22.1.2.86 was incorrect; §22.1.2.88 is the rad section in ECMA-376). - Add math-radical-tests.docx behavior fixture (3 cases: canonical sqrt, cube root, empty-deg-no-degHide). - Add behavior tests asserting <msqrt> / <mroot> shape per case and that no <mroot> ever has an empty index.
|
Quick update on my last comment, @Anuj52 — actually walking that back. We tested your empty- I just pushed a commit to your branch with:
Sorry for the back-and-forth on closing this. Thanks for the fix! |
Add unit tests for m:val="1" (canonical Word output) and m:val="true" (ST_OnOff true alias) so degHide handling for the common true values is locked in, complementing the existing "no val" / "on" / "off" / "0" cases.
caio-pizzol
left a comment
There was a problem hiding this comment.
LGTM, tested locally. Thanks @Anuj52!
|
🎉 This PR is included in vscode-ext v2.3.0-next.4 |
|
🎉 This PR is included in esign v2.3.0-next.4 The release is available on GitHub release |
|
🎉 This PR is included in @superdoc-dev/react v1.2.0-next.1 The release is available on GitHub release |
|
🎉 This PR is included in template-builder v1.5.0-next.4 The release is available on GitHub release |
|
🎉 This PR is included in superdoc v1.26.0-next.4 The release is available on GitHub release |
|
🎉 This PR is included in superdoc-cli v0.7.0-next.4 The release is available on GitHub release |
|
🎉 This PR is included in superdoc-sdk v1.6.0-next.1 |
Closes #2598
Summary
This PR implements the
m:rad(radical) OMML to MathML converter, adding support for square roots and n-th roots in mathematical expressions.Changes
<msqrt>(for square roots with hidden/missing degrees) and<mroot>(for n-th roots).Verification
m:degHidelogic robustly according to ECMA-376 §22.1.2.86.Closes #2598