From 45db182421118e21326a1ec4789c15552a5cf181 Mon Sep 17 00:00:00 2001 From: Tom Alexander Date: Mon, 10 Apr 2023 11:34:29 -0400 Subject: [PATCH] Add comment about why we are not checking the parent exit matcher in paragraph. --- src/parser/paragraph.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/parser/paragraph.rs b/src/parser/paragraph.rs index ea97408..e0a1235 100644 --- a/src/parser/paragraph.rs +++ b/src/parser/paragraph.rs @@ -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");