Port paragraph parser to use ak_element.
This commit is contained in:
@@ -98,7 +98,6 @@ fn _element<'b, 'g, 'r, 's>(
|
||||
let horizontal_rule_matcher = parser_with_context!(horizontal_rule)(context);
|
||||
let keyword_matcher = parser_with_context!(keyword)(context);
|
||||
let babel_keyword_matcher = parser_with_context!(babel_call)(context);
|
||||
let paragraph_matcher = parser_with_context!(paragraph)(context);
|
||||
let latex_environment_matcher = parser_with_context!(latex_environment)(context);
|
||||
|
||||
let (mut remaining, mut maybe_element) = {
|
||||
@@ -128,41 +127,25 @@ fn _element<'b, 'g, 'r, 's>(
|
||||
)))(input)?
|
||||
};
|
||||
|
||||
if maybe_element.is_none() && can_be_paragraph {
|
||||
#[cfg(feature = "tracing")]
|
||||
let span = span!(tracing::Level::DEBUG, "Paragraph with affiliated keyword.");
|
||||
#[cfg(feature = "tracing")]
|
||||
let _enter = span.enter();
|
||||
// Paragraph with affiliated keyword
|
||||
ak_element!(
|
||||
paragraph,
|
||||
&mut affiliated_keywords,
|
||||
post_affiliated_keywords_input,
|
||||
context,
|
||||
input,
|
||||
Element::Paragraph
|
||||
);
|
||||
|
||||
let (remain, paragraph_with_affiliated_keyword) = opt(map(
|
||||
tuple((
|
||||
peek(affiliated_keyword),
|
||||
map(paragraph_matcher, Element::Paragraph),
|
||||
)),
|
||||
|(_, paragraph)| paragraph,
|
||||
))(remaining)?;
|
||||
if paragraph_with_affiliated_keyword.is_some() {
|
||||
remaining = remain;
|
||||
maybe_element = paragraph_with_affiliated_keyword;
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: These two paragraphs need to be revisited using the affiliated keywords parsed above.
|
||||
|
||||
if maybe_element.is_none() && can_be_paragraph {
|
||||
#[cfg(feature = "tracing")]
|
||||
let span = span!(
|
||||
tracing::Level::DEBUG,
|
||||
"Paragraph without affiliated keyword."
|
||||
);
|
||||
#[cfg(feature = "tracing")]
|
||||
let _enter = span.enter();
|
||||
|
||||
let (remain, paragraph_without_affiliated_keyword) =
|
||||
map(paragraph_matcher, Element::Paragraph)(remaining)?;
|
||||
remaining = remain;
|
||||
maybe_element = Some(paragraph_without_affiliated_keyword);
|
||||
}
|
||||
// Paragraph without affiliated keyword
|
||||
ak_element!(
|
||||
paragraph,
|
||||
std::iter::empty(),
|
||||
input,
|
||||
context,
|
||||
input,
|
||||
Element::Paragraph
|
||||
);
|
||||
|
||||
if maybe_element.is_none() {
|
||||
return Err(nom::Err::Error(CustomError::MyError(MyError(
|
||||
|
||||
Reference in New Issue
Block a user