Private
Public Access
test(markdown): add GFM table parser failing tests
This commit is contained in:
@@ -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) == []
|
||||
Reference in New Issue
Block a user