Start of flat text element, not handling more complex types like bold and link.

feature_matrix
Tom Alexander 2 years ago
parent 30d6648590
commit ba25f5b5ca
Signed by: talexander
GPG Key ID: D3A179C9A53C0EDE

@ -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> {

@ -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)
}

Loading…
Cancel
Save