Initial setup for the parser.

This commit is contained in:
Tom Alexander
2022-07-15 23:26:49 -04:00
commit ee9e6297a6
13 changed files with 350 additions and 0 deletions

View File

@@ -0,0 +1,33 @@
//! A single element of text.
use super::nom_context::NomContext;
use super::parser_with_context::parser_with_context;
use super::text::line_break;
use super::text::space;
use super::text::span;
use super::text::symbol;
use super::text::TextElement;
use nom::branch::alt;
use nom::combinator::map;
use nom::combinator::not;
use nom::error::VerboseError;
use nom::IResult;
parser_with_context!(text_element, TextElement, i, context, {
not(|i| context.fail_matcher.borrow_mut().parse(i))(i)?;
alt((
// map(
// BoldParser::new(slf.context.fail_matcher.clone()),
// TextElement::Bold,
// ),
// map(
// LinkParser::new(slf.context.fail_matcher.clone()),
// TextElement::Link,
// ),
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)
});