Remove re-parsing of the final list child.
This commit is contained in:
parent
59cb3c2bbf
commit
bd187ebfe7
@ -147,19 +147,11 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
let (final_child_start, _final_item_first_parse) = match children.pop() {
|
||||
Some(final_child) => final_child,
|
||||
None => {
|
||||
if children.is_empty() {
|
||||
return Err(nom::Err::Error(CustomError::Static(
|
||||
"Plain lists require at least one element.",
|
||||
)));
|
||||
}
|
||||
};
|
||||
let final_item_context = ContextElement::ConsumeTrailingWhitespace(false);
|
||||
let final_item_context = parser_context.with_additional_node(&final_item_context);
|
||||
let (remaining, (_, reparsed_final_item)) =
|
||||
plain_list_item(&final_item_context, final_child_start)?;
|
||||
children.push((final_child_start, reparsed_final_item));
|
||||
|
||||
let (remaining, _trailing_ws) =
|
||||
maybe_consume_trailing_whitespace_if_not_exiting(context, remaining)?;
|
||||
@ -256,23 +248,11 @@ fn plain_list_item<'b, 'g, 'r, 's>(
|
||||
.filter(|b| *b == b'\n')
|
||||
.count();
|
||||
|
||||
let (mut remaining, (mut children, _exit_contents)) = many_till(
|
||||
let (remaining, (children, _exit_contents)) = many_till(
|
||||
include_input(bind_context!(element(true), &parser_context)),
|
||||
bind_context!(exit_matcher_parser, &parser_context),
|
||||
)(remaining)?;
|
||||
|
||||
if !children.is_empty() && !context.should_consume_trailing_whitespace() {
|
||||
let final_item_context = ContextElement::ConsumeTrailingWhitespace(false);
|
||||
let final_item_context = parser_context.with_additional_node(&final_item_context);
|
||||
let (final_child_start, _original_final_child) = children
|
||||
.pop()
|
||||
.expect("if-statement already checked that children was non-empty.");
|
||||
let (remain, reparsed_final_element) =
|
||||
include_input(bind_context!(element(true), &final_item_context))(final_child_start)?;
|
||||
remaining = remain;
|
||||
children.push(reparsed_final_element);
|
||||
}
|
||||
|
||||
let (remaining, _trailing_ws) =
|
||||
maybe_consume_trailing_whitespace_if_not_exiting(context, remaining)?;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user