Fix handling line breaks after divider in description lists.
This commit is contained in:
parent
45be9e7bde
commit
a6d742a536
@ -0,0 +1,2 @@
|
||||
- foo ::
|
||||
|
@ -6,3 +6,6 @@
|
||||
-
|
||||
lorem :: ipsum
|
||||
- dolar *bold* foo :: ipsum
|
||||
- big gap ::
|
||||
|
||||
stuff
|
||||
|
@ -6,9 +6,12 @@ use nom::character::complete::one_of;
|
||||
use nom::character::complete::space0;
|
||||
use nom::character::complete::space1;
|
||||
use nom::combinator::eof;
|
||||
use nom::combinator::not;
|
||||
use nom::combinator::opt;
|
||||
use nom::combinator::peek;
|
||||
use nom::combinator::recognize;
|
||||
use nom::combinator::verify;
|
||||
use nom::multi::many0;
|
||||
use nom::multi::many1;
|
||||
use nom::multi::many_till;
|
||||
use nom::sequence::tuple;
|
||||
@ -163,7 +166,7 @@ pub fn plain_list_item<'r, 's>(
|
||||
parser_with_context!(item_tag)(context),
|
||||
tag(" ::"),
|
||||
)))(remaining)?;
|
||||
let (remaining, _ws) = alt((space1, line_ending))(remaining)?;
|
||||
let (remaining, _ws) = item_tag_post_gap(context, remaining)?;
|
||||
let exit_matcher = plain_list_item_end(indent_level);
|
||||
let parser_context = context
|
||||
.with_additional_node(ContextElement::ConsumeTrailingWhitespace(true))
|
||||
@ -174,7 +177,10 @@ pub fn plain_list_item<'r, 's>(
|
||||
|
||||
let (remaining, (children, _exit_contents)) = many_till(
|
||||
parser_with_context!(element(true))(&parser_context),
|
||||
parser_with_context!(exit_matcher_parser)(&parser_context),
|
||||
alt((
|
||||
peek(recognize(tuple((start_of_line, many0(blank_line), eof)))),
|
||||
parser_with_context!(exit_matcher_parser)(&parser_context),
|
||||
)),
|
||||
)(remaining)?;
|
||||
|
||||
let (remaining, _trailing_ws) =
|
||||
@ -189,7 +195,7 @@ pub fn plain_list_item<'r, 's>(
|
||||
bullet: bull.into(),
|
||||
tag: maybe_tag
|
||||
.map(|(_ws, item_tag, _divider)| item_tag)
|
||||
.unwrap_or(Vec::new()), // TODO
|
||||
.unwrap_or(Vec::new()),
|
||||
children,
|
||||
},
|
||||
));
|
||||
@ -305,6 +311,27 @@ fn item_tag_end<'r, 's>(
|
||||
)))(input)
|
||||
}
|
||||
|
||||
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||
fn item_tag_post_gap<'r, 's>(
|
||||
context: Context<'r, 's>,
|
||||
input: OrgSource<'s>,
|
||||
) -> Res<OrgSource<'s>, OrgSource<'s>> {
|
||||
verify(
|
||||
recognize(tuple((
|
||||
alt((blank_line, space0)),
|
||||
many_till(
|
||||
blank_line,
|
||||
alt((
|
||||
peek(recognize(not(blank_line))),
|
||||
peek(recognize(tuple((many0(blank_line), eof)))),
|
||||
parser_with_context!(exit_matcher_parser)(context),
|
||||
)),
|
||||
),
|
||||
))),
|
||||
|gap| gap.len() > 0,
|
||||
)(input)
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
Loading…
Reference in New Issue
Block a user