Add comment about why we are not checking the parent exit matcher in paragraph.
This commit is contained in:
parent
df9265c2af
commit
45db182421
@ -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(),
|
|(children, _exit_contents)| !children.is_empty(),
|
||||||
)(input)?;
|
)(input)?;
|
||||||
|
|
||||||
// Check if a parent exit matcher is causing the exit
|
// Not checking parent exit matcher because if there are any children matched then we have a valid paragraph.
|
||||||
exit_matcher_parser(context, remaining)?;
|
|
||||||
|
|
||||||
let (remaining, _trailing_ws) = if context.should_consume_trailing_whitespace() {
|
let (remaining, _trailing_ws) = if context.should_consume_trailing_whitespace() {
|
||||||
opt(parser_with_context!(element_trailing_whitespace)(
|
opt(parser_with_context!(element_trailing_whitespace)(
|
||||||
@ -79,8 +78,9 @@ mod tests {
|
|||||||
let document_context =
|
let document_context =
|
||||||
initial_context.with_additional_node(ContextElement::DocumentRoot(input));
|
initial_context.with_additional_node(ContextElement::DocumentRoot(input));
|
||||||
let paragraph_matcher = parser_with_context!(paragraph)(&document_context);
|
let paragraph_matcher = parser_with_context!(paragraph)(&document_context);
|
||||||
let (remaining, first_paragraph) = paragraph_matcher(input).unwrap();
|
let (remaining, first_paragraph) = paragraph_matcher(input).expect("Parse first paragraph");
|
||||||
let (remaining, second_paragraph) = paragraph_matcher(remaining).unwrap();
|
let (remaining, second_paragraph) =
|
||||||
|
paragraph_matcher(remaining).expect("Parse second paragraph.");
|
||||||
assert_eq!(remaining, "");
|
assert_eq!(remaining, "");
|
||||||
assert_eq!(first_paragraph.source, "foo bar baz\n\n");
|
assert_eq!(first_paragraph.source, "foo bar baz\n\n");
|
||||||
assert_eq!(second_paragraph.source, "lorem ipsum");
|
assert_eq!(second_paragraph.source, "lorem ipsum");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user