Add a context element for tracking whether or not elements should consume their trailing whitespace.

This commit is contained in:
Tom Alexander
2023-04-10 10:36:16 -04:00
parent 6813c7c991
commit 9a0172e1a4
6 changed files with 60 additions and 10 deletions

View File

@@ -100,10 +100,11 @@ pub fn document(input: &str) -> Res<&str, Document> {
fn section<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, Section<'s>> {
// TODO: The zeroth section is specialized so it probably needs its own parser
let parser_context = context
.with_additional_node(ContextElement::ConsumeTrailingWhitespace(true))
.with_additional_node(ContextElement::Context("section"))
.with_additional_node(ContextElement::ExitMatcherNode(ExitMatcherNode {
exit_matcher: ChainBehavior::AndParent(Some(&section_end)),
}))
.with_additional_node(ContextElement::Context("section"));
}));
let element_matcher = parser_with_context!(element)(&parser_context);
let exit_matcher = parser_with_context!(exit_matcher_parser)(&parser_context);
let trailing_matcher = parser_with_context!(element_trailing_whitespace)(&parser_context);