Skip to content

fix(math): set displaystyle on MathML output for proper sizing (SD-2404)#2622

Open
caio-pizzol wants to merge 1 commit intomainfrom
caio/sd-2404-math-formulas-have-incorrect-spacing-compared-to-word
Open

fix(math): set displaystyle on MathML output for proper sizing (SD-2404)#2622
caio-pizzol wants to merge 1 commit intomainfrom
caio/sd-2404-math-formulas-have-incorrect-spacing-compared-to-word

Conversation

@caio-pizzol
Copy link
Copy Markdown
Contributor

Set displaystyle="true" on the <math> element so fractions and operators render at full size instead of cramped/script mode. Without this, MathML defaults to "inline" sizing where fractions shrink and operator spacing is tighter than Word.

Also sets display="block" when the source is m:oMathPara (display math paragraph) for proper centering.

  • Add displaystyle="true" to all generated <math> elements
  • Add display="block" for m:oMathPara roots
  • Update tests to verify both attributes

SD-2404

Set displaystyle="true" on the <math> element so fractions and operators
render at full size instead of cramped/script mode. Also set
display="block" when the root is m:oMathPara (display math).
@linear
Copy link
Copy Markdown

linear bot commented Mar 28, 2026

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: 215d945c78

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


const root = ommlJson as OmmlJsonNode;
const mathEl = doc.createElementNS(MATHML_NS, 'math');
mathEl.setAttribute('displaystyle', 'true');
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Recompute math metrics when enabling displaystyle

Setting displaystyle="true" on every generated <math> increases the rendered size of fractions and large operators, but the layout pipeline still reserves the old fixed estimates (MATH_DEFAULT_HEIGHT = 24 in pm-adapter/src/converters/math-constants.ts) and consumes run.width/run.height as-is during line measurement (measuring/dom/src/index.ts math-run path). In documents containing tall formulas (for example fractions/summations), the MathML can now exceed the reserved line box and overlap adjacent lines or wrap incorrectly; this regression appears specifically after this flag was introduced.

Useful? React with 👍 / 👎.

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.

1 participant