Pass context into paragraph from document instead of generating the initial context at paragraph level.
This commit is contained in:
@@ -74,8 +74,14 @@ where
|
||||
)(i)
|
||||
}
|
||||
|
||||
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)
|
||||
pub fn paragraph<'a, F>(
|
||||
i: &'a str,
|
||||
context: &mut NomContext<F>,
|
||||
) -> Res<&'a str, (Vec<TextElement<'a>>, &'a str)>
|
||||
where
|
||||
F: for<'b> FnMut(&'b str) -> IResult<&'b str, &'b str, VerboseError<&'b str>>,
|
||||
F: Clone,
|
||||
{
|
||||
let text_element_parser = parser_with_context!(flat_text_element)(context.clone());
|
||||
many_till(text_element_parser, paragraph_end)(i)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user