Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ describe('convertOmmlToMathml', () => {
expect(result).not.toBeNull();
expect(result!.namespaceURI).toBe(MATHML_NS);
expect(result!.localName).toBe('math');
expect(result!.getAttribute('displaystyle')).toBe('true');

// Should contain an <mi> for the identifier 'x'
const mi = result!.querySelector('mi');
Expand Down Expand Up @@ -94,6 +95,8 @@ describe('convertOmmlToMathml', () => {
const result = convertOmmlToMathml(omml, doc);
expect(result).not.toBeNull();
expect(result!.localName).toBe('math');
expect(result!.getAttribute('displaystyle')).toBe('true');
expect(result!.getAttribute('display')).toBe('block');
// The m:oMathParaPr should be skipped (it ends with 'Pr')
// The m:oMath child should produce content
expect(result!.textContent).toBe('y');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,11 @@ export function convertOmmlToMathml(ommlJson: unknown, doc: Document): Element |

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 👍 / 👎.


if (root.name === 'm:oMathPara') {
mathEl.setAttribute('display', 'block');
}

// For m:oMathPara, iterate over child m:oMath elements
// For m:oMath, process directly
Expand Down
Loading