diff --git a/src/main.rs b/src/main.rs index 70abb81..2ac52e5 100644 --- a/src/main.rs +++ b/src/main.rs @@ -23,7 +23,7 @@ fn main() -> Result<(), Box> { // let parsed = document(TEST_DOC); // println!("{}\n\n\n", TEST_DOC); let initial_context: ContextTree<'_, '_> = ContextTree::new(); - let parsed = item(&initial_context, " 1. foo\n"); + let parsed = item(&initial_context, " 1. foo\n2. bar"); println!("{:#?}", parsed); Ok(()) } diff --git a/src/parser/plain_list.rs b/src/parser/plain_list.rs index c226c87..5175322 100644 --- a/src/parser/plain_list.rs +++ b/src/parser/plain_list.rs @@ -8,6 +8,7 @@ use nom::character::complete::space0; use nom::combinator::consumed; use nom::combinator::not; use nom::combinator::opt; +use nom::combinator::peek; use nom::combinator::recognize; use nom::multi::many0_count; use nom::multi::many1; @@ -17,6 +18,7 @@ use super::combinator::context_many_till; use super::error::Res; use super::paragraph::paragraph_end; use super::parser_context::ContextElement; +use super::parser_with_context::parser_with_context; use super::text::space; use super::text::text_element; use super::token::ListItem; @@ -107,5 +109,9 @@ fn tag_separator<'s>(i: &'s str) -> Res<&'s str, &'s str> { } pub fn item_end<'r, 's>(context: Context<'r, 's>, i: &'s str) -> Res<&'s str, &'s str> { - paragraph_end(i) + let item_matcher = parser_with_context!(item)(&context); + alt(( + paragraph_end, + recognize(tuple((line_ending, peek(item_matcher)))), + ))(i) }