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

@@ -50,7 +50,8 @@ 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(true))(&parser_context);
let element_matcher = element(true);
let element_matcher = parser_with_context!(element_matcher)(&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 +125,8 @@ 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(true))(&document_context);
let element_matcher = element(true);
let footnote_definition_matcher = parser_with_context!(element_matcher)(&document_context);
let (remaining, first_footnote_definition) =
footnote_definition_matcher(input).expect("Parse first footnote_definition");
let (remaining, second_footnote_definition) =
@@ -155,7 +157,8 @@ 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(true))(&document_context);
let element_matcher = element(true);
let footnote_definition_matcher = parser_with_context!(element_matcher)(&document_context);
let (remaining, first_footnote_definition) =
footnote_definition_matcher(input).expect("Parse first footnote_definition");
assert_eq!(remaining, "not in the footnote.");