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

@@ -50,7 +50,7 @@ pub fn footnote_definition<'r, 's>(
exit_matcher: &footnote_definition_end,
}));
// TODO: The problem is we are not accounting for trailing whitespace like we do in section. Maybe it would be easier if we passed down whether or not to parse trailing whitespace into the element matcher similar to how tag takes in parameters.
let element_matcher = parser_with_context!(element)(&parser_context);
let element_matcher = parser_with_context!(element(true))(&parser_context);
let exit_matcher = parser_with_context!(exit_matcher_parser)(&parser_context);
let (remaining, (children, _exit_contents)) =
many_till(element_matcher, exit_matcher)(remaining)?;
@@ -124,7 +124,7 @@ line footnote.";
let initial_context: ContextTree<'_, '_> = ContextTree::new();
let document_context =
initial_context.with_additional_node(ContextElement::DocumentRoot(input));
let footnote_definition_matcher = parser_with_context!(element)(&document_context);
let footnote_definition_matcher = parser_with_context!(element(true))(&document_context);
let (remaining, first_footnote_definition) =
footnote_definition_matcher(input).expect("Parse first footnote_definition");
let (remaining, second_footnote_definition) =
@@ -155,7 +155,7 @@ not in the footnote.";
let initial_context: ContextTree<'_, '_> = ContextTree::new();
let document_context =
initial_context.with_additional_node(ContextElement::DocumentRoot(input));
let footnote_definition_matcher = parser_with_context!(element)(&document_context);
let footnote_definition_matcher = parser_with_context!(element(true))(&document_context);
let (remaining, first_footnote_definition) =
footnote_definition_matcher(input).expect("Parse first footnote_definition");
assert_eq!(remaining, "not in the footnote.");