Fix plain list item parser to not consume trailing whitespace on the last element.
This commit is contained in:
parent
08fed1301e
commit
143ac49777
@ -128,13 +128,13 @@ pub fn plain_list_item<'r, 's>(
|
||||
exit_matcher: ChainBehavior::AndParent(Some(&plain_list_item_end)),
|
||||
}));
|
||||
let without_consume_context = context
|
||||
.with_additional_node(ContextElement::ConsumeTrailingWhitespace(false))
|
||||
.with_additional_node(ContextElement::ListItem(indent_level))
|
||||
.with_additional_node(ContextElement::ExitMatcherNode(ExitMatcherNode {
|
||||
exit_matcher: ChainBehavior::AndParent(Some(&plain_list_item_end)),
|
||||
}));
|
||||
|
||||
let element_matcher = parser_with_context!(element)(&with_consume_context);
|
||||
let with_consume_matcher = parser_with_context!(element)(&with_consume_context);
|
||||
let without_consume_matcher = parser_with_context!(element)(&with_consume_context);
|
||||
let exit_matcher = parser_with_context!(exit_matcher_parser)(&with_consume_context);
|
||||
let (remaining, bull) =
|
||||
verify(bullet, |bull: &str| bull != "*" || indent_level > 0)(remaining)?;
|
||||
@ -155,9 +155,12 @@ pub fn plain_list_item<'r, 's>(
|
||||
}
|
||||
Err(_) => {
|
||||
let (remaining, _ws) = space1(remaining)?;
|
||||
// TODO: The problem is we are not capturing trailing whitespace for elements that are before the last element.
|
||||
let (remaining, (contents, _exit_contents)) =
|
||||
many_till(element_matcher, exit_matcher)(remaining)?;
|
||||
let (remaining, (mut contents, (final_element, _exit_contents))) =
|
||||
many_till(
|
||||
with_consume_matcher,
|
||||
tuple((without_consume_matcher, exit_matcher)),
|
||||
)(remaining)?;
|
||||
contents.push(final_element);
|
||||
let source = get_consumed(input, remaining);
|
||||
return Ok((
|
||||
remaining,
|
||||
|
Loading…
Reference in New Issue
Block a user