Looking at this again with fresh eyes.

Going to remove the broken stuff to start with a simpler state.
This commit is contained in:
Tom Alexander 2022-10-14 19:51:13 -04:00
parent d23f7ce7fe
commit c958136949
Signed by: talexander
GPG Key ID: D3A179C9A53C0EDE
1 changed files with 27 additions and 28 deletions

View File

@ -30,14 +30,14 @@ where
+ std::clone::Clone, + std::clone::Clone,
{ {
not(&mut context.fail_matcher)(i)?; not(&mut context.fail_matcher)(i)?;
if context.can_match_bold { // if context.can_match_bold {
if let Ok(v) = parser_with_context!(flat_bold)(context.clone())(i) { // if let Ok(v) = parser_with_context!(flat_bold)(context.clone())(i) {
return Ok(v); // return Ok(v);
} // }
} // }
if context.can_match_link { // if context.can_match_link {
// todo // // todo
} // }
alt(( alt((
map(span, TextElement::Span), map(span, TextElement::Span),
map(symbol("*"), TextElement::Symbol), map(symbol("*"), TextElement::Symbol),
@ -48,26 +48,25 @@ where
))(i) ))(i)
} }
#[inline(always)] // pub fn flat_bold<'a, F>(i: &'a str, context: &mut NomContext<F>) -> Res<&'a str, TextElement<'a>>
pub fn flat_bold<'a, F>(i: &'a str, context: &mut NomContext<F>) -> Res<&'a str, TextElement<'a>> // where
where // F: for<'b> FnMut(&'b str) -> IResult<&'b str, &'b str, VerboseError<&'b str>>,
F: for<'b> FnMut(&'b str) -> IResult<&'b str, &'b str, VerboseError<&'b str>>, // F: Clone,
F: Clone, // {
{ // not(&mut context.fail_matcher)(i)?;
not(&mut context.fail_matcher)(i)?; // let new_context = context
let new_context = context // .without_bold()
.without_bold() // .with_additional_fail_matcher(|i| recognize(bold_end)(i));
.with_additional_fail_matcher(|i| recognize(bold_end)(i)); // let text_element_parser = parser_with_context!(flat_text_element)(new_context);
let text_element_parser = parser_with_context!(flat_text_element)(new_context); // map(
map( // recognize(tuple((
recognize(tuple(( // bold_start,
bold_start, // many_till(text_element_parser, bold_end),
many_till(text_element_parser, bold_end), // bold_end,
bold_end, // ))),
))), // |body| TextElement::Bold(Bold { contents: body }),
|body| TextElement::Bold(Bold { contents: body }), // )(i)
)(i) // }
}
pub fn paragraph<'a, F>( pub fn paragraph<'a, F>(
i: &'a str, i: &'a str,