Hmmm it seems to be building.
This commit is contained in:
parent
99b19410c5
commit
8357837571
@ -16,14 +16,17 @@ where
|
|||||||
pub can_match_link: bool,
|
pub can_match_link: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
// impl<'a, I, O, E> NomContext<'a, I, O, E> {
|
impl<F> NomContext<F>
|
||||||
// pub fn new(fail_matcher: &'a dyn FnMut(I) -> IResult<I, O, E>) -> Self {
|
where
|
||||||
// NomContext {
|
F: for<'a> FnMut(&'a str) -> IResult<&'a str, &'a str, VerboseError<&'a str>>,
|
||||||
// fail_matcher: fail_matcher,
|
{
|
||||||
// can_match_bold: true,
|
pub fn new(fail_matcher: F) -> Self {
|
||||||
// can_match_link: true,
|
NomContext {
|
||||||
// }
|
fail_matcher: fail_matcher,
|
||||||
// }
|
can_match_bold: true,
|
||||||
|
can_match_link: true,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// pub fn with_no_bold(&self) -> NomContext<I, O, E> {
|
// pub fn with_no_bold(&self) -> NomContext<I, O, E> {
|
||||||
// NomContext {
|
// NomContext {
|
||||||
@ -33,15 +36,15 @@ where
|
|||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// // pub fn with_additional_fail_matcher(&self, additional_matcher: G) -> NomContext<G, I, O, E>
|
// pub fn with_additional_fail_matcher(&self, additional_matcher: G) -> NomContext<G, I, O, E>
|
||||||
// // where
|
// where
|
||||||
// // G: for<'a> FnMut(I) -> IResult<I, O, E>,
|
// G: for<'a> FnMut(I) -> IResult<I, O, E>,
|
||||||
// // {
|
// {
|
||||||
// // let new_fail_matcher = alt((self.fail_matcher, additional_matcher));
|
// let new_fail_matcher = alt((self.fail_matcher, additional_matcher));
|
||||||
// // NomContext {
|
// NomContext {
|
||||||
// // fail_matcher: Rc::new(RefCell::new(new_fail_matcher)),
|
// fail_matcher: Rc::new(RefCell::new(new_fail_matcher)),
|
||||||
// // can_match_bold: self.can_match_bold,
|
// can_match_bold: self.can_match_bold,
|
||||||
// // can_match_link: self.can_match_link,
|
// can_match_link: self.can_match_link,
|
||||||
// // }
|
|
||||||
// // }
|
|
||||||
// }
|
// }
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
@ -16,10 +16,10 @@
|
|||||||
|
|
||||||
macro_rules! parser_with_context {
|
macro_rules! parser_with_context {
|
||||||
($target:ident) => {
|
($target:ident) => {
|
||||||
|context| {
|
move |mut context| {
|
||||||
|i| {
|
move |i| {
|
||||||
// todo
|
// todo
|
||||||
$target(i, context)
|
$target(i, &mut context)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -133,7 +133,7 @@ pub fn paragraph(input: &str) -> Res<&str, (Vec<TextElement>, &str)> {
|
|||||||
todo!()
|
todo!()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn paragraph_end(input: &str) -> Res<&str, &str> {
|
pub fn paragraph_end(input: &str) -> Res<&str, &str> {
|
||||||
recognize(tuple((map(line_break, TextElement::LineBreak), blank_line)))(input)
|
recognize(tuple((map(line_break, TextElement::LineBreak), blank_line)))(input)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,4 +1,7 @@
|
|||||||
//! A single element of text.
|
//! A single element of text.
|
||||||
|
use crate::parser::parser_with_context::parser_with_context;
|
||||||
|
use crate::parser::text::paragraph_end;
|
||||||
|
|
||||||
use super::nom_context::NomContext;
|
use super::nom_context::NomContext;
|
||||||
// use super::parser_with_context::parser_with_context;
|
// use super::parser_with_context::parser_with_context;
|
||||||
use super::text::line_break;
|
use super::text::line_break;
|
||||||
@ -11,6 +14,7 @@ use nom::branch::alt;
|
|||||||
use nom::combinator::map;
|
use nom::combinator::map;
|
||||||
use nom::combinator::not;
|
use nom::combinator::not;
|
||||||
use nom::error::VerboseError;
|
use nom::error::VerboseError;
|
||||||
|
use nom::multi::many_till;
|
||||||
use nom::IResult;
|
use nom::IResult;
|
||||||
|
|
||||||
// parser_with_context!(text_element, TextElement, i, context, {
|
// parser_with_context!(text_element, TextElement, i, context, {
|
||||||
@ -48,3 +52,9 @@ where
|
|||||||
// todo
|
// todo
|
||||||
todo!()
|
todo!()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn paragraph(input: &str) -> Res<&str, (Vec<TextElement>, &str)> {
|
||||||
|
let initial_context = NomContext::new(¶graph_end);
|
||||||
|
let text_element_parser = parser_with_context!(flat_text_element)(initial_context);
|
||||||
|
many_till(text_element_parser, paragraph_end)(input)
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user