Skip to content

fix(pptx): turn line breaks in table cells and notes into newlines - #4844

Open
LindseyZ1205 wants to merge 1 commit into
docling-project:mainfrom
LindseyZ1205:fix/pptx-vertical-tab
Open

LindseyZ1205 wants to merge 1 commit into
docling-project:mainfrom
LindseyZ1205:fix/pptx-vertical-tab

Conversation

@LindseyZ1205

Copy link
Copy Markdown
Contributor

python-pptx returns a line break inside a paragraph (a:br) as a vertical tab ("\v") in the .text of a text frame. The backend uses .text for table cells and for the slide notes, so this control character was in the cell text, in the notes text and in the Markdown export. This change adds a small helper _text_frame_text that replaces "\v" with "\n", the in-paragraph line break of a DoclingDocument (#1787), and uses it for table cells and notes.

Text boxes are read run by run in _paragraph_fragments, which turns a line break into a space (#1664). I did not change this, so that the existing ground truth stays the same. If you prefer a space in table cells and notes as well, I can change the helper.

Issue resolved by this Pull Request:
Resolves #4843

Checklist:

  • Documentation has been updated, if necessary.
  • Examples have been added, if necessary.
  • Tests have been added, if necessary.

Review evidence:

  • Before: a table cell with a line break had the text 'line1\x0bline2', the notes had 'note a\x0bnote b', and the Markdown table row was | line1\x0bline2 | plain |.
  • After: the cell text is 'line1\nline2' and the notes text is 'note a\nnote b'. The Markdown table row is | line1 line2 | plain |, the same as a text box with a line break.
  • Document tree: only the text of table cells and notes that contain a line break changes. Cells and notes without a line break give the same text as before.
  • Reference data: no change. All tests in tests/test_backend_pptx*.py pass with the existing ground truth files, including test_e2e_pptx_conversions.
  • New test: test_pptx_line_breaks_in_table_cells_and_notes in tests/test_backend_pptx.py. It fails on main and passes with this change.
  • Commands and results:
    • uv run --frozen --extra format-pptx --extra format-docx pytest tests/test_backend_pptx.py tests/test_backend_pptx_charts.py tests/test_backend_pptx_hidden_shapes.py tests/test_backend_pptx_math.py tests/test_backend_pptx_shape_hyperlink.py: 79 passed. On main, only the new test fails.
    • uvx prek run --files docling/backend/mspowerpoint_backend.py tests/test_backend_pptx.py: all hooks pass (Ruff, ty, Tach, max lines).
  • Not run: the full test suite.

python-pptx gives a line break inside a paragraph (a:br) as a vertical
tab ("\v") in the .text of a text frame. The backend used .text for
table cells and notes, so this control character ended up in the cell
text, in the notes text and in the Markdown export. Replace it with
"\n", the in-paragraph line break of a DoclingDocument (docling-project#1787).

Signed-off-by: LindseyZ1205 <yingzizhang1205@gmail.com>
@github-actions

Copy link
Copy Markdown
Contributor

✅ DCO Check Passed

Thanks @LindseyZ1205, all your commits are properly signed off. 🎉

@mergify

mergify Bot commented Oct 15, 2026

Copy link
Copy Markdown
Contributor

Merge Protections

🟢 Merge protection satisfied — ready to merge.

Show 1 satisfied protection

🟢 Enforce conventional commit

Make sure that we follow https://www.conventionalcommits.org/en/v1.0.0/

  • title ~= ^(fix|feat|docs|style|refactor|perf|test|build|ci|chore|revert)(?:\(.+\))?(!)?:

@github-actions github-actions Bot added ai:ci-safe AI triage found no CI-safety concern (advisory) bug Something isn't working pptx issue related to pptx backend labels Oct 15, 2026
@github-actions

Copy link
Copy Markdown
Contributor

AI triage (advisory)

Checked commit a030639219. The analysis read the diff only. It did not run code from this pull request.

This PR replaces vertical tab control characters (\v) with newlines (\n) in PowerPoint table cells and slide notes.

Topic labels added: bug, pptx.

CI safety: no concern found. A maintainer must still approve CI.

3 related pull request(s) in the same code
PR State Signal Assessment
#4443 open changes the same code related: PR #4443 modifies PowerPoint text run handling for formatting and hyperlinks. It does not change table cells or slide notes.
#1664 merged referenced as #1664 related: PR #1664 replaces line breaks in PowerPoint text boxes with spaces. It does not handle vertical tabs in table cells or slide notes.
#1600 closed also references issue #1787 related: PR #1600 is closed without merge. It replaced line breaks in table cells with HTML tags instead of newlines.

The ai:* labels are advisory. They do not approve CI and they do not add tests:full. A new push runs this check again.

@github-actions github-actions Bot 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.

AI first review (advisory): no blocker found

This review covers the full diff at a030639219. It read the code and did not run it.

I checked the line break conversion in PPTX table cells and slide notes, the helper function, and the regression test. The change replaces python-pptx vertical tab characters with newlines without breaking existing exports.

A maintainer makes the merge decision. This review never approves the pull request.

@github-actions github-actions Bot added the ai:review-lgtm AI first review found no blocker or major issue (advisory) label Oct 15, 2026
@codecov

codecov Bot commented Oct 15, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai:ci-safe AI triage found no CI-safety concern (advisory) ai:review-lgtm AI first review found no blocker or major issue (advisory) bug Something isn't working pptx issue related to pptx backend

Projects

None yet

Development

Successfully merging this pull request may close these issues.

PPTX: a line break in a table cell or in the notes adds a vertical tab (\x0b) to the text

1 participant