2023-04-22 18:54:19 -04:00
use nom ::branch ::alt ;
2023-04-21 16:07:38 -04:00
use nom ::combinator ::map ;
use nom ::combinator ::not ;
use super ::parser_with_context ::parser_with_context ;
use super ::plain_text ::plain_text ;
2023-04-23 16:53:02 -04:00
use super ::regular_link ::regular_link ;
2023-04-21 16:07:38 -04:00
use super ::Context ;
2023-04-22 20:02:51 -04:00
use crate ::error ::Res ;
2023-07-13 22:42:42 -04:00
use crate ::parser ::angle_link ::angle_link ;
2023-07-21 18:19:39 -04:00
use crate ::parser ::citation ::citation ;
2023-07-18 20:05:39 -04:00
use crate ::parser ::entity ::entity ;
2023-07-19 00:37:51 -04:00
use crate ::parser ::export_snippet ::export_snippet ;
2023-07-19 18:56:46 -04:00
use crate ::parser ::footnote_reference ::footnote_reference ;
2023-07-18 20:51:06 -04:00
use crate ::parser ::latex_fragment ::latex_fragment ;
2023-04-22 20:02:51 -04:00
use crate ::parser ::object ::Object ;
2023-07-14 04:28:56 +00:00
use crate ::parser ::org_macro ::org_macro ;
2023-07-13 18:18:07 -04:00
use crate ::parser ::plain_link ::plain_link ;
2023-04-24 18:55:15 -04:00
use crate ::parser ::radio_link ::radio_link ;
use crate ::parser ::radio_link ::radio_target ;
2023-04-22 20:02:51 -04:00
use crate ::parser ::text_markup ::text_markup ;
2023-04-21 16:07:38 -04:00
#[ tracing::instrument(ret, level = " debug " ) ]
pub fn standard_set_object < ' r , ' s > (
context : Context < ' r , ' s > ,
input : & ' s str ,
) -> Res < & ' s str , Object < ' s > > {
2023-07-19 18:56:46 -04:00
// TODO: citations (NOT citation references), inline babel calls, inline source blocks, line breaks, links, macros, targets and radio targets, statistics cookies, subscript and superscript, timestamps, and text markup.
2023-04-21 16:07:38 -04:00
not ( | i | context . check_exit_matcher ( i ) ) ( input ) ? ;
2023-04-22 18:54:19 -04:00
alt ( (
2023-07-21 18:52:02 -04:00
map ( parser_with_context! ( citation ) ( context ) , Object ::Citation ) ,
2023-07-19 18:56:46 -04:00
map (
parser_with_context! ( footnote_reference ) ( context ) ,
Object ::FootnoteReference ,
) ,
2023-07-19 00:37:51 -04:00
map (
parser_with_context! ( export_snippet ) ( context ) ,
Object ::ExportSnippet ,
) ,
2023-07-18 20:05:39 -04:00
map ( parser_with_context! ( entity ) ( context ) , Object ::Entity ) ,
2023-07-18 20:51:06 -04:00
map (
parser_with_context! ( latex_fragment ) ( context ) ,
Object ::LatexFragment ,
) ,
2023-04-24 18:55:15 -04:00
map ( parser_with_context! ( radio_link ) ( context ) , Object ::RadioLink ) ,
map (
parser_with_context! ( radio_target ) ( context ) ,
Object ::RadioTarget ,
) ,
2023-04-22 20:48:01 -04:00
parser_with_context! ( text_markup ) ( context ) ,
2023-04-23 16:53:02 -04:00
map (
parser_with_context! ( regular_link ) ( context ) ,
Object ::RegularLink ,
) ,
2023-07-13 18:18:07 -04:00
map ( parser_with_context! ( plain_link ) ( context ) , Object ::PlainLink ) ,
2023-07-13 22:42:42 -04:00
map ( parser_with_context! ( angle_link ) ( context ) , Object ::AngleLink ) ,
2023-07-13 23:26:51 -04:00
map ( parser_with_context! ( org_macro ) ( context ) , Object ::OrgMacro ) ,
2023-04-22 18:54:19 -04:00
map ( parser_with_context! ( plain_text ) ( context ) , Object ::PlainText ) ,
) ) ( input )
2023-04-21 16:07:38 -04:00
}
#[ tracing::instrument(ret, level = " debug " ) ]
pub fn minimal_set_object < ' r , ' s > (
context : Context < ' r , ' s > ,
input : & ' s str ,
) -> Res < & ' s str , Object < ' s > > {
2023-07-18 20:51:06 -04:00
// TODO: superscripts and subscripts
2023-04-21 16:07:38 -04:00
not ( | i | context . check_exit_matcher ( i ) ) ( input ) ? ;
2023-04-22 18:54:19 -04:00
alt ( (
2023-07-18 20:05:39 -04:00
map ( parser_with_context! ( entity ) ( context ) , Object ::Entity ) ,
2023-07-18 20:51:06 -04:00
map (
parser_with_context! ( latex_fragment ) ( context ) ,
Object ::LatexFragment ,
) ,
2023-04-22 20:48:01 -04:00
parser_with_context! ( text_markup ) ( context ) ,
2023-04-22 18:54:19 -04:00
map ( parser_with_context! ( plain_text ) ( context ) , Object ::PlainText ) ,
) ) ( input )
2023-04-21 16:07:38 -04:00
}
2023-04-22 19:46:27 -04:00
#[ 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 > > {
2023-04-22 20:02:51 -04:00
// Used for exit matchers so this does not check exit matcher condition.
2023-04-23 16:53:02 -04:00
alt ( (
2023-07-21 18:52:02 -04:00
map ( parser_with_context! ( citation ) ( context ) , Object ::Citation ) ,
2023-07-19 18:56:46 -04:00
map (
parser_with_context! ( footnote_reference ) ( context ) ,
Object ::FootnoteReference ,
) ,
2023-07-19 00:37:51 -04:00
map (
parser_with_context! ( export_snippet ) ( context ) ,
Object ::ExportSnippet ,
) ,
2023-07-18 20:05:39 -04:00
map ( parser_with_context! ( entity ) ( context ) , Object ::Entity ) ,
2023-07-18 20:51:06 -04:00
map (
parser_with_context! ( latex_fragment ) ( context ) ,
Object ::LatexFragment ,
) ,
2023-04-24 18:55:15 -04:00
map ( parser_with_context! ( radio_link ) ( context ) , Object ::RadioLink ) ,
map (
parser_with_context! ( radio_target ) ( context ) ,
Object ::RadioTarget ,
) ,
2023-04-23 16:53:02 -04:00
parser_with_context! ( text_markup ) ( context ) ,
map (
parser_with_context! ( regular_link ) ( context ) ,
Object ::RegularLink ,
) ,
2023-07-13 19:09:44 -04:00
map ( parser_with_context! ( plain_link ) ( context ) , Object ::PlainLink ) ,
2023-07-13 22:42:42 -04:00
map ( parser_with_context! ( angle_link ) ( context ) , Object ::AngleLink ) ,
2023-07-13 23:26:51 -04:00
map ( parser_with_context! ( org_macro ) ( context ) , Object ::OrgMacro ) ,
2023-04-23 16:53:02 -04:00
) ) ( 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: minimal set of objects as well as export snippets, inline babel calls, inline source blocks, macros, and statistics cookies. It can also contain another link, but only when it is a plain or angle link. It can contain square brackets, but not ]]
alt ( ( parser_with_context! ( minimal_set_object ) ( context ) , ) ) ( input )
2023-04-22 19:46:27 -04:00
}