Skip to content

fix(docx): honor hidden n-ary limits - #2825

Open
林SO (Linxiushen) wants to merge 1 commit into
microsoft:mainfrom
Linxiushen:codex/docx-hidden-nary-limits
Open

林SO (Linxiushen) wants to merge 1 commit into
microsoft:mainfrom
Linxiushen:codex/docx-hidden-nary-limits

Conversation

@Linxiushen

Copy link
Copy Markdown

DOCX n-ary equations can retain nonempty lower/upper limits while hiding them with m:subHide or m:supHide. do_nary currently emits both stored limits regardless of those properties, so the Markdown consumed by an LLM includes mathematical content that the document marks hidden.

Filter the corresponding child before converting it. A present flag without m:val, or with 1/true/on, hides that bound; absent and disabled flags preserve it, following the lower and upper property definitions. The tests retain nonempty hidden values and exercise the flags independently, both together, and through public MarkItDown.convert_stream() conversion of in-memory DOCX files.

Validation on Windows, Python 3.12, against base 7482c092d9c0074a89803c9fdb63a969e7fe17fc:

  • New regressions on the unmodified base: 11 failed, 7 passed, including all three public DOCX cases failing because hidden content remained visible.
  • python -m pytest tests/test_docx_nary_visibility.py -q: 18 passed.
  • python -m pytest tests/test_docx.py tests/test_html.py -q --basetemp <isolated-directory>: 134 passed, 1 skipped.
  • Eight existing DOCX module/CLI vectors: 8 passed (file-type detection, local/stream/file/data conversion, CLI stdout/file output).
  • pre-commit run --all-files and git diff --cached --check: passed.

These are local converter correctness tests. Public conversion uses the bundled Magika file-type classifier; no LLM/provider, GPU, training or production evaluation was run. The complete Hatch matrix was not run locally.

Developed and tested with OpenAI Codex assistance.

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