Repository navigation
A non-breaking hyphen in a Word document is read as a hyphen, so the numbers on either side of it stay apart - #1031
Merged
Conversation
…numbers on either side of it stay apart Signed-off-by: dada-yan <BinjunYann@gmail.com>
WaylandYang
approved these changes
Oct 1, 2026
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.
Word writes a non-breaking hyphen as an element of its own,
<w:noBreakHyphen/>, not as a character inw:t. People type it with Ctrl+Shift+-, and converters write it to keep "2024-01-15" or "010-62345678" on one line.docx_xml_to_textreads the text ofw:tand the few elements that stand for a break or a tab. So the hyphen is dropped, and the numbers on either side of it run together.Problem
A Word file written by python-docx, with non-breaking hyphens in a date and in a phone number, reads like this on dev 2e7ba78:
The page shows 2024‑01‑15 and 010‑62345678.
It is the same loss #813 fixed for breaks in table cells and #1019 fixed for breaks on slides.
Change
docx_xml_to_textwrites<w:noBreakHyphen/>as a hyphen, in a paragraph and in a table cell, next to thew:tabcase. It writes the ASCII hyphen-minus rather than U+2011, so "2024-01-15" reads as the date it is.Verification
Run on macOS (arm64): Rust 1.98.1; the workspace suite against PostgreSQL 16 with pgvector 0.8.2, with Poppler 26.06.
a_non_breaking_hyphen_keeps_the_numbers_on_either_side_apart(crates/utopia-ingest/tests/docx_breaks.rs) covers a hyphen inside a run and one in a run of its own.合同于 2024-01-15 签订,电话 010-62345678。.| Sample | 2024-01-15 |.合同于 20240115 签订,电话 01062345678。.合同于 2024-01-15 签订,联系电话 010-62345678。.cargo test --locked -p utopia-ingest: 124 passed.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 --workspace: 1,345 passed, 0 failed, 6 ignored. That run had this change merged with the spreadsheet-number fix opened alongside it.