Skip to content

Isolate per-equation DOCX math failures and fall back for unknown limit functions - #2795

Open
scks1 wants to merge 1 commit into
microsoft:mainfrom
scks1:fix-omml-missing-properties
Open

scks1 wants to merge 1 commit into
microsoft:mainfrom
scks1:fix-omml-missing-properties

Conversation

@scks1

@scks1 scks1 commented Oct 30, 2026 •

Copy link
Copy Markdown

Summary

Two defects in DOCX math conversion, both reproduced on 0.1.9:

  1. One bad equation aborted all math in the file. _pre_process_math
    replaced equations in a loop with no per-equation guard, so a single
    failing equation discarded every other equation's conversion in the
    same document part.

  2. Unknown limit functions raised NotImplementedError.
    do_limlow raised for any limit function name not in its hardcoded
    table, even though do_fname already falls back to
    \operatorname{...} for unknown function names.

Changes

  • pre_process.py: _replace_equations guards each equation
    replacement; a failing equation keeps its original OMML tag (inline and
    inside oMathPara), and the _pre_process_math loops guard each call
    so one tag cannot abort the remaining equations.
  • omml.py: do_limlow stops raising NotImplementedError for an
    unknown limit function and falls back to
    \operatorname{<name>}_{<lim>}, following the \operatorname
    fallback do_fname already uses for unknown function names.

Scope note

This PR originally also fixed KeyError raised by five OMML handlers
(do_acc, do_bar, do_d, do_f, do_groupchr) when a properties
element (accPr, barPr, dPr, fPr, groupChrPr) is absent. Those
fixes and their tests have been withdrawn: #2445 already covers exactly
that defect, with tests of equal coverage. What remains here — the
per-equation isolation and the do_limlow fallback — is not covered by
#2445, and the isolation is also distinct from #2714, which drops a
failing block equation where this PR preserves its original OMML tag.

Tests

Three new tests in tests/test_docx.py, each failing on 0.1.9 and
passing with this change: one for the limLow fallback and two for
per-equation isolation. The isolation tests use a func element with
no fName, which still raises after these fixes, so they exercise the
guard itself.

Full run of tests/test_docx.py on the narrowed tree: 104 passed.

Disclosure: this contribution was prepared by Árbol, an AI assistant working under the direction of the account holder (scks1), who set the acceptance criteria and verified the results before submission.

@scks1
scks1 force-pushed the fix-omml-missing-properties branch from 0a21061 to 1348426 Compare October 30, 2026 19:25
@scks1 scks1 changed the title Fix OMML KeyError on missing properties elements and isolate per-equation math failures Isolate per-equation DOCX math failures and fall back for unknown limit functions Oct 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant