Skip to content

feat(math): implement m:phant phantom converter#2749

Merged
caio-pizzol merged 4 commits intosuperdoc-dev:mainfrom
Abdeltoto:feat/math-phantom-converter
Apr 13, 2026
Merged

feat(math): implement m:phant phantom converter#2749
caio-pizzol merged 4 commits intosuperdoc-dev:mainfrom
Abdeltoto:feat/math-phantom-converter

Conversation

@Abdeltoto
Copy link
Copy Markdown
Contributor

Closes #2608

Summary

  • Implements the m:phant OMML-to-MathML converter (invisible spacing placeholder)
  • Full phantom maps to <mphantom>; partial dimension control maps to <mpadded> with zeroed width/height/depth
  • Supports m:show, m:zeroWid, m:zeroAsc, and m:zeroDesc property flags
  • Registers the converter in MATH_OBJECT_REGISTRY
  • Adds 3 unit tests covering full phantom, visible with zeroed width, and invisible with zeroed height

Spec reference

ECMA-376 Section 22.1.2.81

Test plan

  • vitest run passes for omml-to-mathml.test.ts
  • Linter and formatter pass (lefthook pre-commit)

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 566fc42ea0

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/layout-engine/painters/dom/src/features/math/converters/phantom.ts Outdated
Comment thread packages/layout-engine/painters/dom/src/features/math/converters/phantom.ts Outdated
@Abdeltoto Abdeltoto force-pushed the feat/math-phantom-converter branch from 3e7e2c0 to c6b8cc6 Compare April 8, 2026 03:03
Copy link
Copy Markdown
Contributor

@caio-pizzol caio-pizzol left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Abdeltoto thanks for contributing this! the phantom converter is a nice addition and the code is clean — matches Word perfectly on 7 out of 10 test cases.

one thing to fix: when <m:show> is missing, content renders invisible but should be visible. this affects the most common phantom pattern (zeroing a dimension without explicitly setting show). left an inline comment with a one-line fix, comparison screenshots, and 10 Word-native test files.

Comment thread packages/layout-engine/painters/dom/src/features/math/converters/phantom.ts Outdated
@caio-pizzol caio-pizzol self-assigned this Apr 9, 2026
Abdeltoto and others added 4 commits April 13, 2026 16:08
Per ECMA-376 §22.1.2.96, when <m:show> is absent from <m:phantPr> the
base content should be shown. The previous check only handled bare and
truthy-val variants, so a missing element was treated as hidden —
breaking the most common phantom pattern (zeroing a dimension without
hiding content).

Adds unit coverage for the explicit-hide case and zeroed-dimension-only
case, plus a behavior test loading a 12-case fixture that walks every
m:phantPr configuration in the spec (show absent/bare/val=0/1/true/false,
each zero flag alone and combined, m:transp passthrough).
@caio-pizzol caio-pizzol force-pushed the feat/math-phantom-converter branch from c6b8cc6 to 6b0cb18 Compare April 13, 2026 23:13
@caio-pizzol
Copy link
Copy Markdown
Contributor

hey @Abdeltoto — didn't want to block this any longer so I pushed the last fix myself, hope that's cool.

your two fixes from round 1 look great. the one still open was the "no m:show" case — the spec says content should show when m:show isn't there, but the old check was hiding it. one-line change and it matches Word now.

while I was in there I went through every phantom setup the spec describes (12 in total) and they all render right. added a few more unit tests for the gaps, plus a browser test that loads all 12 in one doc. the doc is in our visual test set too, so we'll catch any future breakage.

also rebased on main — a bunch of other math converters landed since you opened this, so there were some conflicts to untangle.

thanks for picking this up, the code is clean. merging once CI's green.

@caio-pizzol caio-pizzol enabled auto-merge April 13, 2026 23:13
@caio-pizzol caio-pizzol added this pull request to the merge queue Apr 13, 2026
Merged via the queue into superdoc-dev:main with commit 47f92bc Apr 13, 2026
47 of 50 checks passed
@superdoc-bot
Copy link
Copy Markdown
Contributor

superdoc-bot Bot commented Apr 13, 2026

🎉 This PR is included in @superdoc-dev/react v1.2.0-next.8

The release is available on GitHub release

@superdoc-bot
Copy link
Copy Markdown
Contributor

superdoc-bot Bot commented Apr 13, 2026

🎉 This PR is included in vscode-ext v2.3.0-next.11

@superdoc-bot
Copy link
Copy Markdown
Contributor

superdoc-bot Bot commented Apr 13, 2026

🎉 This PR is included in template-builder v1.5.0-next.11

The release is available on GitHub release

@superdoc-bot
Copy link
Copy Markdown
Contributor

superdoc-bot Bot commented Apr 13, 2026

🎉 This PR is included in esign v2.3.0-next.11

The release is available on GitHub release

@superdoc-bot
Copy link
Copy Markdown
Contributor

superdoc-bot Bot commented Apr 13, 2026

🎉 This PR is included in superdoc v1.26.0-next.11

The release is available on GitHub release

@superdoc-bot
Copy link
Copy Markdown
Contributor

superdoc-bot Bot commented Apr 13, 2026

🎉 This PR is included in superdoc-cli v0.7.0-next.12

The release is available on GitHub release

@superdoc-bot
Copy link
Copy Markdown
Contributor

superdoc-bot Bot commented Apr 13, 2026

🎉 This PR is included in superdoc-sdk v1.6.0-next.9

@superdoc-bot
Copy link
Copy Markdown
Contributor

superdoc-bot Bot commented Apr 17, 2026

🎉 This PR is included in superdoc-cli v0.7.0

The release is available on GitHub release

@superdoc-bot
Copy link
Copy Markdown
Contributor

superdoc-bot Bot commented Apr 17, 2026

🎉 This PR is included in superdoc v1.27.0

The release is available on GitHub release

@superdoc-bot
Copy link
Copy Markdown
Contributor

superdoc-bot Bot commented Apr 21, 2026

🎉 This PR is included in @superdoc-dev/react v1.2.0

The release is available on GitHub release

@superdoc-bot
Copy link
Copy Markdown
Contributor

superdoc-bot Bot commented Apr 22, 2026

🎉 This PR is included in superdoc-sdk v1.6.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Math: implement m:phant phantom converter (community)

2 participants