markitdown icon indicating copy to clipboard operation
markitdown copied to clipboard

HTML/DOCX: pipe characters in table cells break Markdown tables

Open soroush5 opened this issue 2 months ago • 0 comments

A literal pipe in an HTML table cell is data, not a column separator, but it is passed through untouched, so the rendered row gains phantom columns. DOCX tables are affected too since they convert via the HTML converter.

Repro:

import io
from markitdown import MarkItDown

html = (
    '<table><thead><tr><th>Name</th><th>Note</th></tr></thead>'
    '<tbody><tr><td>Alice</td><td>Has a | pipe</td></tr></tbody></table>'
)
print(MarkItDown().convert_stream(
    io.BytesIO(html.encode()), file_extension='.html').markdown)
# Before: | Alice | Has a | pipe |   (3 columns, broken)
# After:  | Alice | Has a \| pipe |  (2 columns, correct)

Same class as the CSV (#2266) and XLSX (#2436) pipe bugs, but in the shared HTML layer (_CustomMarkdownify), which neither of those covers. Searched open and closed issues/PRs: no report or fix for HTML/DOCX table pipes (open #1785 covers PPTX only, via pre-escaping).

soroush5 avatar Sep 10 '26 07:09 soroush5