Add a test proving that nested lists are exited by two blank lines.

This commit is contained in:
Tom Alexander 2023-04-12 13:21:31 -04:00
parent 75a47deedd
commit ba9ef7907f
Signed by: talexander
GPG Key ID: D3A179C9A53C0EDE
1 changed files with 25 additions and 1 deletions

View File

@ -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
"#
);
}