2022-07-16 03:26:49 +00:00
|
|
|
//! 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;
|
|
|
|
|
2022-07-16 22:18:41 +00:00
|
|
|
parser_with_context!(text_element, TextElement, i, context, {
|
2022-07-16 22:09:43 +00:00
|
|
|
// not(|i| (context.fail_matcher)(i))(i)?;
|
2022-07-16 03:26:49 +00:00
|
|
|
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)
|
|
|
|
});
|