Update flat_bold to context_many_till.

This commit is contained in:
Tom Alexander 2022-12-11 00:33:40 -05:00
parent 972ffa6345
commit 88bf1b3d8b
Signed by: talexander
GPG Key ID: D3A179C9A53C0EDE
1 changed files with 5 additions and 3 deletions

View File

@ -118,6 +118,10 @@ pub fn context_paragraph_end<'s, 'r>(
paragraph_end(input)
}
pub fn context_bold_end<'s, 'r>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, &'s str> {
recognize(bold_end)(input)
}
pub fn paragraph<'s, 'r>(
context: Context<'r, 's>,
i: &'s str,
@ -170,11 +174,9 @@ fn flat_bold<'s, 'r>(context: Context<'r, 's>, i: &'s str) -> Res<&'s str, Bold<
context.with_additional_node(ContextElement::FailMatcherNode(FailMatcherNode {
fail_matcher: ChainBehavior::AndParent(Some(&recognize_bold_end)),
}));
// let nom_context = context.with_additional_fail_matcher(&recognize_bold_end);
let text_element_parser = parser_with_context!(flat_text_element)(nom_context);
let (remaining, captured) = recognize(tuple((
bold_start,
many_till(text_element_parser, bold_end),
|i| context_many_till(&nom_context, flat_text_element, context_bold_end)(i),
)))(i)?;
let ret = Bold { contents: captured };
Ok((remaining, ret))