markitdown
markitdown copied to clipboard
fix(docx): preserve underlined text
## 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 -qPYTHONPATH=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 -qpython -m py_compile packages/markitdown/src/markitdown/converters/_docx_converter.py packages/markitdown/src/markitdown/converters/_markdownify.py packages/markitdown/tests/test_module_misc.pygit diff --check
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 deselectedPYTHONPATH=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-> passedgit 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.