Private
Public Access
0
0

test(markdown): add GFM table parser failing tests

This commit is contained in:
2026-06-03 10:59:57 -04:00
parent 11253e8d60
commit 44f631c9a5
2 changed files with 38 additions and 0 deletions
+10
View File
@@ -0,0 +1,10 @@
from dataclasses import dataclass
@dataclass(frozen=True)
class TableBlock:
headers: list[str]
rows: list[list[str]]
span: tuple[int, int]
def parse_tables(text: str) -> list[TableBlock]:
return []
+28
View File
@@ -0,0 +1,28 @@
from src.markdown_table import parse_tables
def test_parses_simple_two_column_table():
text = (
"| Name | Type |\n"
"|-------|------|\n"
"| foo | int |\n"
"| bar | str |\n"
)
blocks = parse_tables(text)
assert len(blocks) == 1
block = blocks[0]
assert block.headers == ["Name", "Type"]
assert block.rows == [["foo", "int"], ["bar", "str"]]
def test_ignores_tables_inside_code_fence():
text = (
"```\n"
"| not | a table |\n"
"| --- | ------- |\n"
"| x | y |\n"
"```\n"
)
assert parse_tables(text) == []
def test_returns_empty_for_plain_markdown():
text = "# Heading\n\nSome **bold** text.\n"
assert parse_tables(text) == []