Add a test case demonstrating an issue.

This commit is contained in:
Tom Alexander
2023-04-12 15:24:18 -04:00
parent 9efc291d28
commit 665c1d70fb
2 changed files with 40 additions and 34 deletions

View File

@@ -100,6 +100,7 @@ pub fn plain_list_item<'r, 's>(
}
Err(_) => {
let (remaining, _ws) = space1(remaining)?;
// TODO: The problem is we are not capturing trailing whitespace for elements that are before the last element.
let (remaining, (contents, _exit_contents)) =
many_till(element_matcher, exit_matcher)(remaining)?;
let source = get_consumed(input, remaining);
@@ -296,7 +297,6 @@ mod tests {
#[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
@@ -315,6 +315,40 @@ baz"#;
1. bar
"#
);
}
#[test]
fn interior_trailing_whitespace() {
let input = r#"1. foo
bar
1. baz
lorem
ipsum"#;
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, "ipsum");
assert_eq!(
result.get_source(),
r#"1. foo
bar
1. baz
lorem
"#
);
}