The current problem is plain_list_item_end is not taking into account depth.

This commit is contained in:
Tom Alexander 2023-03-31 13:08:53 -04:00
parent 68156f3667
commit 2b0e88dc01
Signed by: talexander
GPG Key ID: D3A179C9A53C0EDE
2 changed files with 9 additions and 5 deletions

View File

@ -1,6 +1,7 @@
use nom::branch::alt; 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::peek;
use nom::combinator::recognize; use nom::combinator::recognize;
use nom::combinator::verify; use nom::combinator::verify;
use nom::multi::many1; 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 exit_matcher = parser_with_context!(exit_matcher_parser)(&parser_context);
let (remaining, (children, _exit_contents)) = verify( 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(), |(children, _exit_contents)| !children.is_empty(),
)(input)?; )(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> { 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); let non_paragraph_element_matcher = parser_with_context!(non_paragraph_element)(context);
alt(( alt((
recognize(tuple((line_ending, many1(blank_line)))), recognize(many1(blank_line)),
recognize(tuple((line_ending, non_paragraph_element_matcher))), recognize(non_paragraph_element_matcher),
eof, eof,
))(input) ))(input)
} }

View File

@ -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 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(tuple((line_ending, plain_list_item_matcher))), recognize(plain_list_item_matcher),
recognize(tuple((line_ending, line_indented_lte_matcher))), recognize(line_indented_lte_matcher),
eof, eof,
))(input) ))(input)
} }