Repository navigation
fix: read content controls in DOCXToDocument - #13164
Open
LindseyZ1205 wants to merge 2 commits into
Open
LindseyZ1205 wants to merge 2 commits into
LindseyZ1205 wants to merge 2 commits into
Conversation
_extract_elements only handled the direct w:p and w:tbl children of the document body. Block-level content controls (w:sdt) keep their paragraphs and tables in w:sdtContent, so their content was dropped without any warning. Word uses them for cover pages, tables of contents and template fields. Expand content controls, including nested ones, into the elements they hold before the existing paragraph and table handling. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
LindseyZ1205
requested review from
julian-risch
and removed request for
a team
October 7, 2026 14:24
Contributor
|
@LindseyZ1205 is attempting to deploy a commit to the deepset Team on Vercel. A member of the Team first needs to authorize it. |
Contributor
Coverage reportClick to see where and how coverage changed
This report was generated by python-coverage-comment-action |
||||||||||||||||||||||||
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.
Related Issues
Proposed Changes:
DOCXToDocument._extract_elementsonly handled the directw:pandw:tblchildren of the document body. Block-level content controls (w:sdt) keep their paragraphs and tables inw:sdtContent, so their content was dropped without any warning. Word uses them for cover pages, tables of contents and template fields.A new
_block_elementshelper lists the body's children and replaces each content control with the elements in itsw:sdtContent, recursively, so nested content controls are expanded too._extract_elementsiterates this list, so paragraphs (including text boxes, page breaks and links) and tables inside a content control go through the existing handling, in reading order.How did you test it?
test_run_reads_text_inside_a_content_control(paragraphs, including a nested content control, in reading order) andtest_run_reads_a_table_inside_a_content_control. Both fail onmainand pass with this change._docx_with_text_boxto_docx_with_block, since it now also builds the content-control documents. The text box tests are unchanged.hatch run test:unit(full unit suite),hatch run fmt,hatch run test:types, and pre-commit on the changed files.Notes for the reviewer
Word also stores the table of contents in a block-level content control, so its entries now appear in the converted text, as they do in the document. If you'd rather skip the table of contents (its
w:sdtPrhas aw:docPartGalleryof "Table of Contents"), I can add that.This PR was generated with an AI assistant (Claude Code), including finding the bug. I have reviewed the changes and run the relevant tests locally.
Checklist
🤖 Generated with Claude Code