PPTX image alt text ending in a backslash breaks the Markdown image

Aperta Adatta ai principianti
#2,943 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@dongyikuan919 ci sta già lavorando.

Dal 1/12/2026.

  • #2944 di @dongyikuan919 — aperta

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
78/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
python
Ambito
backend

Direzione di ricerca

Individua il percorso di conversione delle immagini PPTX che normalizza il testo alternativo prima di creare i link Markdown alle immagini. Leggi come questo percorso gestisce i link a immagini normali e i link a immagini data URI, poi aggiungi test per il testo alternativo che termina con una barra rovesciata. Il lavoro è completato quando entrambe le immagini vengono analizzate come nodi immagine e il primo testo alternativo conserva la barra rovesciata letterale finale.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

What happens

A PowerPoint picture whose native alt text ends in a backslash is emitted as ![Output directory C:\](Picture1.jpg). CommonMark treats the backslash as escaping the closing bracket, so the picture no longer renders as an image. An ordinary alt label in the next picture renders correctly.

I reproduced this on the PyPI release 0.1.9 and on main at ed178952a6672abdfd35b5f9e76a80b6cefc086e.

Minimal reproduction

With markitdown[pptx], Pillow and markdown-it-py installed:

from io import BytesIO

from markdown_it import MarkdownIt
from markitdown import MarkItDown, StreamInfo
from PIL import Image
from pptx import Presentation
from pptx.util import Inches

deck = Presentation()
slide = deck.slides.add_slide(deck.slide_layouts[6])
for x, alt in enumerate(("Output directory C:\\", "Control image")):
    png = BytesIO()
    Image.new("RGB", (1, 1), "white").save(png, format="PNG")
    png.seek(0)
    picture = slide.shapes.add_picture(png, Inches(x), Inches(0))
    picture._element._nvXxPr.cNvPr.set("descr", alt)

source = BytesIO()
deck.save(source)
source.seek(0)
result = MarkItDown().convert_stream(source, stream_info=StreamInfo(extension=".pptx"))
images = [
    "".join(segment.content for segment in child.children or [])
    for token in MarkdownIt().parse(result.markdown)
    for child in token.children or []
    if child.type == "image"
]
print(images)

Actual: ['Control image']

Expected: Both image nodes, with the first alt text ending in a literal backslash.

The converter normalizes the label before inserting it between the Markdown brackets. Escaping literal backslashes at that point should preserve the intended text for both ordinary and data-URI image links.

Prepared and reproduced with Codex assistance.

Lingua principale
Python
Stelle
198k
Fork
15k
Merge medio
2h 16m
PR unite (30g)
9

Preparare l'ambiente

Apri in Codespaces

Avvia il container di sviluppo del progetto nel browser, con il tuo account GitHub.

  • Include un Dockerfile o un file Docker Compose
  • Nessun modello di pull request
  • Nessuna guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di microsoft/markitdown

Tutte le issue di microsoft/markitdown

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.