Moving towards unifying into a single parameterized element matcher.

This is to give paragraph priority over keyword in parsing so that affiliated keywords for paragraphs will be parsed as such.
This commit is contained in:
Tom Alexander
2023-04-22 00:55:31 -04:00
parent fef5841713
commit 4ac6d89311
8 changed files with 81 additions and 99 deletions

View File

@@ -161,8 +161,8 @@ pub fn plain_list_item<'r, 's>(
exit_matcher: &plain_list_item_end,
}));
let with_consume_matcher = parser_with_context!(element)(&with_consume_context);
let without_consume_matcher = parser_with_context!(element)(&without_consume_context);
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 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 +370,7 @@ 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)(&document_context);
let plain_list_matcher = parser_with_context!(element(true))(&document_context);
let (remaining, result) =
plain_list_matcher(input).expect("Should parse the plain list successfully.");
assert_eq!(remaining, " ipsum\n");
@@ -396,7 +396,7 @@ 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)(&document_context);
let plain_list_matcher = parser_with_context!(element(true))(&document_context);
let (remaining, result) =
plain_list_matcher(input).expect("Should parse the plain list successfully.");
assert_eq!(remaining, "baz");
@@ -427,7 +427,8 @@ dolar"#;
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)(&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, "dolar");