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

This commit is contained in:
Tom Alexander 2022-10-15 14:04:24 -04:00
parent 30d6648590
commit ba25f5b5ca
Signed by: talexander
GPG Key ID: D3A179C9A53C0EDE
2 changed files with 15 additions and 2 deletions

View File

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

View File

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