Port the rest of the element parsers over.

This commit is contained in:
Tom Alexander
2023-10-12 17:12:55 -04:00
parent 767f44f94d
commit f475754a71
10 changed files with 218 additions and 84 deletions

View File

@@ -32,6 +32,7 @@ use crate::parser::util::start_of_line;
use crate::parser::util::WORD_CONSTITUENT_CHARACTERS;
use crate::types::Drawer;
use crate::types::Element;
use crate::types::Keyword;
use crate::types::Paragraph;
use crate::types::SetSource;
@@ -39,16 +40,20 @@ use crate::types::SetSource;
feature = "tracing",
tracing::instrument(ret, level = "debug", skip(context))
)]
pub(crate) fn drawer<'b, 'g, 'r, 's>(
pub(crate) fn drawer<'b, 'g, 'r, 's, AK>(
affiliated_keywords: AK,
remaining: OrgSource<'s>,
context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>,
) -> Res<OrgSource<'s>, Drawer<'s>> {
) -> Res<OrgSource<'s>, Drawer<'s>>
where
AK: IntoIterator<Item = Keyword<'s>>,
{
if immediate_in_section(context, "drawer") {
return Err(nom::Err::Error(CustomError::MyError(MyError(
"Cannot nest objects of the same element".into(),
))));
}
let (remaining, affiliated_keywords) = many0(affiliated_keyword)(input)?;
start_of_line(remaining)?;
let (remaining, _leading_whitespace) = space0(remaining)?;
let (remaining, (_open_colon, drawer_name, _close_colon, _new_line)) = tuple((