Add start of paragraph context.
This commit is contained in:
parent
b2742f89e2
commit
972ffa6345
@ -67,6 +67,7 @@ impl<'r, 's> ContextTree<'r, 's> {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
ContextElement::PreviousElementNode(_) => {}
|
ContextElement::PreviousElementNode(_) => {}
|
||||||
|
ContextElement::StartOfParagraph => {}
|
||||||
};
|
};
|
||||||
|
|
||||||
current_node = current_node.without_front();
|
current_node = current_node.without_front();
|
||||||
@ -82,6 +83,7 @@ impl<'r, 's> ContextTree<'r, 's> {
|
|||||||
pub enum ContextElement<'r, 's> {
|
pub enum ContextElement<'r, 's> {
|
||||||
FailMatcherNode(FailMatcherNode<'r>),
|
FailMatcherNode(FailMatcherNode<'r>),
|
||||||
PreviousElementNode(PreviousElementNode<'s>),
|
PreviousElementNode(PreviousElementNode<'s>),
|
||||||
|
StartOfParagraph,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
|
@ -63,6 +63,7 @@ where
|
|||||||
current_context = next_context;
|
current_context = next_context;
|
||||||
match context_element {
|
match context_element {
|
||||||
ContextElement::FailMatcherNode(_) => {}
|
ContextElement::FailMatcherNode(_) => {}
|
||||||
|
ContextElement::StartOfParagraph => {}
|
||||||
ContextElement::PreviousElementNode(PreviousElementNode {
|
ContextElement::PreviousElementNode(PreviousElementNode {
|
||||||
element: token,
|
element: token,
|
||||||
}) => {
|
}) => {
|
||||||
@ -123,8 +124,9 @@ pub fn paragraph<'s, 'r>(
|
|||||||
) -> Res<&'s str, (Vec<TextElement<'s>>, &'s str)> {
|
) -> Res<&'s str, (Vec<TextElement<'s>>, &'s str)> {
|
||||||
// Add a not(eof) check because many_till cannot match a zero-length string
|
// Add a not(eof) check because many_till cannot match a zero-length string
|
||||||
not(eof)(i)?;
|
not(eof)(i)?;
|
||||||
let paragraph_context =
|
let paragraph_context = context
|
||||||
context.with_additional_node(ContextElement::FailMatcherNode(FailMatcherNode {
|
.with_additional_node(ContextElement::StartOfParagraph)
|
||||||
|
.with_additional_node(ContextElement::FailMatcherNode(FailMatcherNode {
|
||||||
fail_matcher: ChainBehavior::AndParent(Some(¶graph_end)),
|
fail_matcher: ChainBehavior::AndParent(Some(¶graph_end)),
|
||||||
}));
|
}));
|
||||||
let (remaining, (many, till)) =
|
let (remaining, (many, till)) =
|
||||||
|
Loading…
x
Reference in New Issue
Block a user