Skip to content

feat(math): implement m:box and m:borderBox converters#2750

Open
Abdeltoto wants to merge 3 commits intosuperdoc-dev:mainfrom
Abdeltoto:feat/math-box-border-box-converter
Open

feat(math): implement m:box and m:borderBox converters#2750
Abdeltoto wants to merge 3 commits intosuperdoc-dev:mainfrom
Abdeltoto:feat/math-box-border-box-converter

Conversation

@Abdeltoto
Copy link
Copy Markdown

Closes #2605

Summary

  • Implements m:box (invisible grouping container) as MathML <mrow>
  • Implements m:borderBox (bordered box) as MathML <menclose> with configurable notations
  • Supports all hide flags (m:hideTop, m:hideBot, m:hideLeft, m:hideRight) and strike flags (m:strikeH, m:strikeV, m:strikeBLTR, m:strikeTLBR)
  • Registers both converters in MATH_OBJECT_REGISTRY
  • Adds 5 unit tests covering default box, empty box, default border box, hidden sides, and strike notations

Spec reference

ECMA-376 Sections 22.1.2.13 (box) and 22.1.2.11 (borderBox)

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: 6157dcc02b

ℹ️ 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".

const base = elements.find((e) => e.name === 'm:e');

const isOn = (el?: { attributes?: Record<string, string> }) =>
el && (el.attributes?.['m:val'] === '1' || el.attributes?.['m:val'] === 'on' || !el.attributes);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Parse ST_OnOff "true" values in borderBox flags

isOn only treats m:val="1" and m:val="on" as enabled, so valid ST_OnOff values like m:val="true" are interpreted as false. In those documents, hide/strike flags on m:borderBoxPr are silently ignored and the rendered MathML notation is wrong (e.g., borders shown when they should be hidden).

Useful? React with 👍 / 👎.

Comment on lines +84 to +86
if (notations.length > 0) {
menclose.setAttribute('notation', notations.join(' '));
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Set explicit notation when borderBox hides all sides

When all four m:hide* flags are on and no strike notation is added, notations stays empty and the code omits the notation attribute entirely. A <menclose> without notation uses the MathML default (longdiv), so this path renders an unintended enclosure instead of a fully hidden border box.

Useful? React with 👍 / 👎.

@caio-pizzol caio-pizzol self-assigned this Apr 9, 2026
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:box and m:borderBox converters (community)

2 participants