From 972ffa63455abdb209c540d6e1653284c75e3457 Mon Sep 17 00:00:00 2001 From: Tom Alexander Date: Sun, 11 Dec 2022 00:21:30 -0500 Subject: [PATCH] Add start of paragraph context. --- src/parser/nom_context.rs | 2 ++ src/parser/text_element_parser.rs | 6 ++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/parser/nom_context.rs b/src/parser/nom_context.rs index c195ae3..5fa6f97 100644 --- a/src/parser/nom_context.rs +++ b/src/parser/nom_context.rs @@ -67,6 +67,7 @@ impl<'r, 's> ContextTree<'r, 's> { }; } ContextElement::PreviousElementNode(_) => {} + ContextElement::StartOfParagraph => {} }; current_node = current_node.without_front(); @@ -82,6 +83,7 @@ impl<'r, 's> ContextTree<'r, 's> { pub enum ContextElement<'r, 's> { FailMatcherNode(FailMatcherNode<'r>), PreviousElementNode(PreviousElementNode<'s>), + StartOfParagraph, } #[derive(Debug)] diff --git a/src/parser/text_element_parser.rs b/src/parser/text_element_parser.rs index 408ce72..1e259bf 100644 --- a/src/parser/text_element_parser.rs +++ b/src/parser/text_element_parser.rs @@ -63,6 +63,7 @@ where current_context = next_context; match context_element { ContextElement::FailMatcherNode(_) => {} + ContextElement::StartOfParagraph => {} ContextElement::PreviousElementNode(PreviousElementNode { element: token, }) => { @@ -123,8 +124,9 @@ pub fn paragraph<'s, 'r>( ) -> Res<&'s str, (Vec>, &'s str)> { // Add a not(eof) check because many_till cannot match a zero-length string not(eof)(i)?; - let paragraph_context = - context.with_additional_node(ContextElement::FailMatcherNode(FailMatcherNode { + let paragraph_context = context + .with_additional_node(ContextElement::StartOfParagraph) + .with_additional_node(ContextElement::FailMatcherNode(FailMatcherNode { fail_matcher: ChainBehavior::AndParent(Some(¶graph_end)), })); let (remaining, (many, till)) =