diff options
Diffstat (limited to '')
-rw-r--r-- | src/compiler.rs | 69 |
1 files changed, 42 insertions, 27 deletions
diff --git a/src/compiler.rs b/src/compiler.rs index 57ab40a..4a9ec36 100644 --- a/src/compiler.rs +++ b/src/compiler.rs @@ -479,48 +479,63 @@ fn on_enter_list(context: &mut CompileContext) { } else { balance -= 1; - // Blank line directly in list or directly in list item, - // but not a blank line after an empty list item. if balance < 3 && event.token_type == Token::BlankLineEnding { - let mut at_marker = false; + // Blank line directly after a prefix: + // + // ```markdown + // > | -␊ + // ^ + // | a + // ``` + let mut at_prefix = false; + // Blank line directly after item, which is just a prefix. + // + // ```markdown + // > | -␊ + // ^ + // | - a + // ``` + let mut at_empty_list_item = false; + // Blank line at block quote prefix: + // + // ```markdown + // > | * >␊ + // ^ + // | * a + // ``` + let mut at_empty_block_quote = false; - if balance == 2 { + if balance == 1 { let mut before = index - 2; - if events[before].token_type == Token::SpaceOrTab { - before -= 2; - } - - if events[before].token_type == Token::ListItemPrefix { - at_marker = true; - } - } + if events[before].token_type == Token::ListItem { + before -= 1; - let mut at_empty_list_item = false; - let mut at_empty_block_quote = false; + if events[before].token_type == Token::SpaceOrTab { + before -= 2; + } - if balance == 1 { + if events[before].token_type == Token::BlockQuote + && events[before - 1].token_type == Token::BlockQuotePrefix + { + at_empty_block_quote = true; + } else if events[before].token_type == Token::ListItemPrefix { + at_empty_list_item = true; + } + } + } else { let mut before = index - 2; if events[before].token_type == Token::SpaceOrTab { before -= 2; } - if events[before].token_type == Token::ListItem - && events[before - 1].token_type == Token::ListItemPrefix - { - at_empty_list_item = true; - } - - if events[before].token_type == Token::ListItem - && events[before - 1].token_type == Token::BlockQuote - && events[before - 2].token_type == Token::BlockQuotePrefix - { - at_empty_block_quote = true; + if events[before].token_type == Token::ListItemPrefix { + at_prefix = true; } } - if !at_marker && !at_empty_list_item && !at_empty_block_quote { + if !at_prefix && !at_empty_list_item && !at_empty_block_quote { loose = true; break; } |