Skip to content

fix(docx): keep non-breaking hyphens - #179

Open
breken-ai wants to merge 1 commit into
firecrawl:mainfrom
breken-ai:fix/docx-no-break-hyphen
Open

breken-ai wants to merge 1 commit into
firecrawl:mainfrom
breken-ai:fix/docx-no-break-hyphen

Conversation

@breken-ai

@breken-ai breken-ai commented Sep 26, 2026 •

Copy link
Copy Markdown

What

The DOCX run walker now turns w:noBreakHyphen into 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:

<w:r><w:t>Call 555</w:t><w:noBreakHyphen/><w:t>0123 by e</w:t><w:noBreakHyphen/><w:t>mail</w:t></w:r>
  • before: Call 5550123 by email
  • after: Call 555-0123 by e-mail

The other readers already handle this character. The .doc reader maps 0x1E to - and the RTF reader maps \_ to -. So one document saved as .doc or .rtf kept its phone numbers, part numbers and hyphenated words, but saved as .docx it lost them.

Testing

  • New test non_breaking_hyphen_renders_as_a_hyphen in src/formats/docx/mod.rs. It fails on main (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 --check and cargo clippy -p anydoc --all-targets --all-features -- -D warnings are 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").

  • Emits a - with the run's style, matching how the .doc and RTF readers already handle the same character.
  • Adds a regression test that fails on main and passes with this change.

Written for commit 21eecd9. Summary will update on new commits.

Review in cubic

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>

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 2 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

Re-trigger cubic

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant