Skip to content

fix(pptx): read a line break as a newline instead of a vertical tab - #4571

Merged
cragwolfe merged 2 commits into
Unstructured-IO:mainfrom
L4XB:fix/pptx-line-breaks
Oct 22, 2026
Merged

cragwolfe merged 2 commits into
Unstructured-IO:mainfrom
L4XB:fix/pptx-line-breaks

Conversation

@L4XB

@L4XB L4XB commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Summary

python-pptx returns a line break inside a paragraph (Shift+Enter in PowerPoint, <a:br/> in the XML) as a vertical tab (\v). partition_pptx() passes paragraph.text through unchanged, so that control character ends up in the element text of titles, text boxes and slide notes:

source element text on main with this PR
title Quarterly ⏎ results 'Quarterly\x0bresults' 'Quarterly\nresults'
text box First line ⏎ second line 'First line\x0bsecond line' 'First line\nsecond line'
slide notes Note one ⏎ note two 'Note one\x0bnote two' 'Note one\nnote two'

Table cells were already unaffected, because their text goes through the HTML table normalization.

Change

A small _break_lines() helper replaces \v with \n. It is used for paragraph text in _iter_shape_elements() and _iter_title_shape_element(), and for the slide-notes text. A newline is how the DOCX partitioner already gives a w:br line break, since python-docx reads it as \n.

Testing

  • New test_partition_pptx_reads_line_breaks_as_newlines builds a slide with a line break in the title, in a text box and in the notes. It fails on main.
  • The other 73 tests in test_pptx.py pass. The .ppt tests need LibreOffice, which isn't installed here.
  • ruff 0.15.10 check and format are clean, and scripts/version-sync.sh -c passes with 0.27.34-dev1.

View guided diff

@cragwolfe cragwolfe left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 7c8087d34b0d4f31207f8fc2b60934276fcb1951 with GPT Pro. No actionable production defects found. Line-break normalization is consistent across titles, body paragraphs and notes; the regression test covers serialized PPTX input and exact text ordering.

This is a code-review approval. Required test/lint CI is not verified: the Actions runs require approval, and the two successful Socket checks do not establish test success. No tests were run locally.

(authored by codex)

@cragwolfe
cragwolfe merged commit 33779f9 into Unstructured-IO:main Oct 22, 2026
52 checks passed
@CyMule CyMule mentioned this pull request Oct 22, 2026
linhongyu510 pushed a commit to linhongyu510/unstructured that referenced this pull request Oct 22, 2026
Drops the `-dev6` suffix so 0.27.34 can be tagged and published. There
are no code changes.

Since 0.27.33, this release contains:

- Free decode buffers sooner when restoring original elements (Unstructured-IO#4524)
- Free image buffers sooner during figure extraction (Unstructured-IO#4523)
- Honor `encoding=` in `partition_json` and `partition_ndjson` (Unstructured-IO#4483)
- Read a PowerPoint line break as a newline (Unstructured-IO#4571)
- Drop the empty entry of an email address group (Unstructured-IO#4576)
- Read CSV and TSV cells as the file holds them (Unstructured-IO#4574)
- Classify text as an email address only when all of it is one (Unstructured-IO#4577)

After merge, create the `0.27.34` GitHub release from the merge commit.
That publishes to PyPI.

<!-- This is an auto-generated description by cubic. -->
<a
href="https://cubic.dev/pr/Unstructured-IO/unstructured/pull/4582?utm_source=github"
target="_blank" rel="noopener noreferrer"
data-no-image-dialog="true"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"><source
media="(prefers-color-scheme: light)"
srcset="https://www.cubic.dev/buttons/review-in-cubic-light.svg"><img
alt="View guided diff"
src="https://www.cubic.dev/buttons/review-in-cubic-light.svg"></picture></a>
<!-- End of auto-generated description by cubic. -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants