Repository navigation
Conversation
Square brackets came out as parentheses, and a delimiter with several
items, such as f(a, b), kept only the first. Delimiters now use their
begChr/endChr/sepChr (OMML defaults to "(", ")" and "|"), and an
already bracketed base is not wrapped again: (a+b)^2, not ((a+b))^2.
Also formats the new tests with the repository's ruff and drops an
unrelated .gitignore entry.
2 tasks done
8 of 21 tasks
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Native Word equations (OMML) lost their structure during DOCX text extraction:
1/2 + 1/3came out as12+13,2^3as23andsqrt(9)as9, because the DOCX walkers collected only the leaf text runs.This change linearizes OMML in the shared DOCX extraction, so Immersive Reading, the reading agent and chat attachments all receive an unambiguous form:
a/b, superscripts →a^b, subscripts →a_bsqrt(x), n-th roots →root(n, x)[0, 1],(a,b)(a+b)/(c-d),(a+b)^2m:oMathstays in place within its paragraph; a displaym:oMathParabecomes its own linedeeptutor/utils/document_images.pyaddslinearize_ommland uses it inextract_docx_rich. The pure-OOXML fallback indeeptutor/utils/document_extractor.pyreuses the same walker, so equations survive when python-docx is unavailable. No new dependency.With the issue's
math-formula-native-only.docx, all three paths (extract_materialfor Immersive Reading,extract_text_from_bytesfor attachments, and the OOXML fallback) now give:Paragraph order, table text and embedded-image markers are unchanged.
Not covered: n-ary operators (∑, ∫), functions (
sin x) and matrices still fall back to their leaf text, as before. Happy to add a notation for them if you have a preference.Related Issues
Module(s) Affected
agentsapiconfigcoreknowledgeloggingservicestoolsutilsweb(Frontend)docs(Documentation)scriptstests...Checklist
dev(notmain— see the base-branch selector above).pre-commit run --all-filesand fixed any issues. (Ran the Python hooks on the changed files instead:ruff checkandruff format --checkwith the pinned ruff 0.16.0, andscripts/check_repo_hygiene.py. All pass.)Additional Notes
On
devwith this change,pytest tests/utils tests/reading: 620 passed, 6 skipped (605 passed without it). The one failure,tests/reading/test_extension_router.py::test_async_reading_action_can_be_retried_after_timeout[True], fails the same way ondevwithout this change (seen on Windows).