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

@@ -34,8 +34,9 @@ pub fn footnote_definition<'r, 's>(
// Cannot be indented.
let (remaining, (_lead_in, lbl, _lead_out, _ws)) =
tuple((tag_no_case("[fn:"), label, tag("]"), space0))(input)?;
let parser_context =
context.with_additional_node(ContextElement::ExitMatcherNode(ExitMatcherNode {
let parser_context = context
.with_additional_node(ContextElement::ConsumeTrailingWhitespace(true))
.with_additional_node(ContextElement::ExitMatcherNode(ExitMatcherNode {
exit_matcher: ChainBehavior::IgnoreParent(Some(&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.