Separate out calls to build element parser.
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
use crate::error::Res;
|
||||
use crate::parser::element_parser::element;
|
||||
use nom::branch::alt;
|
||||
use nom::combinator::eof;
|
||||
use nom::combinator::recognize;
|
||||
@@ -45,7 +46,8 @@ pub fn paragraph<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s st
|
||||
|
||||
#[tracing::instrument(ret, level = "debug")]
|
||||
fn paragraph_end<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, &'s str> {
|
||||
let non_paragraph_element_matcher = parser_with_context!(element(false))(context);
|
||||
let element_matcher = element(false);
|
||||
let non_paragraph_element_matcher = parser_with_context!(element_matcher)(context);
|
||||
let start_of_line_matcher = parser_with_context!(start_of_line)(&context);
|
||||
alt((
|
||||
recognize(tuple((start_of_line_matcher, many1(blank_line)))),
|
||||
@@ -70,7 +72,8 @@ mod tests {
|
||||
let initial_context: ContextTree<'_, '_> = ContextTree::new();
|
||||
let document_context =
|
||||
initial_context.with_additional_node(ContextElement::DocumentRoot(input));
|
||||
let paragraph_matcher = parser_with_context!(element(true))(&document_context);
|
||||
let element_matcher = element(true);
|
||||
let paragraph_matcher = parser_with_context!(element_matcher)(&document_context);
|
||||
let (remaining, first_paragraph) = paragraph_matcher(input).expect("Parse first paragraph");
|
||||
let (remaining, second_paragraph) =
|
||||
paragraph_matcher(remaining).expect("Parse second paragraph.");
|
||||
|
||||
Reference in New Issue
Block a user