From 2b0e88dc01395a7208349c52dc7e7a954d6b899c Mon Sep 17 00:00:00 2001 From: Tom Alexander Date: Fri, 31 Mar 2023 13:08:53 -0400 Subject: [PATCH] The current problem is plain_list_item_end is not taking into account depth. --- src/parser/paragraph.rs | 10 +++++++--- src/parser/plain_list.rs | 4 ++-- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/parser/paragraph.rs b/src/parser/paragraph.rs index 764b646f..bea09086 100644 --- a/src/parser/paragraph.rs +++ b/src/parser/paragraph.rs @@ -1,6 +1,7 @@ use nom::branch::alt; use nom::character::complete::line_ending; use nom::combinator::eof; +use nom::combinator::peek; use nom::combinator::recognize; use nom::combinator::verify; use nom::multi::many1; @@ -32,7 +33,10 @@ pub fn paragraph<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s st let exit_matcher = parser_with_context!(exit_matcher_parser)(&parser_context); let (remaining, (children, _exit_contents)) = verify( - many_till(standard_set_object_matcher, exit_matcher), + many_till( + standard_set_object_matcher, + peek(alt((eof, recognize(tuple((line_ending, exit_matcher)))))), + ), |(children, _exit_contents)| !children.is_empty(), )(input)?; @@ -46,8 +50,8 @@ pub fn paragraph<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s st fn paragraph_end<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, &'s str> { let non_paragraph_element_matcher = parser_with_context!(non_paragraph_element)(context); alt(( - recognize(tuple((line_ending, many1(blank_line)))), - recognize(tuple((line_ending, non_paragraph_element_matcher))), + recognize(many1(blank_line)), + recognize(non_paragraph_element_matcher), eof, ))(input) } diff --git a/src/parser/plain_list.rs b/src/parser/plain_list.rs index 9e314286..2abc7ee1 100644 --- a/src/parser/plain_list.rs +++ b/src/parser/plain_list.rs @@ -97,8 +97,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 line_indented_lte_matcher = parser_with_context!(line_indented_lte)(context); alt(( - recognize(tuple((line_ending, plain_list_item_matcher))), - recognize(tuple((line_ending, line_indented_lte_matcher))), + recognize(plain_list_item_matcher), + recognize(line_indented_lte_matcher), eof, ))(input) }