Move consuming trailing element whitespace inside the parsers.
This ensures the parsers can take into account the affiliated keywords when setting their source without needing the SetSource trait.
This commit is contained in:
@@ -15,6 +15,7 @@ use super::keyword::affiliated_keyword;
|
||||
use super::org_source::OrgSource;
|
||||
use super::util::get_name;
|
||||
use super::util::include_input;
|
||||
use super::util::maybe_consume_trailing_whitespace_if_not_exiting;
|
||||
use super::util::WORD_CONSTITUENT_CHARACTERS;
|
||||
use crate::context::parser_with_context;
|
||||
use crate::context::ContextElement;
|
||||
@@ -43,8 +44,8 @@ pub(crate) fn footnote_definition<'b, 'g, 'r, 's>(
|
||||
"Cannot nest objects of the same element".into(),
|
||||
))));
|
||||
}
|
||||
let (input, affiliated_keywords) = many0(affiliated_keyword)(input)?;
|
||||
start_of_line(input)?;
|
||||
let (remaining, affiliated_keywords) = many0(affiliated_keyword)(input)?;
|
||||
start_of_line(remaining)?;
|
||||
// Cannot be indented.
|
||||
let (remaining, (_, lbl, _, _, _)) = tuple((
|
||||
tag_no_case("[fn:"),
|
||||
@@ -54,7 +55,7 @@ pub(crate) fn footnote_definition<'b, 'g, 'r, 's>(
|
||||
opt(verify(many0(blank_line), |lines: &Vec<OrgSource<'_>>| {
|
||||
lines.len() <= 2
|
||||
})),
|
||||
))(input)?;
|
||||
))(remaining)?;
|
||||
let contexts = [
|
||||
ContextElement::ConsumeTrailingWhitespace(true),
|
||||
ContextElement::Context("footnote definition"),
|
||||
@@ -83,6 +84,8 @@ pub(crate) fn footnote_definition<'b, 'g, 'r, 's>(
|
||||
}
|
||||
}
|
||||
|
||||
let (remaining, _trailing_ws) =
|
||||
maybe_consume_trailing_whitespace_if_not_exiting(context, remaining)?;
|
||||
let source = get_consumed(input, remaining);
|
||||
Ok((
|
||||
remaining,
|
||||
|
||||
Reference in New Issue
Block a user