markdown-it-py icon indicating copy to clipboard operation
markdown-it-py copied to clipboard

Table parsing fails

Open poutila opened this issue 2 months ago • 0 comments

Describe the bug

/markdown_it/rules_block/table.py

  1. Header row checks for | (line 130-131)
  2. Body rows don't check for | (missing after line 198)

The fix is one line: if "|" not in lineText: break

Minimal Reproduction

from markdown_it import MarkdownIt

md = MarkdownIt('commonmark').enable('table')

content = """| A | B | |---|---| | 1 | 2 | Paragraph. """

tokens = md.parse(content) for t in tokens: if t.type == 'table_open': print(f'table_open: map={t.map}') # Expected: [0, 3], Actual: [0, 4]

Expected: Table ends at line 3, "Paragraph." is separate Actual: Table includes line 4, "Paragraph." parsed as table cell

Reproduce the bug

Minimal Reproduction

from markdown_it import MarkdownIt

md = MarkdownIt('commonmark').enable('table')

content = """| A | B | |---|---| | 1 | 2 | Paragraph. """

tokens = md.parse(content) for t in tokens: if t.type == 'table_open': print(f'table_open: map={t.map}') # Expected: [0, 3], Actual: [0, 4]

List your environment

No response

poutila avatar Dec 11 '25 12:12 poutila