Repository navigation
fix(doc2md): read PPTX strikethrough from a:rPr, not Font.strike - #18399
Open
MohammadHijjawi97 wants to merge 1 commit into
Open
MohammadHijjawi97 wants to merge 1 commit into
MohammadHijjawi97 wants to merge 1 commit into
Conversation
python-pptx's Font has no `strike` attribute, so converting any PPTX that contains a table with text failed with "RuntimeError: Failed to convert ...: 'Font' object has no attribute 'strike'". Table cells now use _pptx_run_strike() like text frames do. _pptx_run_strike() itself looked up a namespace-qualified "strike" attribute, but DrawingML writes it unqualified on <a:rPr> (as with "baseline"), so strikethrough in text frames was never rendered.
|
|
This branch has not been deployed
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.
Description
doc2md_convertfails on any.pptxthat contains a table with text:The table-cell code in
paddleocr/_doc2md/converters/pptx.pyreadsrun.font.strike, but python-pptx'sFonthas no strikethrough property (python-pptx 1.0.2 exposes only bold, color, fill, italic, language_id, name, size and underline).The helper meant for this,
_pptx_run_strike(), had a second bug: it looked up a namespace-qualifiedstrikeattribute, but DrawingML writesstrikeunqualified on<a:rPr>(the same asbaseline, which_pptx_run_script()already reads correctly). So strikethrough in text boxes was never rendered either.Changes:
_pptx_run_strike()reads the unqualifiedstrikeattribute (sngStrike/dblStrike)._pptx_run_strike()instead ofrun.font.strike.tests/doc2md/test_pptx_converter.pybuilds small decks with python-pptx intmp_pathand checks a table (with a struck cell) and a text box with struck and plain runs.Repro (deck: one 2x2 table, one text box with a struck run):
Before:
After:
Testing
pytest tests/doc2md tests/utils: 4 passed. Both new tests fail without the fix.