Skip to content

Table parsing fails #376

Description

@poutila

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions