Initial setup for the parser.
This commit is contained in:
33
src/parser/text_element_parser.rs
Normal file
33
src/parser/text_element_parser.rs
Normal 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)
|
||||
});
|
||||
Reference in New Issue
Block a user