I need to prevent matching bold inside a bold.

This commit is contained in:
Tom Alexander 2022-12-15 21:14:49 -05:00
parent b27be8eab1
commit 0c676c44c2
Signed by: talexander
GPG Key ID: D3A179C9A53C0EDE
1 changed files with 1 additions and 5 deletions

View File

@ -222,15 +222,11 @@ fn flat_text_element<'s, 'r>(
))(i)
}
fn recognize_bold_end<'s, 'r>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, &'s str> {
recognize(bold_end)(input)
}
fn flat_bold<'s, 'r>(context: Context<'r, 's>, i: &'s str) -> Res<&'s str, Bold<'s>> {
let bold_start = parser_with_context!(context_bold_start)(&context);
let nom_context =
context.with_additional_node(ContextElement::FailMatcherNode(FailMatcherNode {
fail_matcher: ChainBehavior::AndParent(Some(&recognize_bold_end)),
fail_matcher: ChainBehavior::AndParent(Some(&context_bold_end)),
}));
let (remaining, captured) = recognize(tuple((bold_start, |i| {
context_many_till(&nom_context, flat_text_element, context_bold_end)(i)