markitdown icon indicating copy to clipboard operation
markitdown copied to clipboard

fix(docx): preserve underlined text

Open he-yufeng opened this issue 6 months ago • 1 comments

## Summary

Fixes #35.

DOCX underlined runs were lost because Mammoth only emits underline markup when a style map for u is present, and the HTML-to-Markdown pass did not preserve <u> tags. This adds the missing default style map entry for DOCX conversion and keeps underline markup in the Markdown output.

To verify

  • PYTHONPATH=packages/markitdown/src python -m pytest packages/markitdown/tests/test_module_misc.py -k docx -q
  • PYTHONPATH=packages/markitdown/src python -m pytest packages/markitdown/tests/test_module_misc.py::test_docx_underlined_text_is_preserved packages/markitdown/tests/test_module_misc.py::test_docx_comments -q
  • python -m py_compile packages/markitdown/src/markitdown/converters/_docx_converter.py packages/markitdown/src/markitdown/converters/_markdownify.py packages/markitdown/tests/test_module_misc.py
  • git diff --check

he-yufeng avatar May 31 '26 02:05 he-yufeng

Local re-check after cleaning up my environment:

  • PYTHONPATH=packages/markitdown/src python -m pytest packages/markitdown/tests/test_module_misc.py -q -k "underline or docx" -> 3 passed, 12 deselected
  • PYTHONPATH=packages/markitdown/src python -m py_compile packages/markitdown/src/markitdown/converters/_docx_converter.py packages/markitdown/src/markitdown/converters/_markdownify.py packages/markitdown/tests/test_module_misc.py -> passed
  • git diff --check origin/main...HEAD -> passed

The explicit PYTHONPATH is intentional here: my global Python had an editable markitdown install pointing at another local clone, so the first local run did not exercise this branch.

he-yufeng avatar May 31 '26 09:05 he-yufeng