Repository navigation
fix(pptx): emit a blank line between PowerPoint paragraphs - #2759
Open
PerryLink (PerryLink) wants to merge 1 commit into
Open
PerryLink (PerryLink) wants to merge 1 commit into
PerryLink (PerryLink) wants to merge 1 commit into
Conversation
python-pptx joins the paragraphs of a text frame with a single newline, and the converter wrote that string as-is. A single newline is a CommonMark soft break, so separate bullet-less paragraphs rendered as one continuous line. Join the paragraphs with a blank line instead, matching how the DOCX and HTML converters emit separate blocks. Trailing spaces would not survive the normalizer, which rstrips every output line.
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.
PptxConverterwrites a body text frame withshape.text, which python-pptx joins with a single\nbetween paragraphs. A single newline is a CommonMark soft break, so separate paragraphs render as one continuous line:Actual:
which renders as one paragraph — "…year over year. Costs stayed flat. Outlook is positive."
Expected (separate paragraphs, like the DOCX and HTML converters produce):
The trailing-double-space alternative (requested in #1331) cannot work here:
_markitdown.pyrstrips every output line before joining, so the spaces are gone by the time the Markdown is returned. A blank line is preserved (the normalizer only collapses runs of three or more newlines).Change
Join the paragraphs of a body text frame with a blank line instead of writing
shape.textas-is. Title handling is unchanged.Test
packages/markitdown/tests/test_pptx.py::test_body_paragraphs_are_separate_markdown_paragraphsbuilds the deck above, asserts the blank-line separation, and asserts that. Costs stayed flat.does not appear. It fails onmainand passes with the change;test_pptx.pyis 50 passed.Related: #1331 (hard breaks in PPTX), #1911 and #2513 (hyperlinks/lists and soft line breaks inside a paragraph) are complementary and still join paragraphs with a single newline.