Set the source using the full range of affiliated keywords to trailing whitespace.

This commit is contained in:
Tom Alexander
2023-04-22 00:09:14 -04:00
parent 0b989b53a6
commit 7b7779ee7e
3 changed files with 39 additions and 4 deletions

View File

@@ -16,6 +16,7 @@ use super::lesser_block::src_block;
use super::lesser_block::verse_block;
use super::paragraph::paragraph;
use super::plain_list::plain_list;
use super::source::SetSource;
use super::util::get_consumed;
use super::util::maybe_consume_trailing_whitespace_if_not_exiting;
@@ -42,12 +43,13 @@ 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)?;
let (remaining, element) = map(paragraph_matcher, Element::Paragraph)(remaining)?;
let (remaining, mut 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);
let source = get_consumed(input, remaining);
element.set_source(source);
Ok((remaining, element))
}
@@ -73,7 +75,7 @@ pub fn non_paragraph_element<'r, 's>(
let horizontal_rule_matcher = parser_with_context!(horizontal_rule)(context);
let keyword_matcher = parser_with_context!(keyword)(context);
let (remaining, mut affiliated_keywords) = many0(keyword_matcher)(input)?;
let (remaining, element) = match alt((
let (remaining, mut element) = match alt((
map(plain_list_matcher, Element::PlainList),
map(greater_block_matcher, Element::GreaterBlock),
map(dynamic_block_matcher, Element::DynamicBlock),
@@ -102,7 +104,8 @@ pub fn non_paragraph_element<'r, 's>(
let (remaining, _trailing_ws) =
maybe_consume_trailing_whitespace_if_not_exiting(context, remaining)?;
let _source = get_consumed(input, remaining);
let source = get_consumed(input, remaining);
element.set_source(source);
Ok((remaining, element))
}