The current problem is whitespace at the end of a list item should not be consumed.
This commit is contained in:
parent
3d8fe253c9
commit
3643f91bac
@ -2,7 +2,9 @@ use nom::branch::alt;
|
|||||||
use nom::character::complete::line_ending;
|
use nom::character::complete::line_ending;
|
||||||
use nom::combinator::eof;
|
use nom::combinator::eof;
|
||||||
use nom::combinator::recognize;
|
use nom::combinator::recognize;
|
||||||
|
use nom::combinator::verify;
|
||||||
use nom::multi::many1;
|
use nom::multi::many1;
|
||||||
|
use nom::multi::many_till;
|
||||||
use nom::sequence::tuple;
|
use nom::sequence::tuple;
|
||||||
|
|
||||||
use crate::parser::object::standard_set_object;
|
use crate::parser::object::standard_set_object;
|
||||||
@ -10,6 +12,7 @@ use crate::parser::parser_context::ChainBehavior;
|
|||||||
use crate::parser::parser_context::ContextElement;
|
use crate::parser::parser_context::ContextElement;
|
||||||
use crate::parser::parser_context::ExitMatcherNode;
|
use crate::parser::parser_context::ExitMatcherNode;
|
||||||
use crate::parser::parser_with_context::parser_with_context;
|
use crate::parser::parser_with_context::parser_with_context;
|
||||||
|
use crate::parser::util::exit_matcher_parser;
|
||||||
|
|
||||||
use super::element::non_paragraph_element;
|
use super::element::non_paragraph_element;
|
||||||
use super::error::Res;
|
use super::error::Res;
|
||||||
@ -26,8 +29,12 @@ pub fn paragraph<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s st
|
|||||||
exit_matcher: ChainBehavior::AndParent(Some(¶graph_end)),
|
exit_matcher: ChainBehavior::AndParent(Some(¶graph_end)),
|
||||||
}));
|
}));
|
||||||
let standard_set_object_matcher = parser_with_context!(standard_set_object)(&parser_context);
|
let standard_set_object_matcher = parser_with_context!(standard_set_object)(&parser_context);
|
||||||
|
let exit_matcher = parser_with_context!(exit_matcher_parser)(&parser_context);
|
||||||
|
|
||||||
let (remaining, children) = many1(standard_set_object_matcher)(input)?;
|
let (remaining, (children, _exit_contents)) = verify(
|
||||||
|
many_till(standard_set_object_matcher, exit_matcher),
|
||||||
|
|(children, _exit_contents)| !children.is_empty(),
|
||||||
|
)(input)?;
|
||||||
|
|
||||||
let (remaining, _trailing_whitespace) = trailing_whitespace(remaining)?;
|
let (remaining, _trailing_whitespace) = trailing_whitespace(remaining)?;
|
||||||
|
|
||||||
|
@ -16,6 +16,7 @@ use crate::parser::util::start_of_line;
|
|||||||
use nom::branch::alt;
|
use nom::branch::alt;
|
||||||
use nom::bytes::complete::tag;
|
use nom::bytes::complete::tag;
|
||||||
use nom::character::complete::digit1;
|
use nom::character::complete::digit1;
|
||||||
|
use nom::character::complete::line_ending;
|
||||||
use nom::character::complete::one_of;
|
use nom::character::complete::one_of;
|
||||||
use nom::character::complete::space0;
|
use nom::character::complete::space0;
|
||||||
use nom::combinator::eof;
|
use nom::combinator::eof;
|
||||||
@ -94,8 +95,8 @@ fn plain_list_item_end<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<
|
|||||||
let plain_list_item_matcher = parser_with_context!(plain_list_item)(context);
|
let plain_list_item_matcher = parser_with_context!(plain_list_item)(context);
|
||||||
let line_indented_lte_matcher = parser_with_context!(line_indented_lte)(context);
|
let line_indented_lte_matcher = parser_with_context!(line_indented_lte)(context);
|
||||||
alt((
|
alt((
|
||||||
recognize(plain_list_item_matcher),
|
recognize(tuple((line_ending, plain_list_item_matcher))),
|
||||||
line_indented_lte_matcher,
|
recognize(tuple((line_ending, line_indented_lte_matcher))),
|
||||||
eof,
|
eof,
|
||||||
))(input)
|
))(input)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user