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

AS
11d ago
+280-2

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 firecrawl/anydoc#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.