Skip to content

fix(docx): strip baked-in numbering prefix from ordered list items - #217

Open
Aschenbath wants to merge 2 commits into
firecrawl:mainfrom
Aschenbath:fix/docx-duplicate-list-prefix
Open

Aschenbath wants to merge 2 commits into
firecrawl:mainfrom
Aschenbath:fix/docx-duplicate-list-prefix

Conversation

@Aschenbath

@Aschenbath Aschenbath commented Nov 5, 2026 •

Copy link
Copy Markdown

Summary

Programmatic DOCX writers often emit both numPr and the rendered prefix in the text, so an item arrived as "1. first item" while the renderer adds its own "1. " in front. Ordered list items now drop a leading prefix that matches their own marker (composite label when present, otherwise the marker kind's text for the number); bullets and non-matching leading numbers are untouched.

Tests

  • cargo test --workspace: 288 lib tests passed, all other suites passed.
  • cargo fmt --all --check and cargo clippy --workspace --all-targets --all-features (-D warnings): clean.
  • End-to-end check with a minimal docx (numPr decimal + baked "1."/"2." prefixes): before this change it converted to "1. 1. first item"; after, to "1. first item".

Closes #81


Summary by cubic

Fixes duplicate numbering on DOCX ordered list items that carry both numPr and a baked-in prefix, so "1. first item" renders as "1. first item" instead of "1. 1. first item".

  • Strips only the prefix matching the item's own marker (composite label when present, otherwise the marker kind's text), crossing styled runs, hyperlinks, and anchors, while leaving bullets and mismatched leading numbers untouched.
  • Requires whitespace or end-of-run after the marker, so values like "1.5 volts" are not affected.

Written for commit c53935e. Summary will update on new commits.

View guided diff

@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.

All reported issues were addressed across 1 file

Reply with feedback, questions, or to request a fix.

View guided diff | Re-trigger cubic

Comment thread src/formats/docx/content.rs Resolved
Comment thread src/formats/docx/content.rs Resolved
@Aschenbath

Copy link
Copy Markdown
Author

Both P2 review comments were valid and are fixed in c53935e. Stripping now stops unless the first block is a paragraph, and walks text recursively through hyperlinks and across adjacent runs, preserving styles and anchors and checking the separator across spans.

Verification:

  • cargo test --locked -p anydoc formats::docx: 23 passed; before the fix, the added regressions produced 6 failures.
  • cargo test --locked -p anydoc: 295 unit tests and 12 integration tests passed; 1 existing sample sweep ignored because it requires local gitignored fixtures.
  • cargo fmt --all --check: passed.
  • cargo clippy --locked -p anydoc --all-targets --all-features -- -D warnings: passed.

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.

Bug: duplicate numbering prefix in DOCX ordered lists from programmatically generated files

1 participant