From ba9ef7907fedf3c2be70dde3f9b096d6eefefc22 Mon Sep 17 00:00:00 2001 From: Tom Alexander Date: Wed, 12 Apr 2023 13:21:31 -0400 Subject: [PATCH] Add a test proving that nested lists are exited by two blank lines. --- src/parser/plain_list.rs | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/src/parser/plain_list.rs b/src/parser/plain_list.rs index 0e881e77..b728780c 100644 --- a/src/parser/plain_list.rs +++ b/src/parser/plain_list.rs @@ -267,7 +267,6 @@ mod tests { #[test] fn two_blank_lines_ends_list() { - // Plain lists with an asterisk bullet must be indented or else they would be a headline let input = r#"1. foo 2. bar baz @@ -291,6 +290,31 @@ mod tests { 3. lorem +"# + ); + } + + #[test] + fn two_blank_lines_ends_nested_list() { + // Plain lists with an asterisk bullet must be indented or else they would be a headline + let input = r#"1. foo + 1. bar + + +baz"#; + let initial_context: ContextTree<'_, '_> = ContextTree::new(); + let document_context = + initial_context.with_additional_node(ContextElement::DocumentRoot(input)); + let plain_list_matcher = parser_with_context!(plain_list)(&document_context); + let (remaining, result) = + plain_list_matcher(input).expect("Should parse the plain list successfully."); + assert_eq!(remaining, "baz"); + assert_eq!( + result.get_source(), + r#"1. foo + 1. bar + + "# ); }