Repository navigation
fix: preserve strikethrough semantics for <strike>, line-through CSS, and w:dstrike - #2356
Conversation
|
I reproduced the DOCX path while investigating #2340. One edge is worth locking down before merge: A focused end-to-end test can clone the existing assert "~~double strike marker~~" in result.text_content
assert "disabled double strike marker" in result.text_content
assert "~~disabled double strike marker~~" not in result.text_contentThe HTML portions also overlap #2342; the distinct value in this PR is the |
…ssing Normalize <w:dstrike> to <strike> during DOCX pre-processing so double strikethrough runs keep their strikethrough semantics in the output. Co-Authored-By: Claude Opus 5 <[email protected]>
5e52b6f to
b0a484d
Compare
There was a problem hiding this comment.
🟡 Changes recommended
CSS handling is missing, and DOCX normalization has incomplete coverage and lacks regression tests.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Review details
Suppressed comments (3)
packages/markitdown/src/markitdown/converter_utils/docx/pre_process.py:113
- This only handles parts routed through
_pre_process_math(document.xml, footnotes, and endnotes). Double-strike can also be inherited fromstyles.xml, which is routed through_pre_process_styles, and can occur in extractedcomments.xml; those occurrences remain unsupported by Mammoth and are still emitted as plain text. Apply the normalization to every DOCX XML part from which Mammoth extracts run formatting.
for tag in soup.find_all("dstrike"):
tag.name = "strike"
packages/markitdown/src/markitdown/converter_utils/docx/pre_process.py:113
- There is no DOCX regression test exercising this new path through final Markdown conversion, so a namespace/serialization or routing regression could silently leave
w:dstrikeflattened. Add a generated DOCX case containingw:dstrikeand assert that conversion emits~~...~~; include styled double-strike to cover the separatestyles.xmlpath.
for tag in soup.find_all("dstrike"):
tag.name = "strike"
packages/markitdown/src/markitdown/converter_utils/docx/pre_process.py:111
- The PR description says inline CSS
line-throughis normalized, but the HTML conversion path contains notext-decoration/text-decoration-linehandling, and the added strikethrough test only covers HTML tags. The issue's CSS reproductions will therefore still produce plain text. Implement the promised HTML preprocessing and cover both CSS property forms.
# Normalize dstrike to strike to preserve strikethrough semantics
- Files reviewed: 1/1 changed files
- Comments generated: 1
- Review effort level: Balanced
There was a problem hiding this comment.
🟡 Changes recommended
The preprocessing dispatch regresses style repair, and the advertised CSS handling is absent.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Review details
Suppressed comments (2)
packages/markitdown/src/markitdown/converter_utils/docx/pre_process.py:196
- This hard-codes the math preprocessor and ignores the function selected by
pre_process_enable_files. Consequently,word/styles.xmlno longer runs_pre_process_styles; malformed-but-valid styles missingw:typeagain reach Mammoth and can make conversion fail (covered bytests/test_module_vectors.py:204). Invoke the mapped preprocessor so style repair remains intact.
updated_content = _pre_process_math(updated_content)
packages/markitdown/src/markitdown/converter_utils/docx/pre_process.py:192
- The PR description says inline CSS
text-decoration: line-throughis normalized, but the source tree contains notext-decorationorline-throughhandling. CSS-only strikethrough therefore remains plain text, leaving the advertised fix and issue #2340 incomplete. Add preprocessing (includingtext-decoration-line) and regression tests, or narrow the PR's stated scope.
updated_content = _pre_process_strike(updated_content)
- Files reviewed: 1/1 changed files
- Comments generated: 1
- Review effort level: Balanced
| for tag in soup.find_all("dstrike"): | ||
| tag.name = "strike" |
There was a problem hiding this comment.
🟡 Changes recommended
CSS strikethrough remains unsupported, and the DOCX behavior lacks regression coverage.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Review details
Suppressed comments (1)
packages/markitdown/src/markitdown/converter_utils/docx/pre_process.py:116
- There is no regression test for the new DOCX behavior: no test input contains
w:dstrike, so the namespace-preserving rename, style handling, and final Markdown output are unverified. Add a minimal DOCX or in-memory package test that confirms double-struck text produces~~text~~(and ideally coversw:val="0").
for tag in soup.find_all("dstrike"):
tag.name = "strike"
- Files reviewed: 1/1 changed files
- Comments generated: 2
- Review effort level: Balanced
| "word/footnotes.xml": _pre_process_math, | ||
| "word/endnotes.xml": _pre_process_math, | ||
| "word/styles.xml": _pre_process_styles, | ||
| "word/document.xml": (_pre_process_strike, _pre_process_math), |
| soup = BeautifulSoup(content.decode(), features="xml") | ||
| for tag in soup.find_all("dstrike"): | ||
| tag.name = "strike" |
Fixes #2340.
This preserves strikethrough semantics that were previously lost during extraction:
convert_striketo_CustomMarkdownifyfor obsolete<strike>tags.text-decoration: line-throughto<del>in HTML preprocessing.<w:dstrike>(double strikethrough) to<w:strike>in DOCX preprocessing so Mammoth handles it correctly.