fix(parser): strip blockquote continuation prefix from table rows#515
fix(parser): strip blockquote continuation prefix from table rows#515ImmanuelHaffner wants to merge 2 commits into
Conversation
get_node_text() only applies col_start offset to the first line of a tree-sitter node. For tables inside blockquotes, lines 2+ retain the '> ' prefix, causing the lpeg row parser to fail silently and produce empty results. This left separator and data rows unrendered. Strip the prefix via line:sub(col_start + 1) for lines after the first, and skip empty/blank lines (e.g. trailing '>' markers).
Repro for the block-continuation prefix fix. With tables nested in blockquotes, get_node_text() leaves the '> ' prefix on lines 2+, so the lpeg row parser fails on the separator and data rows. Observable via markdown.parse: blockquoted tables come back with alignments=0 (separator unparsed) and the separator leaking into the row count, while the plain control table parses correctly. This fixture covers a plain control table, a simple blockquote table, a nested blockquote table, and a blockquote table with alignment markers.
|
This is not a bug as |
|
I don't understand that, please elaborate. Is |
Basically every markdown parser under the sun. Parsers don't understand what a "block" is. So, a table is just a long line separated by The parsed table information is already provided so there shouldn't be any need to use the raw text. It's mostly meant to be used internally. |
|
@ImmanuelHaffner Also I don't think there's a need to change it's value only for |
get_node_text()only applies a tree-sitter node'scol_startoffset to its first line. For a table nested inside a blockquote, lines 2+ therefore retain the>block-continuation prefix, and the lpeg row parser inparsers/markdown.luafails silently on them — leaving the separator and data rows unparsed. Symptoms: no alignment is detected, and the separator row leaks into the data-row count, so blockquoted tables render broken/empty.The fix strips
range.col_startcharacters from lines after the first, and skips empty/blank lines (e.g. trailing>markers).A fixture (
test/blockquote_table.md) is included covering a plain control table, a simple blockquote table, a nested blockquote table, and a blockquote table with alignment markers.