Fix handling fixed width area post-blank inside a list.
This commit is contained in:
parent
e846c85188
commit
30412361e1
@ -0,0 +1,6 @@
|
||||
1. foo
|
||||
#+begin_src text
|
||||
|
||||
#+end_src
|
||||
|
||||
2. baz
|
@ -14,7 +14,7 @@ use nom::InputTake;
|
||||
|
||||
use super::affiliated_keyword::parse_affiliated_keywords;
|
||||
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 crate::context::parser_with_context;
|
||||
use crate::context::RefContext;
|
||||
@ -48,8 +48,11 @@ where
|
||||
),
|
||||
))(remaining)?;
|
||||
|
||||
let (remaining, post_blank) =
|
||||
maybe_consume_trailing_whitespace_if_not_exiting_mid_line(context, remaining)?;
|
||||
let post_blank_begin = 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 mut value = Vec::with_capacity(remaining_lines.len() + 1);
|
||||
value.push(Into::<&str>::into(first_line));
|
||||
@ -63,7 +66,11 @@ where
|
||||
affiliated_keywords,
|
||||
),
|
||||
value,
|
||||
post_blank: post_blank.map(Into::<&str>::into),
|
||||
post_blank: if post_blank.len() > 0 {
|
||||
Some(Into::<&str>::into(post_blank))
|
||||
} else {
|
||||
None
|
||||
},
|
||||
},
|
||||
))
|
||||
}
|
||||
|
@ -72,13 +72,6 @@ fn element_trailing_whitespace<'s>(input: OrgSource<'s>) -> Res<OrgSource<'s>, O
|
||||
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(
|
||||
feature = "tracing",
|
||||
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(
|
||||
feature = "tracing",
|
||||
tracing::instrument(ret, level = "debug", skip(context))
|
||||
|
Loading…
Reference in New Issue
Block a user