Add comment about why we are not checking the parent exit matcher in paragraph.

This commit is contained in:
Tom Alexander 2023-04-10 11:34:29 -04:00
parent df9265c2af
commit 45db182421
Signed by: talexander
GPG Key ID: D3A179C9A53C0EDE

View File

@ -37,8 +37,7 @@ pub fn paragraph<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s st
|(children, _exit_contents)| !children.is_empty(),
)(input)?;
// Check if a parent exit matcher is causing the exit
exit_matcher_parser(context, remaining)?;
// Not checking parent exit matcher because if there are any children matched then we have a valid paragraph.
let (remaining, _trailing_ws) = if context.should_consume_trailing_whitespace() {
opt(parser_with_context!(element_trailing_whitespace)(
@ -79,8 +78,9 @@ mod tests {
let document_context =
initial_context.with_additional_node(ContextElement::DocumentRoot(input));
let paragraph_matcher = parser_with_context!(paragraph)(&document_context);
let (remaining, first_paragraph) = paragraph_matcher(input).unwrap();
let (remaining, second_paragraph) = paragraph_matcher(remaining).unwrap();
let (remaining, first_paragraph) = paragraph_matcher(input).expect("Parse first paragraph");
let (remaining, second_paragraph) =
paragraph_matcher(remaining).expect("Parse second paragraph.");
assert_eq!(remaining, "");
assert_eq!(first_paragraph.source, "foo bar baz\n\n");
assert_eq!(second_paragraph.source, "lorem ipsum");