2022-07-16 03:26:49 +00:00
|
|
|
//! A single element of text.
|
|
|
|
use super::nom_context::NomContext;
|
2022-07-17 00:42:56 +00:00
|
|
|
// use super::parser_with_context::parser_with_context;
|
2022-07-16 03:26:49 +00:00
|
|
|
use super::text::line_break;
|
|
|
|
use super::text::space;
|
|
|
|
use super::text::span;
|
|
|
|
use super::text::symbol;
|
2022-07-17 00:42:56 +00:00
|
|
|
use super::text::Res;
|
2022-07-16 03:26:49 +00:00
|
|
|
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-17 00:42:56 +00:00
|
|
|
// parser_with_context!(text_element, TextElement, i, context, {
|
|
|
|
// // not(|j| {
|
|
|
|
// // // tood
|
|
|
|
// // (context.fail_matcher)(j)
|
|
|
|
// // })(i)?;
|
|
|
|
// // not(|i| (context.fail_matcher)(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)
|
|
|
|
// });
|
|
|
|
|
2022-07-17 01:16:34 +00:00
|
|
|
pub fn flat_text_element<'a, F>(
|
|
|
|
i: &'a str,
|
|
|
|
context: &mut NomContext<F>,
|
|
|
|
) -> Res<&'a str, TextElement<'a>>
|
2022-07-17 00:42:56 +00:00
|
|
|
where
|
2022-07-17 01:16:34 +00:00
|
|
|
F: for<'b> FnMut(&'b str) -> IResult<&'b str, &'b str, VerboseError<&'b str>>,
|
2022-07-17 00:42:56 +00:00
|
|
|
{
|
|
|
|
// not(context.fail_matcher)(i)?;
|
|
|
|
// todo
|
|
|
|
todo!()
|
|
|
|
}
|