use super::comment::comment; use super::drawer::drawer; use super::dynamic_block::dynamic_block; use super::element::Element; use super::error::Res; use super::footnote_definition::footnote_definition; use super::greater_block::greater_block; use super::lesser_block::lesser_block; use super::paragraph::paragraph; use super::plain_list::plain_list; use super::Context; use crate::parser::parser_with_context::parser_with_context; use crate::parser::table::org_mode_table; use nom::branch::alt; use nom::combinator::map; #[tracing::instrument(ret, level = "debug")] pub fn element<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, Element<'s>> { let non_paragraph_matcher = parser_with_context!(non_paragraph_element)(context); let paragraph_matcher = parser_with_context!(paragraph)(context); alt(( non_paragraph_matcher, map(paragraph_matcher, Element::Paragraph), ))(input) } pub fn non_paragraph_element<'r, 's>( context: Context<'r, 's>, input: &'s str, ) -> Res<&'s str, Element<'s>> { 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); let footnote_definition_matcher = parser_with_context!(footnote_definition)(context); let comment_matcher = parser_with_context!(comment)(context); let drawer_matcher = parser_with_context!(drawer)(context); let table_matcher = parser_with_context!(org_mode_table)(context); let lesser_block_matcher = parser_with_context!(lesser_block)(context); alt(( map(plain_list_matcher, Element::PlainList), map(greater_block_matcher, Element::GreaterBlock), map(dynamic_block_matcher, Element::DynamicBlock), map(footnote_definition_matcher, Element::FootnoteDefinition), map(comment_matcher, Element::Comment), map(drawer_matcher, Element::Drawer), map(table_matcher, Element::Table), map(lesser_block_matcher, Element::LesserBlock), ))(input) }