Fix footnote definition end matcher detecting the next footnote definition.

This commit is contained in:
Tom Alexander
2023-04-19 14:30:02 -04:00
parent 71bc1a5679
commit c6fd04e9ce
2 changed files with 21 additions and 8 deletions

View File

@@ -83,10 +83,18 @@ fn footnote_definition_end<'r, 's>(
input: &'s str,
) -> Res<&'s str, &'s str> {
let start_of_line_matcher = parser_with_context!(start_of_line)(context);
let footnote_definition_matcher = parser_with_context!(footnote_definition)(context);
let allow_nesting_context =
context.with_additional_node(ContextElement::Context("allow nesting footnotes"));
let footnote_definition_matcher = parser_with_context!(footnote_definition)(
if immediate_in_section(context, "footnote definition") {
&allow_nesting_context
} else {
context
},
);
let maybe_consume_trailing_whitespace_matcher =
parser_with_context!(maybe_consume_trailing_whitespace)(context);
alt((
let (remaining, source) = alt((
recognize(tuple((
maybe_consume_trailing_whitespace_matcher,
footnote_definition_matcher,
@@ -95,7 +103,9 @@ fn footnote_definition_end<'r, 's>(
start_of_line_matcher,
verify(many1(blank_line), |lines: &Vec<&str>| lines.len() >= 2),
))),
))(input)
))(input)?;
Ok((remaining, source))
}
#[cfg(test)]