fix: preserve underline formatting in DOCX to Markdown conversion#1696
Open
nitinbhatia-dev wants to merge 1 commit intomicrosoft:mainfrom
Open
fix: preserve underline formatting in DOCX to Markdown conversion#1696nitinbhatia-dev wants to merge 1 commit intomicrosoft:mainfrom
nitinbhatia-dev wants to merge 1 commit intomicrosoft:mainfrom
Conversation
Underlined text in .docx files was silently dropped during conversion because Mammoth's default style map does not emit <u> tags, and _CustomMarkdownify had no handler for them. - Add `u => u` as the default Mammoth style_map in DocxConverter so underlined runs are emitted as <u> HTML elements. User-supplied style_map is appended and still takes precedence. - Add `convert_u` to _CustomMarkdownify to render <u> elements as `<u>text</u>` in the Markdown output (HTML inline is the only way to express underline in CommonMark). Fixes microsoft#35 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Author
|
@microsoft-github-policy-service agree |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #35
Underlined text in
.docxfiles was silently dropped during conversion. Two things were missing:<u>HTML tags for underlined runs (it requires an explicitstyle_maprule)_CustomMarkdownifyhad noconvert_uhandler, so even if<u>tags arrived they would have been strippedChanges
_docx_converter.py: Setu => uas the default Mammothstyle_mapso underlined runs are emitted as<u>elements. Any user-suppliedstyle_mapis appended and takes precedence._markdownify.py: Addconvert_uto_CustomMarkdownifythat renders<u>text</u>inline HTML — the only way to express underline in CommonMark.Test plan
.docxfile containing underlined text and verify the output contains<u>...</u>wrapping the underlined spans**bold**,*italic*)style_mapkwarg still works and takes precedence over the defaulthatch test🤖 Generated with Claude Code