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

Commit
24 days ago
fix(pptx): read a line break as a newline instead of a vertical tab (#4571) ## 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`. <!-- This is an auto-generated description by cubic. --> <a href="https://cubic.dev/pr/Unstructured-IO/unstructured/pull/4571?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. -->
Author
Parents
Loading