From c958136949ef68de244326ae570c2b5d61c17c64 Mon Sep 17 00:00:00 2001 From: Tom Alexander Date: Fri, 14 Oct 2022 19:51:13 -0400 Subject: [PATCH] Looking at this again with fresh eyes. Going to remove the broken stuff to start with a simpler state. --- src/parser/text_element_parser.rs | 55 +++++++++++++++---------------- 1 file changed, 27 insertions(+), 28 deletions(-) diff --git a/src/parser/text_element_parser.rs b/src/parser/text_element_parser.rs index 0954dd83..24c193b6 100644 --- a/src/parser/text_element_parser.rs +++ b/src/parser/text_element_parser.rs @@ -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) -> 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) -> 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,