Conversation
Word writes a non-breaking hyphen as a w:noBreakHyphen run element, which the run walker ignored, so "555-0123" became "5550123" and "e-mail" became "email". The .doc and RTF readers already emit a hyphen for the same character. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
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.
What
The DOCX run walker now turns
w:noBreakHypheninto a-. It keeps the run's style.Why
Word stores a non-breaking hyphen (Ctrl+Shift+-) as its own run element, not as a character inside
w:t. The walker's match had no arm for it, so the hyphen disappeared and the text on either side ran together:Call 5550123 by emailCall 555-0123 by e-mailThe other readers already handle this character. The
.docreader maps 0x1E to-and the RTF reader maps\_to-. So one document saved as.docor.rtfkept its phone numbers, part numbers and hyphenated words, but saved as.docxit lost them.Testing
non_breaking_hyphen_renders_as_a_hypheninsrc/formats/docx/mod.rs. It fails onmain(left: "Call 5550123 by email\n") and passes with the fix.cargo test --locked: 287 unit, 1 robustness and 9 snapshot tests pass, 1 ignored, as on main.cargo fmt --all --checkandcargo clippy -p anydoc --all-targets --all-features -- -D warningsare clean.This PR was prepared with AI assistance (Claude Code) and reviewed before submission.
🤖 Generated with Claude Code
Summary by cubic
Fixes the DOCX run walker so non-breaking hyphens render as
-instead of vanishing, which previously joined text on either side ("5550123" instead of "555-0123").-with the run's style, matching how the.docand RTF readers already handle the same character.mainand passes with this change.Written for commit 21eecd9. Summary will update on new commits.