Add start of paragraph context.

This commit is contained in:
Tom Alexander 2022-12-11 00:21:30 -05:00
parent b2742f89e2
commit 972ffa6345
Signed by: talexander
GPG Key ID: D3A179C9A53C0EDE
2 changed files with 6 additions and 2 deletions

View File

@ -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)]

View File

@ -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<TextElement<'s>>, &'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(&paragraph_end)),
}));
let (remaining, (many, till)) =