diff --git a/src/parser/new_context.rs b/src/parser/new_context.rs index aae99535..360bdf25 100644 --- a/src/parser/new_context.rs +++ b/src/parser/new_context.rs @@ -102,16 +102,19 @@ where } } - pub fn with_additional_fail_matcher( - &'r self, - fail_matcher: &'r Matcher, - ) -> ContextTree<'r, FailMatcherNode> { - self.with_additional_node(FailMatcherNode { - fail_matcher: ChainBehavior::AndParent(Some(fail_matcher)) - }) - } + // pub fn with_additional_fail_matcher( + // &'r self, + // fail_matcher: &'r Matcher, + // ) -> ContextTree<'r, FailMatcherNode> { + // self.with_additional_node(FailMatcherNode { + // fail_matcher: ChainBehavior::AndParent(Some(fail_matcher)) + // }) + // } - pub fn check_fail_matcher<'s>(&'r self, i: &'s str) -> IResult<&'s str, &'s str, VerboseError<&'s str>> { + pub fn check_fail_matcher<'s>( + &'r self, + i: &'s str, + ) -> IResult<&'s str, &'s str, VerboseError<&'s str>> { todo!() } } diff --git a/src/parser/text_element_parser.rs b/src/parser/text_element_parser.rs index f261436e..3979482e 100644 --- a/src/parser/text_element_parser.rs +++ b/src/parser/text_element_parser.rs @@ -5,6 +5,7 @@ use std::rc::Rc; use crate::parser::parser_with_context::parser_with_context; use crate::parser::text::paragraph_end; +use super::new_context::ChainBehavior; use super::new_context::ContextElement; use super::new_context::ContextTree; use super::new_context::FailMatcherNode; @@ -97,7 +98,10 @@ where { // Add a not(eof) check because many_till cannot match a zero-length string not(eof)(i)?; - let paragraph_context = context.with_additional_fail_matcher(¶graph_end); + let paragraph_context = context.with_additional_node(FailMatcherNode { + fail_matcher: ChainBehavior::AndParent(Some(¶graph_end)), + }); + // let paragraph_context = context.with_additional_fail_matcher(¶graph_end); let text_element_parser = parser_with_context!(flat_text_element)(¶graph_context); let ret = context_many_till(¶graph_context, text_element_parser, paragraph_end)(i); // let ret = many_till(text_element_parser, paragraph_end)(i); @@ -136,7 +140,10 @@ fn flat_bold<'s, 'r, C>(context: &'r ContextTree<'r, C>, i: &'s str) -> Res<&'s where C: ContextElement, { - let new_context = context.with_additional_fail_matcher(&recognize_bold_end); + let new_context = context.with_additional_node(FailMatcherNode { + fail_matcher: ChainBehavior::AndParent(Some(&recognize_bold_end)), + }); + // let new_context = context.with_additional_fail_matcher(&recognize_bold_end); let text_element_parser = parser_with_context!(flat_text_element)(&new_context); let (remaining, captured) = recognize(tuple(( bold_start, @@ -154,7 +161,10 @@ fn flat_link<'s, 'r, C>(context: &'r ContextTree<'r, C>, i: &'s str) -> Res<&'s where C: ContextElement, { - let new_context = context.with_additional_fail_matcher(&recognize_link_end); + let new_context = context.with_additional_node(FailMatcherNode { + fail_matcher: ChainBehavior::AndParent(Some(&recognize_link_end)), + }); + // let new_context = context.with_additional_fail_matcher(&recognize_link_end); let text_element_parser = parser_with_context!(flat_text_element)(&new_context); let (remaining, captured) = recognize(tuple(( link_start,