fix(math): set displaystyle on MathML output for proper sizing (SD-2404)#2622
fix(math): set displaystyle on MathML output for proper sizing (SD-2404)#2622caio-pizzol wants to merge 1 commit intomainfrom
Conversation
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).
There was a problem hiding this comment.
💡 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'); |
There was a problem hiding this comment.
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 👍 / 👎.
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 ism:oMathPara(display math paragraph) for proper centering.displaystyle="true"to all generated<math>elementsdisplay="block"form:oMathPararootsSD-2404