Handle contentless list items mid-document.

This commit is contained in:
Tom Alexander 2023-09-08 19:01:46 -04:00
parent 0110d23387
commit 494fe5cceb
Signed by: talexander
GPG Key ID: D3A179C9A53C0EDE

View File

@ -154,8 +154,10 @@ pub fn plain_list_item<'b, 'g, 'r, 's>(
let (remaining, maybe_tag) = let (remaining, maybe_tag) =
opt(tuple((space1, parser_with_context!(item_tag)(context))))(remaining)?; opt(tuple((space1, parser_with_context!(item_tag)(context))))(remaining)?;
let maybe_contentless_item: Res<OrgSource<'_>, OrgSource<'_>> =
peek(recognize(tuple((many0(blank_line), eof))))(remaining); let maybe_contentless_item: Res<OrgSource<'_>, ()> = peek(parser_with_context!(
detect_contentless_item_contents
)(context))(remaining);
match maybe_contentless_item { match maybe_contentless_item {
Ok((_rem, _ws)) => { Ok((_rem, _ws)) => {
let (remaining, _trailing_ws) = opt(blank_line)(remaining)?; let (remaining, _trailing_ws) = opt(blank_line)(remaining)?;
@ -374,6 +376,18 @@ fn item_tag_post_gap<'b, 'g, 'r, 's>(
)(input) )(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<OrgSource<'s>, ()> {
let (remaining, _) = recognize(many_till(
blank_line,
parser_with_context!(exit_matcher_parser)(context),
))(input)?;
Ok((remaining, ()))
}
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::*; use super::*;