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

This commit is contained in:
Tom Alexander 2023-10-17 15:56:02 -04:00
parent b7442c1e92
commit a276ba70e0
Signed by: talexander
GPG Key ID: D3A179C9A53C0EDE
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((

View File

@ -243,6 +243,10 @@ pub(crate) fn org_line_ending(input: OrgSource<'_>) -> Res<OrgSource<'_>, OrgSou
}
/// Match the whitespace at the beginning of a line and give it an indentation level.
#[cfg_attr(
feature = "tracing",
tracing::instrument(ret, level = "debug", skip(context))
)]
pub(crate) fn indentation_level<'s>(
context: RefContext<'_, '_, '_, 's>,
input: OrgSource<'s>,