This commit is contained in:
Tom Alexander
2023-04-22 01:45:38 -04:00
parent 92ee59558b
commit 9861084afe
8 changed files with 16 additions and 33 deletions

View File

@@ -46,8 +46,7 @@ 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 element_matcher = element(false);
let non_paragraph_element_matcher = parser_with_context!(element_matcher)(context);
let non_paragraph_element_matcher = parser_with_context!(element(false))(context);
let start_of_line_matcher = parser_with_context!(start_of_line)(&context);
alt((
recognize(tuple((start_of_line_matcher, many1(blank_line)))),
@@ -64,16 +63,13 @@ mod tests {
use crate::parser::parser_with_context::parser_with_context;
use crate::parser::source::Source;
use super::*;
#[test]
fn two_paragraphs() {
let input = "foo bar baz\n\nlorem ipsum";
let initial_context: ContextTree<'_, '_> = ContextTree::new();
let document_context =
initial_context.with_additional_node(ContextElement::DocumentRoot(input));
let element_matcher = element(true);
let paragraph_matcher = parser_with_context!(element_matcher)(&document_context);
let paragraph_matcher = parser_with_context!(element(true))(&document_context);
let (remaining, first_paragraph) = paragraph_matcher(input).expect("Parse first paragraph");
let (remaining, second_paragraph) =
paragraph_matcher(remaining).expect("Parse second paragraph.");