fix: preserve bold and italic text inside DOCX hyperlinks

AF
9h ago
+124-9

Summary

DOCX emphasis extraction visits paragraph.runs, which excludes runs nested inside a Word hyperlink. Their visible text and external link target can survive partitioning while their explicit bold/italic formatting disappears from emphasized_text_contents and emphasized_text_tags. The same omission affects paragraphs in table cells.

Walk the paragraph's runs and hyperlinks in document order and inspect the hyperlink's own runs as well. Preserve the existing treatment of plain runs, whitespace-only runs and runs with both emphasis flags. Internal document links are included for formatting without turning them into external link metadata.

Validation

  • The 18 new public-API cases produce 13 failures and 5 passing controls on the original source.
  • The final source plus the existing DOCX partitioner suite reports 236 passed on Python 3.12.
  • Tests save and reopen real Word documents containing external/internal hyperlinks in body paragraphs and table cells. They cover bold, italic, combined formatting, order among ordinary and linked runs, unchanged visible text/link targets, and blank/unformatted controls.
  • Repository-configured Ruff check, format check and source-integrity checks pass.
  • Validation run, exact commands and JUnit artifacts.

Checklist

  • User-facing conventional-commit title.
  • Maintainer: please apply the bug category label.