Separate out calls to build element parser.

This commit is contained in:
Tom Alexander
2023-04-22 01:08:45 -04:00
parent 4ac6d89311
commit ba74bb58bb
7 changed files with 28 additions and 14 deletions

View File

@@ -161,8 +161,9 @@ pub fn plain_list_item<'r, 's>(
exit_matcher: &plain_list_item_end,
}));
let with_consume_matcher = parser_with_context!(element(true))(&with_consume_context);
let without_consume_matcher = parser_with_context!(element(true))(&without_consume_context);
let element_matcher = element(true);
let with_consume_matcher = parser_with_context!(element_matcher)(&with_consume_context);
let without_consume_matcher = parser_with_context!(element_matcher)(&without_consume_context);
let exit_matcher = parser_with_context!(exit_matcher_parser)(&with_consume_context);
let (remaining, bull) =
verify(bullet, |bull: &str| bull != "*" || indent_level > 0)(remaining)?;
@@ -370,7 +371,8 @@ mod tests {
let initial_context: ContextTree<'_, '_> = ContextTree::new();
let document_context =
initial_context.with_additional_node(ContextElement::DocumentRoot(input));
let plain_list_matcher = parser_with_context!(element(true))(&document_context);
let element_matcher = element(true);
let plain_list_matcher = parser_with_context!(element_matcher)(&document_context);
let (remaining, result) =
plain_list_matcher(input).expect("Should parse the plain list successfully.");
assert_eq!(remaining, " ipsum\n");
@@ -396,7 +398,8 @@ 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!(element(true))(&document_context);
let element_matcher = element(true);
let plain_list_matcher = parser_with_context!(element_matcher)(&document_context);
let (remaining, result) =
plain_list_matcher(input).expect("Should parse the plain list successfully.");
assert_eq!(remaining, "baz");