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