Pass context into paragraph from document instead of generating the initial context at paragraph level.

This commit is contained in:
Tom Alexander
2022-07-17 18:40:05 -04:00
parent e5af567981
commit 70688c8d51
3 changed files with 14 additions and 11 deletions

View File

@@ -24,6 +24,7 @@ use nom::sequence::tuple;
use nom::IResult;
use super::nom_context::NomContext;
use super::parser_with_context::parser_with_context;
use super::text_element_parser::paragraph;
pub type Res<T, U> = IResult<T, U, VerboseError<T>>;
@@ -139,5 +140,6 @@ pub fn paragraph_end(input: &str) -> Res<&str, &str> {
}
pub fn document(input: &str) -> Res<&str, Vec<(Vec<TextElement>, &str)>> {
many1(paragraph)(input)
let initial_context = NomContext::new(&paragraph_end);
many1(parser_with_context!(paragraph)(initial_context))(input)
}