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

@@ -63,10 +63,11 @@ pub fn plain_list_item<'r, 's>(
// It is fine that we get the indent level using the number of bytes rather than the number of characters because nom's space0 only matches space and tab (0x20 and 0x09)
let indent_level = leading_whitespace.len();
let parser_context = context
.with_additional_node(ContextElement::ConsumeTrailingWhitespace(false))
.with_additional_node(ContextElement::ListItem(indent_level))
.with_additional_node(ContextElement::ExitMatcherNode(ExitMatcherNode {
exit_matcher: ChainBehavior::AndParent(Some(&plain_list_item_end)),
}))
.with_additional_node(ContextElement::ListItem(indent_level));
}));
let element_matcher = parser_with_context!(element)(&parser_context);
let exit_matcher = parser_with_context!(exit_matcher_parser)(&parser_context);