{{ message }}
Repository navigation
A text box in a Word document is read once, not once for each way Word draws it - #1020
Merged
Merged
Conversation
Maya-Kid
force-pushed
the
fix/docx-text-box-read-once
branch
from
September 30, 2026 14:34
0e2cec1 to
53069f0
Compare
…d draws it Signed-off-by: dada-yan <BinjunYann@gmail.com>
Maya-Kid
force-pushed
the
fix/docx-text-box-read-once
branch
from
September 30, 2026 20:36
53069f0 to
98d0126
Compare
WaylandYang
approved these changes
Oct 1, 2026
WaylandYang
left a comment
Contributor
There was a problem hiding this comment.
Approving. Thanks @Maya-Kid. Reviewed at 98d0126: the markup-compatibility rule is followed exactly (first Choice read, later Choices and the Fallback skipped by depth), a document without mc:AlternateContent reads as before, and the table-cell case is covered. It touches the same function as #1018; I will land them one after the other with a branch update in between.
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.

Since Word 2010, a text box is written twice inside
mc:AlternateContent:mc:Choicewith the DrawingML shape (wps:txbx);mc:Fallbackwith a VML shape (v:textbox) for older versions of Word.Both carry the box's paragraphs.
docx_xml_to_textreads everyw:tit meets, so the text of every text box comes out twice.Problem
On dev, a paragraph with a text box reading "Quarterly revenue rose 12%" comes out as:
The same text box in a table cell gives
| Revenue | Up 12% Up 12% |.Reports, forms and cover pages use text boxes for titles, call-outs and side notes.
Change
docx_xml_to_textfollows the markup-compatibility rule. In eachmc:AlternateContentit reads the firstmc:Choiceand skips the later Choices and themc:Fallback. It counts the depth of a skipped subtree to know where it ends.A document without
mc:AlternateContentreads exactly as before.Verification
Run on macOS (arm64): Rust 1.98.1; the workspace suite against PostgreSQL 16 with pgvector 0.8.2, with Poppler 26.06.
crates/utopia-ingest/tests/docx_text_boxes.rsbuilds the text box the way Word writes it: the wps shape in the Choice, the VML shape in the Fallback. It also builds a variant with a second Choice.a_text_box_is_read_once: the sentence appears once, and the text before and after the box is intact.a_text_box_in_a_table_cell_is_read_once:| Revenue | Up 12% |.cargo test --locked -p utopia-ingest: 96 unit tests and every integration test pass.cargo fmt --all --checkandcargo clippy --locked --workspace --all-targets -- -D warningsare clean.UTOPIA_TEST_REQUIRE_DB=1 UTOPIA_TEST_REQUIRE_PDFTOTEXT=1 cargo test --locked --workspacepasses: 1,331 passed, 0 failed, 6 ignored.utopia-ingestfixes opened alongside it: spreadsheet dates, slide line breaks and Word headings.Notes