From 412bdcda288b4e2f527a20ea6690cdca3f9c005c Mon Sep 17 00:00:00 2001 From: Tom Alexander Date: Fri, 14 Apr 2023 23:56:55 -0400 Subject: [PATCH] Fix problem with detecting end of plain list item. The problem is line indented lte does not match because we aren't consuming the whitespace that the plain list would consume. --- src/parser/plain_list.rs | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/parser/plain_list.rs b/src/parser/plain_list.rs index 20d5cf1..133015c 100644 --- a/src/parser/plain_list.rs +++ b/src/parser/plain_list.rs @@ -28,6 +28,8 @@ use nom::combinator::recognize; use nom::combinator::verify; use nom::multi::many1; use nom::multi::many_till; +use nom::sequence::preceded; +use nom::sequence::terminated; use nom::sequence::tuple; use tracing::span; @@ -180,11 +182,16 @@ pub fn plain_list_item<'r, 's>( } Err(_) => { let (remaining, _ws) = space1(remaining)?; - let (remaining, (mut contents, (final_element, _exit_contents))) = - many_till( - with_consume_matcher, - tuple((without_consume_matcher, exit_matcher)), - )(remaining)?; + let (remaining, (mut contents, final_element)) = many_till( + with_consume_matcher, + alt(( + terminated(without_consume_matcher, exit_matcher), + preceded( + peek(tuple((with_consume_matcher, exit_matcher))), + without_consume_matcher, + ), + )), + )(remaining)?; contents.push(final_element); let source = get_consumed(input, remaining); return Ok((