Conversation
A plain table cell took its text from python-docx's `_Cell.text`, which only reads runs and hyperlinks that are direct children of a paragraph. Runs nested in an inline content control, a simple field such as a mail-merge field, a smart tag or a tracked insertion were dropped, so a form filled in with content controls came out of a table with empty answers. Body paragraphs already read those wrappers through `_iter_paragraph_content`. Read each cell paragraph the same way. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: breken-ai <312387581+breken-ai@users.noreply.github.com>
Contributor
|
✅ DCO Check Passed Thanks @breken-ai, all your commits are properly signed off. 🎉 |
Contributor
Merge Protections🟢 Merge protection satisfied — ready to merge. Show 1 satisfied protection🟢 Enforce conventional commitMake sure that we follow https://www.conventionalcommits.org/en/v1.0.0/
|
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Member
|
Thanks @breken-ai for describing the issue and posting this PR! |
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.
A plain Word table cell loses any text held in an inline content control, a simple field, a smart tag or a tracked insertion.
_handle_tablestakes a plain cell's text from python-docx's_Cell.text. That only joins the runs and hyperlinks that are direct children of each paragraph (CT_P.textreadsw:r | w:hyperlink). Body paragraphs are read through_iter_paragraph_content, which already goes intow:sdt,w:fldSimple,w:smartTag,w:customXmlandw:ins, so the same content survives in a paragraph but is dropped in a table.This matters most for forms. Word forms are usually tables with the answers in content controls, and mail-merge output keeps its values in
MERGEFIELDfield results. A cell such asName | <content control: Jane Doe>comes out asName |with the answer gone:mainw:sdt)Jane DoeMERGEFIELDresult (w:fldSimple)ACME CorpParisw:ins)1200Change: a small
_get_cell_texthelper joins_get_paragraph_textfor each cell paragraph with\n, which is the same joining_Cell.textuses. The cell code uses it both for the equation check and for the cell text. Rich cells and everything else are unchanged.Tests:
test_table_cell_keeps_text_of_wrapped_runsbuilds a table with one wrapper per row. It fails onmain('' != 'Jane Doe') and passes with the fix.tests/test_backend_msword*.pyandtests/test_backend_legacy_msoffice.pypass (261 passed, 5 skipped) and no reference data changed.ruff check,ruff format --checkandty checkare clean.tyreports the same diagnostics as onmain.I found and fixed this with help from an AI coding assistant, and I reviewed the change and the test results myself.
Checklist: