diff --git a/src/parser/nom_context.rs b/src/parser/nom_context.rs index 18946adc..94fa26a2 100644 --- a/src/parser/nom_context.rs +++ b/src/parser/nom_context.rs @@ -2,6 +2,7 @@ use std::cell::RefCell; use std::rc::Rc; use nom::branch::alt; +use nom::combinator::not; use nom::error::VerboseError; use nom::IResult; use nom::Parser; @@ -47,6 +48,10 @@ impl<'a> NomContext<'a> { can_match_link: self.can_match_link, } } + + pub fn not_matching_fail<'s>(&self, i: &'s str) -> IResult<&'s str, (), VerboseError<&'s str>> { + not(FailChecker::new(self))(i) + } } impl<'a, 'b> Parser<&'b str, &'b str, VerboseError<&'b str>> for FailChecker<'a> { diff --git a/src/parser/text_element_parser.rs b/src/parser/text_element_parser.rs index d3681943..d31ab201 100644 --- a/src/parser/text_element_parser.rs +++ b/src/parser/text_element_parser.rs @@ -25,6 +25,14 @@ fn flat_text_element<'s, 'r>( i: &'s str, context: &'r mut NomContext, ) -> Res<&'s str, TextElement<'s>> { - // not(&mut context.fail_matcher)(i)?; - todo!() + context.not_matching_fail(i)?; + + alt(( + map(span, TextElement::Span), + map(symbol("*"), TextElement::Symbol), + map(symbol("["), TextElement::Symbol), + map(symbol("]"), TextElement::Symbol), + map(space, TextElement::Space), + map(line_break, TextElement::LineBreak), + ))(i) }