haystack icon indicating copy to clipboard operation
haystack copied to clipboard

PPTXToDocument drops soft line breaks when link_format is markdown or plain

Open Harsh23Kashyap opened this issue 2 months ago • 1 comments

Describe the bug

With link_format="markdown" or "plain", PPTXToDocument joins the runs of a paragraph directly. A soft line break (Shift+Enter, the <a:br/> element) between runs disappears, so the text on both sides is glued together. The default link_format="none" path keeps the break.

A deck whose textbox holds Account: Alice, a soft line break, then Balance: 100 converts like this:

from io import BytesIO
from pptx import Presentation
from pptx.util import Inches
from haystack.components.converters import PPTXToDocument
from haystack.dataclasses import ByteStream

presentation = Presentation()
slide = presentation.slides.add_slide(presentation.slide_layouts[6])
frame = slide.shapes.add_textbox(Inches(1), Inches(1), Inches(7), Inches(2)).text_frame
frame.text = "Account: Alice\vBalance: 100"
buffer = BytesIO()
presentation.save(buffer)

for link_format in ("none", "markdown", "plain"):
    documents = PPTXToDocument(link_format=link_format).run(
        sources=[ByteStream(data=buffer.getvalue())]
    )["documents"]
    print(link_format, repr(documents[0].content))

Output:

none 'Account: Alice\x0bBalance: 100'
markdown 'Account: AliceBalance: 100'
plain 'Account: AliceBalance: 100'

Alice and Balance become one token in both link modes, so retrieval over the converted document no longer matches either word cleanly.

Expected behavior

Soft line breaks should survive in every link_format, matching what the default mode already returns.

Environment

Reproduced twice with python-pptx 1.0.2 against current main (0499239e66f515feab503a2768ba785cace6de91).

I can prepare a draft PR with regression tests if this fits the intended behavior.

Harsh23Kashyap avatar Sep 30 '26 16:09 Harsh23Kashyap

Taking this. Plan: reproduce with a PPTX that contains soft line breaks under markdown/plain link format, fix the handling in PPTXToDocument, and add a regression test. PR incoming.

Harbor404 avatar Oct 01 '26 17:10 Harbor404