Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .beads/issues.jsonl

Large diffs are not rendered by default.

432 changes: 432 additions & 0 deletions claude-notes/plans/2026-05-11-bq-multiline-in-list-item.md

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- > a
> b
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
1. > a
> b
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
1) > a
> b
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
+ > a
> b
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
* > a
> b
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
- > a
> b

c
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
- > a
> b
> c
18 changes: 17 additions & 1 deletion crates/tree-sitter-qmd/tree-sitter-markdown/src/scanner.c
Original file line number Diff line number Diff line change
Expand Up @@ -2037,7 +2037,23 @@ static bool scan(Scanner *s, TSLexer *lexer, const bool *valid_symbols) {
return false;
}

if (s->state & STATE_MATCHING) { // we are in the state of trying to match all currently open blocks
// bd-vet6: when we re-enter STATE_MATCHING after a SOFT_LINE_ENDING
// and the current lookahead is the trailing \n / \r of the same
// logical line, do NOT call match_line here. The LIST_ITEM match()
// returns case 2 on \n (see line ~537) and advances past it; the
// line-ending gate at line ~2233 then has nothing to match against
// and scan() returns false. The state changes get rolled back, but
// tree-sitter retries with another lex_external state and emits
// CLOSE_BLOCK, which the parser cannot shift in this position.
// Bypassing match_line here lets the line-ending gate run and emit
// the LINE_ENDING / SOFT_LINE_ENDING the parser actually expects.
// (EOF is handled above at line ~2027 and never reaches here.)
bool at_soft_break_line_end =
(s->state & STATE_MATCHING) &&
(s->state & STATE_WAS_SOFT_LINE_BREAK) &&
(lexer->lookahead == '\n' || lexer->lookahead == '\r');

if ((s->state & STATE_MATCHING) && !at_soft_break_line_end) { // we are in the state of trying to match all currently open blocks
DEBUG_PRINT("scan() while STATE_MATCHING\n");
int match_line_return = match_line(s, lexer);
// bool might_be_soft_break = match_line_return & 2;
Expand Down
127 changes: 126 additions & 1 deletion crates/tree-sitter-qmd/tree-sitter-markdown/test/corpus/list.txt
Original file line number Diff line number Diff line change
Expand Up @@ -425,4 +425,129 @@ b
(pandoc_str)
(block_continuation)))
(list_item
(list_marker_star))))))
(list_marker_star))))))
================================================================================
24 - multi-line block quote inside list item, followed by paragraph (minus)
================================================================================
- > a
> b

c
--------------------------------------------------------------------------------
(document
(section
(pandoc_list
(list_item
(list_marker_minus)
(pandoc_block_quote
(block_quote_marker)
(pandoc_paragraph
(pandoc_str)
(pandoc_soft_break)
(pandoc_str)))))
(pandoc_paragraph
(pandoc_str))))
================================================================================
25 - multi-line block quote inside list item, followed by paragraph (star)
================================================================================
* > a
> b

c
--------------------------------------------------------------------------------
(document
(section
(pandoc_list
(list_item
(list_marker_star)
(pandoc_block_quote
(block_quote_marker)
(pandoc_paragraph
(pandoc_str)
(pandoc_soft_break)
(pandoc_str)))))
(pandoc_paragraph
(pandoc_str))))
================================================================================
26 - multi-line block quote inside list item, followed by paragraph (plus)
================================================================================
+ > a
> b

c
--------------------------------------------------------------------------------
(document
(section
(pandoc_list
(list_item
(list_marker_plus)
(pandoc_block_quote
(block_quote_marker)
(pandoc_paragraph
(pandoc_str)
(pandoc_soft_break)
(pandoc_str)))))
(pandoc_paragraph
(pandoc_str))))
================================================================================
27 - multi-line block quote inside list item, followed by paragraph (ordered, dot)
================================================================================
1. > a
> b

c
--------------------------------------------------------------------------------
(document
(section
(pandoc_list
(list_item
(list_marker_dot)
(pandoc_block_quote
(block_quote_marker)
(pandoc_paragraph
(pandoc_str)
(pandoc_soft_break)
(pandoc_str)))))
(pandoc_paragraph
(pandoc_str))))
================================================================================
28 - multi-line block quote inside list item, followed by paragraph (ordered, paren)
================================================================================
1) > a
> b

c
--------------------------------------------------------------------------------
(document
(section
(pandoc_list
(list_item
(list_marker_parenthesis)
(pandoc_block_quote
(block_quote_marker)
(pandoc_paragraph
(pandoc_str)
(pandoc_soft_break)
(pandoc_str)))))
(pandoc_paragraph
(pandoc_str))))
================================================================================
29 - three-line block quote inside list item
================================================================================
- > a
> b
> c
--------------------------------------------------------------------------------
(document
(section
(pandoc_list
(list_item
(list_marker_minus)
(pandoc_block_quote
(block_quote_marker)
(pandoc_paragraph
(pandoc_str)
(pandoc_soft_break)
(pandoc_str)
(pandoc_soft_break)
(pandoc_str)))))))