From 2552ba28d11eb2c7e7063f1fa01a879d88c5c89b Mon Sep 17 00:00:00 2001 From: Tom Alexander Date: Mon, 3 Apr 2023 15:06:12 -0400 Subject: [PATCH] Correctly parsing plain list items. --- src/parser/plain_list.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/parser/plain_list.rs b/src/parser/plain_list.rs index 2abc7ee..9911f3f 100644 --- a/src/parser/plain_list.rs +++ b/src/parser/plain_list.rs @@ -94,10 +94,16 @@ fn counter<'s>(i: &'s str) -> Res<&'s str, &'s str> { #[tracing::instrument(ret, level = "debug")] fn plain_list_item_end<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, &'s str> { + let current_item_indent_level: &usize = + get_context_item_indent(context).ok_or(nom::Err::Error(CustomError::MyError(MyError( + "Not inside a plain list item", + ))))?; 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(plain_list_item_matcher), + recognize(verify(plain_list_item_matcher, |pli| { + pli.indentation <= *current_item_indent_level + })), recognize(line_indented_lte_matcher), eof, ))(input)