Removed one wrapper.

This commit is contained in:
Tom Alexander 2022-11-27 00:35:38 -05:00
parent 7d25628f74
commit 8608136124
Signed by: talexander
GPG Key ID: D3A179C9A53C0EDE
2 changed files with 25 additions and 12 deletions

View File

@ -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!()
}
}

View File

@ -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(&paragraph_end);
let paragraph_context = context.with_additional_node(FailMatcherNode {
fail_matcher: ChainBehavior::AndParent(Some(&paragraph_end)),
});
// let paragraph_context = context.with_additional_fail_matcher(&paragraph_end);
let text_element_parser = parser_with_context!(flat_text_element)(&paragraph_context);
let ret = context_many_till(&paragraph_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,