Switch to a contextual bold start function.
This commit is contained in:
parent
88bf1b3d8b
commit
9dfca22b86
@ -118,6 +118,13 @@ pub fn context_paragraph_end<'s, 'r>(
|
|||||||
paragraph_end(input)
|
paragraph_end(input)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn context_bold_start<'s, 'r>(
|
||||||
|
context: Context<'r, 's>,
|
||||||
|
input: &'s str,
|
||||||
|
) -> Res<&'s str, &'s str> {
|
||||||
|
recognize(bold_start)(input)
|
||||||
|
}
|
||||||
|
|
||||||
pub fn context_bold_end<'s, 'r>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, &'s str> {
|
pub fn context_bold_end<'s, 'r>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, &'s str> {
|
||||||
recognize(bold_end)(input)
|
recognize(bold_end)(input)
|
||||||
}
|
}
|
||||||
@ -170,14 +177,14 @@ fn recognize_bold_end(input: &str) -> Res<&str, &str> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn flat_bold<'s, 'r>(context: Context<'r, 's>, i: &'s str) -> Res<&'s str, Bold<'s>> {
|
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.clone());
|
||||||
let nom_context =
|
let nom_context =
|
||||||
context.with_additional_node(ContextElement::FailMatcherNode(FailMatcherNode {
|
context.with_additional_node(ContextElement::FailMatcherNode(FailMatcherNode {
|
||||||
fail_matcher: ChainBehavior::AndParent(Some(&recognize_bold_end)),
|
fail_matcher: ChainBehavior::AndParent(Some(&recognize_bold_end)),
|
||||||
}));
|
}));
|
||||||
let (remaining, captured) = recognize(tuple((
|
let (remaining, captured) = recognize(tuple((bold_start, |i| {
|
||||||
bold_start,
|
context_many_till(&nom_context, flat_text_element, context_bold_end)(i)
|
||||||
|i| context_many_till(&nom_context, flat_text_element, context_bold_end)(i),
|
})))(i)?;
|
||||||
)))(i)?;
|
|
||||||
let ret = Bold { contents: captured };
|
let ret = Bold { contents: captured };
|
||||||
Ok((remaining, ret))
|
Ok((remaining, ret))
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user