From 494fe5ccebffd74c02832fa9052f3cfbee726bbc Mon Sep 17 00:00:00 2001 From: Tom Alexander Date: Fri, 8 Sep 2023 19:01:46 -0400 Subject: [PATCH] Handle contentless list items mid-document. --- src/parser/plain_list.rs | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/parser/plain_list.rs b/src/parser/plain_list.rs index f74de75..8c02bff 100644 --- a/src/parser/plain_list.rs +++ b/src/parser/plain_list.rs @@ -154,8 +154,10 @@ pub fn plain_list_item<'b, 'g, 'r, 's>( let (remaining, maybe_tag) = opt(tuple((space1, parser_with_context!(item_tag)(context))))(remaining)?; - let maybe_contentless_item: Res, OrgSource<'_>> = - peek(recognize(tuple((many0(blank_line), eof))))(remaining); + + let maybe_contentless_item: Res, ()> = peek(parser_with_context!( + detect_contentless_item_contents + )(context))(remaining); match maybe_contentless_item { Ok((_rem, _ws)) => { let (remaining, _trailing_ws) = opt(blank_line)(remaining)?; @@ -374,6 +376,18 @@ fn item_tag_post_gap<'b, 'g, 'r, 's>( )(input) } +#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] +fn detect_contentless_item_contents<'b, 'g, 'r, 's>( + context: RefContext<'b, 'g, 'r, 's>, + input: OrgSource<'s>, +) -> Res, ()> { + let (remaining, _) = recognize(many_till( + blank_line, + parser_with_context!(exit_matcher_parser)(context), + ))(input)?; + Ok((remaining, ())) +} + #[cfg(test)] mod tests { use super::*;