Create an also_recognize combinator to make providing source slices fast and safe.
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
use super::combinator::also_recognize;
|
||||
use super::combinator::context_many_till;
|
||||
use super::error::Res;
|
||||
use super::parser_context::ChainBehavior;
|
||||
@@ -26,8 +27,11 @@ pub fn paragraph<'r, 's>(context: Context<'r, 's>, i: &'s str) -> Res<&'s str, P
|
||||
exit_matcher: ChainBehavior::AndParent(Some(&context_paragraph_end)),
|
||||
}))
|
||||
.with_additional_node(ContextElement::StartOfParagraph);
|
||||
let (remaining, (many, till)) =
|
||||
context_many_till(¶graph_context, text_element, context_paragraph_end)(i)?;
|
||||
let (remaining, (source, (many, till))) = also_recognize(context_many_till(
|
||||
¶graph_context,
|
||||
text_element,
|
||||
context_paragraph_end,
|
||||
))(i)?;
|
||||
let many = many
|
||||
.into_iter()
|
||||
.filter_map(|token| match token {
|
||||
@@ -40,6 +44,7 @@ pub fn paragraph<'r, 's>(context: Context<'r, 's>, i: &'s str) -> Res<&'s str, P
|
||||
Paragraph {
|
||||
contents: many,
|
||||
paragraph_end: till,
|
||||
source,
|
||||
},
|
||||
))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user