Repository navigation
Conversation
Text inside a w:smartTag element (a legacy inline wrapper Word emits for values filled from an external source) was silently dropped from Paragraph.text and _Cell.text. Add a CT_SmartTag element class whose text property joins its w:r children (including nested smart tags), and include w:smartTag children in CT_P.text so the wrapped runs are reported along with regular runs and hyperlink runs. Fixes python-openxml#1390
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
Text inside a
w:smartTagelement (a legacy inline wrapper Word emits for values filled from an external source, e.g. a database or XML file) was silently dropped fromParagraph.textand_Cell.text. In the example document attached to #1390, the string "0.5m" inside a table cell is wrapped in aw:smartTagand does not appear in the text reported for that cell.This PR adds a
CT_SmartTagelement class whosetextproperty joins the text of itsw:rchildren (including runs inside nested smart tags), and includesw:smartTagchildren inCT_P.textso the wrapped runs are reported along with regular runs and hyperlink runs.Verification
Fixes the issue in the document attached to #1390:
Before:
After:
Full test suite passes (1606 passed; the 9 errors in
tests/opc/test_phys_pkg.pyalso occur on unmodifiedmasterin this environment and are unrelated to this change).ruff checkandruff format --checkpass on all changed files.Disclosure
Prepared with AI assistance (Claude Code); the change was verified with the tests listed above.