From 1f11bfa2ec3ac7b58d243be6915c55bf46ee198f Mon Sep 17 00:00:00 2001 From: Tom Alexander Date: Mon, 11 Sep 2023 10:13:22 -0400 Subject: [PATCH] Join the plain list item tag end matchers again. --- src/context/context.rs | 2 +- src/context/exiting.rs | 1 - src/parser/plain_list.rs | 38 +++++++++++++------------------------- 3 files changed, 14 insertions(+), 27 deletions(-) diff --git a/src/context/context.rs b/src/context/context.rs index a485cdf7..0baa2e8b 100644 --- a/src/context/context.rs +++ b/src/context/context.rs @@ -108,7 +108,7 @@ impl<'g, 'r, 's> Context<'g, 'r, 's> { &'r self, i: OrgSource<'s>, ) -> IResult, OrgSource<'s>, CustomError>> { - let mut current_class_filter = ExitClass::Delta; + let mut current_class_filter = ExitClass::Gamma; for current_node in self.iter_context() { let context_element = current_node.get_data(); match context_element { diff --git a/src/context/exiting.rs b/src/context/exiting.rs index c989a335..44585c99 100644 --- a/src/context/exiting.rs +++ b/src/context/exiting.rs @@ -4,7 +4,6 @@ pub enum ExitClass { Alpha = 2, Beta = 3, Gamma = 4, - Delta = 5, } impl std::fmt::Display for ExitClass { diff --git a/src/parser/plain_list.rs b/src/parser/plain_list.rs index 4f4bc498..73c92d59 100644 --- a/src/parser/plain_list.rs +++ b/src/parser/plain_list.rs @@ -301,18 +301,11 @@ fn item_tag<'b, 'g, 'r, 's>( context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, Vec>> { - let contexts = [ - ContextElement::ExitMatcherNode(ExitMatcherNode { - class: ExitClass::Gamma, - exit_matcher: &item_tag_line_ending_end, - }), - ContextElement::ExitMatcherNode(ExitMatcherNode { - class: ExitClass::Delta, - exit_matcher: &item_tag_end, - }), - ]; - let parser_context = context.with_additional_node(&contexts[0]); - let parser_context = parser_context.with_additional_node(&contexts[1]); + let parser_context = ContextElement::ExitMatcherNode(ExitMatcherNode { + class: ExitClass::Gamma, + exit_matcher: &item_tag_end, + }); + let parser_context = context.with_additional_node(&parser_context); let (remaining, (children, _exit_contents)) = verify( many_till( // TODO: Should this be using a different set like the minimal set? @@ -330,19 +323,14 @@ fn item_tag_end<'b, 'g, 'r, 's>( _context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, OrgSource<'s>> { - recognize(tuple(( - one_of(" \t"), - tag("::"), - alt((recognize(one_of(" \t")), line_ending, eof)), - )))(input) -} - -#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -fn item_tag_line_ending_end<'b, 'g, 'r, 's>( - _context: RefContext<'b, 'g, 'r, 's>, - input: OrgSource<'s>, -) -> Res, OrgSource<'s>> { - line_ending(input) + alt(( + recognize(tuple(( + one_of(" \t"), + tag("::"), + alt((recognize(one_of(" \t")), line_ending, eof)), + ))), + line_ending, + ))(input) } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]