Add a macro for calling parsers that take in the affiliated keywords.
This commit is contained in:
parent
a6f36ba679
commit
6ca4dc8ffc
@ -32,6 +32,7 @@ use super::lesser_block::verse_block;
|
||||
use super::org_source::OrgSource;
|
||||
use super::paragraph::paragraph;
|
||||
use super::plain_list::detect_plain_list;
|
||||
use super::plain_list::new_plain_list;
|
||||
use super::plain_list::plain_list;
|
||||
use super::table::detect_table;
|
||||
use crate::context::parser_with_context;
|
||||
@ -39,6 +40,7 @@ use crate::context::RefContext;
|
||||
use crate::error::CustomError;
|
||||
use crate::error::MyError;
|
||||
use crate::error::Res;
|
||||
use crate::parser::macros::ak_element;
|
||||
use crate::parser::table::org_mode_table;
|
||||
use crate::types::Element;
|
||||
|
||||
@ -62,6 +64,17 @@ fn _element<'b, 'g, 'r, 's>(
|
||||
) -> Res<OrgSource<'s>, Element<'s>> {
|
||||
let (post_affiliated_keywords_input, affiliated_keywords) = many0(affiliated_keyword)(input)?;
|
||||
|
||||
let mut affiliated_keywords = affiliated_keywords.into_iter();
|
||||
|
||||
ak_element!(
|
||||
new_plain_list,
|
||||
&mut affiliated_keywords,
|
||||
post_affiliated_keywords_input,
|
||||
context,
|
||||
input,
|
||||
Element::PlainList
|
||||
);
|
||||
|
||||
let plain_list_matcher = parser_with_context!(plain_list)(context);
|
||||
let greater_block_matcher = parser_with_context!(greater_block)(context);
|
||||
let dynamic_block_matcher = parser_with_context!(dynamic_block)(context);
|
||||
@ -131,6 +144,8 @@ fn _element<'b, 'g, 'r, 's>(
|
||||
}
|
||||
}
|
||||
|
||||
// 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!(
|
||||
|
@ -1 +1,25 @@
|
||||
/// Parse an element that has affiliated keywords.
|
||||
macro_rules! ak_element {
|
||||
($parser:ident, $affiliated_keywords:expr, $post_affiliated_keywords_input: expr, $context: expr, $input: expr, $wrapper: expr) => {
|
||||
if let Ok((remaining, ele)) = $parser(
|
||||
$affiliated_keywords,
|
||||
$post_affiliated_keywords_input,
|
||||
$context,
|
||||
$input,
|
||||
) {
|
||||
return Ok((remaining, $wrapper(ele)));
|
||||
}
|
||||
};
|
||||
($parser:ident, $affiliated_keywords:expr, $post_affiliated_keywords_input: expr, $context: expr, $input: expr) => {
|
||||
if let Ok((remaining, ele)) = $parser(
|
||||
$affiliated_keywords,
|
||||
$post_affiliated_keywords_input,
|
||||
$context,
|
||||
$input,
|
||||
) {
|
||||
return Ok((remaining, ele));
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
pub(crate) use ak_element;
|
||||
|
@ -91,7 +91,7 @@ pub(crate) fn new_plain_list<'b, 'g, 'r, 's, AK>(
|
||||
input: OrgSource<'s>,
|
||||
) -> Res<OrgSource<'s>, PlainList<'s>>
|
||||
where
|
||||
AK: Iterator<Item = Keyword<'s>>,
|
||||
AK: IntoIterator<Item = Keyword<'s>>,
|
||||
{
|
||||
todo!()
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user