use nom::branch::alt; use nom::combinator::map; use nom::combinator::not; use super::parser_with_context::parser_with_context; use super::plain_text::plain_text; use super::regular_link::regular_link; use super::Context; use crate::error::Res; use crate::parser::angle_link::angle_link; use crate::parser::citation::citation; use crate::parser::entity::entity; use crate::parser::export_snippet::export_snippet; use crate::parser::footnote_reference::footnote_reference; use crate::parser::inline_babel_call::inline_babel_call; use crate::parser::inline_source_block::inline_source_block; use crate::parser::latex_fragment::latex_fragment; use crate::parser::line_break::line_break; use crate::parser::object::Object; use crate::parser::org_macro::org_macro; use crate::parser::plain_link::plain_link; use crate::parser::radio_link::radio_link; use crate::parser::radio_link::radio_target; use crate::parser::statistics_cookie::statistics_cookie; use crate::parser::target::target; use crate::parser::text_markup::text_markup; #[tracing::instrument(ret, level = "debug")] pub fn standard_set_object<'r, 's>( context: Context<'r, 's>, input: &'s str, ) -> Res<&'s str, Object<'s>> { // TODO: subscript and superscript, timestamps. not(|i| context.check_exit_matcher(i))(input)?; alt(( map( parser_with_context!(statistics_cookie)(context), Object::StatisticsCookie, ), map(parser_with_context!(target)(context), Object::Target), map(parser_with_context!(line_break)(context), Object::LineBreak), map( parser_with_context!(inline_source_block)(context), Object::InlineSourceBlock, ), map( parser_with_context!(inline_babel_call)(context), Object::InlineBabelCall, ), map(parser_with_context!(citation)(context), Object::Citation), map( parser_with_context!(footnote_reference)(context), Object::FootnoteReference, ), map( parser_with_context!(export_snippet)(context), Object::ExportSnippet, ), map(parser_with_context!(entity)(context), Object::Entity), map( parser_with_context!(latex_fragment)(context), Object::LatexFragment, ), map(parser_with_context!(radio_link)(context), Object::RadioLink), map( parser_with_context!(radio_target)(context), Object::RadioTarget, ), parser_with_context!(text_markup)(context), map( parser_with_context!(regular_link)(context), Object::RegularLink, ), map(parser_with_context!(plain_link)(context), Object::PlainLink), map(parser_with_context!(angle_link)(context), Object::AngleLink), map(parser_with_context!(org_macro)(context), Object::OrgMacro), map(parser_with_context!(plain_text)(context), Object::PlainText), ))(input) } #[tracing::instrument(ret, level = "debug")] pub fn minimal_set_object<'r, 's>( context: Context<'r, 's>, input: &'s str, ) -> Res<&'s str, Object<'s>> { // TODO: superscripts and subscripts not(|i| context.check_exit_matcher(i))(input)?; alt(( map(parser_with_context!(entity)(context), Object::Entity), map( parser_with_context!(latex_fragment)(context), Object::LatexFragment, ), parser_with_context!(text_markup)(context), map(parser_with_context!(plain_text)(context), Object::PlainText), ))(input) } #[tracing::instrument(ret, level = "debug")] pub fn any_object_except_plain_text<'r, 's>( context: Context<'r, 's>, input: &'s str, ) -> Res<&'s str, Object<'s>> { // Used for exit matchers so this does not check exit matcher condition. alt(( map( parser_with_context!(statistics_cookie)(context), Object::StatisticsCookie, ), map(parser_with_context!(target)(context), Object::Target), map(parser_with_context!(line_break)(context), Object::LineBreak), map( parser_with_context!(inline_source_block)(context), Object::InlineSourceBlock, ), map( parser_with_context!(inline_babel_call)(context), Object::InlineBabelCall, ), map(parser_with_context!(citation)(context), Object::Citation), map( parser_with_context!(footnote_reference)(context), Object::FootnoteReference, ), map( parser_with_context!(export_snippet)(context), Object::ExportSnippet, ), map(parser_with_context!(entity)(context), Object::Entity), map( parser_with_context!(latex_fragment)(context), Object::LatexFragment, ), map(parser_with_context!(radio_link)(context), Object::RadioLink), map( parser_with_context!(radio_target)(context), Object::RadioTarget, ), parser_with_context!(text_markup)(context), map( parser_with_context!(regular_link)(context), Object::RegularLink, ), map(parser_with_context!(plain_link)(context), Object::PlainLink), map(parser_with_context!(angle_link)(context), Object::AngleLink), map(parser_with_context!(org_macro)(context), Object::OrgMacro), ))(input) } #[tracing::instrument(ret, level = "debug")] pub fn regular_link_description_object_set<'r, 's>( context: Context<'r, 's>, input: &'s str, ) -> Res<&'s str, Object<'s>> { // TODO: add export snippets. It can also contain another link, but only when it is a plain or angle link. It can contain square brackets, but not ]] alt(( map( parser_with_context!(statistics_cookie)(context), Object::StatisticsCookie, ), map( parser_with_context!(inline_source_block)(context), Object::InlineSourceBlock, ), map( parser_with_context!(inline_babel_call)(context), Object::InlineBabelCall, ), map(parser_with_context!(org_macro)(context), Object::OrgMacro), parser_with_context!(minimal_set_object)(context), ))(input) }