Port the rest of the element parsers over.
This commit is contained in:
@@ -101,44 +101,124 @@ fn _element<'b, 'g, 'r, 's>(
|
||||
|
||||
element!(comment, context, input, Element::Comment);
|
||||
|
||||
let drawer_matcher = parser_with_context!(drawer)(context);
|
||||
let table_matcher = parser_with_context!(org_mode_table)(context);
|
||||
let verse_block_matcher = parser_with_context!(verse_block)(context);
|
||||
let comment_block_matcher = parser_with_context!(comment_block)(context);
|
||||
let example_block_matcher = parser_with_context!(example_block)(context);
|
||||
let export_block_matcher = parser_with_context!(export_block)(context);
|
||||
let src_block_matcher = parser_with_context!(src_block)(context);
|
||||
let clock_matcher = parser_with_context!(clock)(context);
|
||||
let diary_sexp_matcher = parser_with_context!(diary_sexp)(context);
|
||||
let fixed_width_area_matcher = parser_with_context!(fixed_width_area)(context);
|
||||
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 latex_environment_matcher = parser_with_context!(latex_environment)(context);
|
||||
ak_element!(
|
||||
drawer,
|
||||
&mut affiliated_keywords,
|
||||
post_affiliated_keywords_input,
|
||||
context,
|
||||
input,
|
||||
Element::Drawer
|
||||
);
|
||||
|
||||
let (remaining, maybe_element) = {
|
||||
#[cfg(feature = "tracing")]
|
||||
let span = span!(tracing::Level::DEBUG, "Main element block");
|
||||
#[cfg(feature = "tracing")]
|
||||
let _enter = span.enter();
|
||||
ak_element!(
|
||||
org_mode_table,
|
||||
&mut affiliated_keywords,
|
||||
post_affiliated_keywords_input,
|
||||
context,
|
||||
input,
|
||||
Element::Table
|
||||
);
|
||||
|
||||
opt(alt((
|
||||
map(drawer_matcher, Element::Drawer),
|
||||
map(table_matcher, Element::Table),
|
||||
map(verse_block_matcher, Element::VerseBlock),
|
||||
map(comment_block_matcher, Element::CommentBlock),
|
||||
map(example_block_matcher, Element::ExampleBlock),
|
||||
map(export_block_matcher, Element::ExportBlock),
|
||||
map(src_block_matcher, Element::SrcBlock),
|
||||
map(clock_matcher, Element::Clock),
|
||||
map(diary_sexp_matcher, Element::DiarySexp),
|
||||
map(fixed_width_area_matcher, Element::FixedWidthArea),
|
||||
map(horizontal_rule_matcher, Element::HorizontalRule),
|
||||
map(latex_environment_matcher, Element::LatexEnvironment),
|
||||
map(babel_keyword_matcher, Element::BabelCall),
|
||||
map(keyword_matcher, Element::Keyword),
|
||||
)))(input)?
|
||||
};
|
||||
ak_element!(
|
||||
verse_block,
|
||||
&mut affiliated_keywords,
|
||||
post_affiliated_keywords_input,
|
||||
context,
|
||||
input,
|
||||
Element::VerseBlock
|
||||
);
|
||||
|
||||
ak_element!(
|
||||
comment_block,
|
||||
&mut affiliated_keywords,
|
||||
post_affiliated_keywords_input,
|
||||
context,
|
||||
input,
|
||||
Element::CommentBlock
|
||||
);
|
||||
|
||||
ak_element!(
|
||||
example_block,
|
||||
&mut affiliated_keywords,
|
||||
post_affiliated_keywords_input,
|
||||
context,
|
||||
input,
|
||||
Element::ExampleBlock
|
||||
);
|
||||
|
||||
ak_element!(
|
||||
export_block,
|
||||
&mut affiliated_keywords,
|
||||
post_affiliated_keywords_input,
|
||||
context,
|
||||
input,
|
||||
Element::ExportBlock
|
||||
);
|
||||
|
||||
ak_element!(
|
||||
src_block,
|
||||
&mut affiliated_keywords,
|
||||
post_affiliated_keywords_input,
|
||||
context,
|
||||
input,
|
||||
Element::SrcBlock
|
||||
);
|
||||
|
||||
element!(clock, context, input, Element::Clock);
|
||||
|
||||
ak_element!(
|
||||
diary_sexp,
|
||||
&mut affiliated_keywords,
|
||||
post_affiliated_keywords_input,
|
||||
context,
|
||||
input,
|
||||
Element::DiarySexp
|
||||
);
|
||||
|
||||
ak_element!(
|
||||
fixed_width_area,
|
||||
&mut affiliated_keywords,
|
||||
post_affiliated_keywords_input,
|
||||
context,
|
||||
input,
|
||||
Element::FixedWidthArea
|
||||
);
|
||||
|
||||
ak_element!(
|
||||
horizontal_rule,
|
||||
&mut affiliated_keywords,
|
||||
post_affiliated_keywords_input,
|
||||
context,
|
||||
input,
|
||||
Element::HorizontalRule
|
||||
);
|
||||
|
||||
ak_element!(
|
||||
latex_environment,
|
||||
&mut affiliated_keywords,
|
||||
post_affiliated_keywords_input,
|
||||
context,
|
||||
input,
|
||||
Element::LatexEnvironment
|
||||
);
|
||||
|
||||
ak_element!(
|
||||
babel_call,
|
||||
&mut affiliated_keywords,
|
||||
post_affiliated_keywords_input,
|
||||
context,
|
||||
input,
|
||||
Element::BabelCall
|
||||
);
|
||||
|
||||
ak_element!(
|
||||
keyword,
|
||||
&mut affiliated_keywords,
|
||||
post_affiliated_keywords_input,
|
||||
context,
|
||||
input,
|
||||
Element::Keyword
|
||||
);
|
||||
|
||||
if can_be_paragraph {
|
||||
// Paragraph with affiliated keyword
|
||||
@@ -162,14 +242,9 @@ fn _element<'b, 'g, 'r, 's>(
|
||||
);
|
||||
}
|
||||
|
||||
if maybe_element.is_none() {
|
||||
return Err(nom::Err::Error(CustomError::MyError(MyError(
|
||||
"No element.",
|
||||
))));
|
||||
}
|
||||
let element = maybe_element.expect("The above if-statement ensures this is Some().");
|
||||
|
||||
Ok((remaining, element))
|
||||
Err(nom::Err::Error(CustomError::MyError(MyError(
|
||||
"No element.",
|
||||
))))
|
||||
}
|
||||
|
||||
pub(crate) const fn detect_element(
|
||||
|
||||
Reference in New Issue
Block a user