Fix handling fixed width area post-blank inside a list.

This commit is contained in:
Tom Alexander 2023-12-15 19:19:58 -05:00
parent e846c85188
commit 30412361e1
Signed by: talexander
GPG Key ID: D3A179C9A53C0EDE
3 changed files with 17 additions and 27 deletions

View File

@ -0,0 +1,6 @@
1. foo
#+begin_src text
#+end_src
2. baz

View File

@ -14,7 +14,7 @@ use nom::InputTake;
use super::affiliated_keyword::parse_affiliated_keywords; use super::affiliated_keyword::parse_affiliated_keywords;
use super::org_source::OrgSource; use super::org_source::OrgSource;
use super::util::maybe_consume_trailing_whitespace_if_not_exiting_mid_line; use super::util::maybe_consume_trailing_whitespace_if_not_exiting;
use super::util::org_line_ending; use super::util::org_line_ending;
use crate::context::parser_with_context; use crate::context::parser_with_context;
use crate::context::RefContext; use crate::context::RefContext;
@ -48,8 +48,11 @@ where
), ),
))(remaining)?; ))(remaining)?;
let (remaining, post_blank) = let post_blank_begin = remaining;
maybe_consume_trailing_whitespace_if_not_exiting_mid_line(context, remaining)?; let (remaining, _first_line_break) = org_line_ending(remaining)?;
let (remaining, _additional_post_blank) =
maybe_consume_trailing_whitespace_if_not_exiting(context, remaining)?;
let post_blank = get_consumed(post_blank_begin, remaining);
let source = get_consumed(input, remaining); let source = get_consumed(input, remaining);
let mut value = Vec::with_capacity(remaining_lines.len() + 1); let mut value = Vec::with_capacity(remaining_lines.len() + 1);
value.push(Into::<&str>::into(first_line)); value.push(Into::<&str>::into(first_line));
@ -63,7 +66,11 @@ where
affiliated_keywords, affiliated_keywords,
), ),
value, value,
post_blank: post_blank.map(Into::<&str>::into), post_blank: if post_blank.len() > 0 {
Some(Into::<&str>::into(post_blank))
} else {
None
},
}, },
)) ))
} }

View File

@ -72,13 +72,6 @@ fn element_trailing_whitespace<'s>(input: OrgSource<'s>) -> Res<OrgSource<'s>, O
alt((eof, recognize(many0(blank_line))))(input) alt((eof, recognize(many0(blank_line))))(input)
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
fn element_trailing_whitespace_mid_line<'s>(
input: OrgSource<'s>,
) -> Res<OrgSource<'s>, OrgSource<'s>> {
alt((eof, recognize(many0(blank_line))))(input)
}
#[cfg_attr( #[cfg_attr(
feature = "tracing", feature = "tracing",
tracing::instrument(ret, level = "debug", skip(context)) tracing::instrument(ret, level = "debug", skip(context))
@ -121,22 +114,6 @@ pub(crate) fn maybe_consume_trailing_whitespace_if_not_exiting<'b, 'g, 'r, 's>(
} }
} }
#[cfg_attr(
feature = "tracing",
tracing::instrument(ret, level = "debug", skip(context))
)]
pub(crate) fn maybe_consume_trailing_whitespace_if_not_exiting_mid_line<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>,
) -> Res<OrgSource<'s>, Option<OrgSource<'s>>> {
if context.should_consume_trailing_whitespace() && exit_matcher_parser(context, input).is_err()
{
Ok(opt(element_trailing_whitespace_mid_line)(input)?)
} else {
Ok((input, None))
}
}
#[cfg_attr( #[cfg_attr(
feature = "tracing", feature = "tracing",
tracing::instrument(ret, level = "debug", skip(context)) tracing::instrument(ret, level = "debug", skip(context))