Move consuming the trailing whitespace up to the element matchers.
This commit is contained in:
@@ -16,6 +16,8 @@ use super::lesser_block::src_block;
|
||||
use super::lesser_block::verse_block;
|
||||
use super::paragraph::paragraph;
|
||||
use super::plain_list::plain_list;
|
||||
use super::util::get_consumed;
|
||||
use super::util::maybe_consume_trailing_whitespace_if_not_exiting;
|
||||
use super::util::start_of_line;
|
||||
use super::Context;
|
||||
use crate::error::Res;
|
||||
@@ -40,7 +42,14 @@ pub fn paragraph_element<'r, 's>(
|
||||
let paragraph_matcher = parser_with_context!(paragraph)(context);
|
||||
let keyword_matcher = parser_with_context!(keyword)(context);
|
||||
let (remaining, affiliated_keywords) = many0(keyword_matcher)(input)?;
|
||||
map(paragraph_matcher, Element::Paragraph)(remaining)
|
||||
let (remaining, element) = map(paragraph_matcher, Element::Paragraph)(remaining)?;
|
||||
|
||||
let (remaining, _trailing_ws) =
|
||||
maybe_consume_trailing_whitespace_if_not_exiting(context, remaining)?;
|
||||
|
||||
let source = get_consumed(input, remaining);
|
||||
|
||||
Ok((remaining, element))
|
||||
}
|
||||
pub fn non_paragraph_element<'r, 's>(
|
||||
context: Context<'r, 's>,
|
||||
@@ -89,5 +98,11 @@ pub fn non_paragraph_element<'r, 's>(
|
||||
map(keyword_matcher, Element::Keyword)(input)
|
||||
}
|
||||
}?;
|
||||
|
||||
let (remaining, _trailing_ws) =
|
||||
maybe_consume_trailing_whitespace_if_not_exiting(context, remaining)?;
|
||||
|
||||
let source = get_consumed(input, remaining);
|
||||
|
||||
Ok((remaining, element))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user