Fix empty content items with final item whitespace cut-off before headlines.
Some checks failed
clippy Build clippy has succeeded
rust-foreign-document-test Build rust-foreign-document-test has failed
rust-build Build rust-build has succeeded
rust-test Build rust-test has succeeded

This commit is contained in:
Tom Alexander
2023-10-17 15:56:02 -04:00
parent b7442c1e92
commit a276ba70e0
2 changed files with 15 additions and 4 deletions

View File

@@ -113,7 +113,9 @@ pub(crate) fn detect_not_plain_list_item_indent<'b, 'g, 'r, 's>(
alt((space1, line_ending, eof)),
)),
)),
|(_, (depth, bullet), (_, _))| *depth == 0 && Into::<&str>::into(bullet).starts_with('*'),
|(_, (depth, _), ((_, bullet), _))| {
*depth == 0 && Into::<&str>::into(bullet).starts_with('*')
},
)(input)
{
return Ok((input, indent));
@@ -263,10 +265,15 @@ fn plain_list_item<'b, 'g, 'r, 's>(
let maybe_contentless_item: Res<OrgSource<'_>, ()> =
detect_contentless_item_contents(&parser_context, remaining);
if let Ok((_rem, _ws)) = maybe_contentless_item {
let (remaining, _trailing_ws) = if context.should_consume_trailing_whitespace() {
recognize(alt((recognize(many1(blank_line)), eof)))(remaining)?
} else {
let (remaining, _trailing_ws) = if tuple((
blank_line,
bind_context!(final_item_whitespace_cutoff, context),
))(remaining)
.is_ok()
{
recognize(alt((blank_line, eof)))(remaining)?
} else {
recognize(alt((recognize(many1(blank_line)), eof)))(remaining)?
};
let source = get_consumed(input, remaining);
return Ok((