From 538031c688abe2b2a5c3002168e55e8517169f22 Mon Sep 17 00:00:00 2001 From: Tom Alexander Date: Sat, 22 Apr 2023 18:54:19 -0400 Subject: [PATCH] Call the text markup parser. --- src/parser/mod.rs | 1 + src/parser/object_parser.rs | 22 ++++++++++++++++------ src/parser/text_markup.rs | 11 +++++++++++ 3 files changed, 28 insertions(+), 6 deletions(-) create mode 100644 src/parser/text_markup.rs diff --git a/src/parser/mod.rs b/src/parser/mod.rs index 3bd8761..1f5cfec 100644 --- a/src/parser/mod.rs +++ b/src/parser/mod.rs @@ -29,6 +29,7 @@ mod property_drawer; pub mod sexp; mod source; mod table; +mod text_markup; mod util; pub use document::document; pub use document::Document; diff --git a/src/parser/object_parser.rs b/src/parser/object_parser.rs index a6ce342..7b9920e 100644 --- a/src/parser/object_parser.rs +++ b/src/parser/object_parser.rs @@ -1,4 +1,6 @@ use crate::error::Res; +use crate::parser::text_markup::text_markup; +use nom::branch::alt; use nom::combinator::map; use nom::combinator::not; @@ -16,9 +18,13 @@ pub fn standard_set_object<'r, 's>( // TODO: add entities, LaTeX fragments, export snippets, footnote references, 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. not(|i| context.check_exit_matcher(i))(input)?; - let plain_text_matcher = parser_with_context!(plain_text)(context); - - map(plain_text_matcher, Object::PlainText)(input) + alt(( + map( + parser_with_context!(text_markup)(context), + Object::TextMarkup, + ), + map(parser_with_context!(plain_text)(context), Object::PlainText), + ))(input) } #[tracing::instrument(ret, level = "debug")] @@ -29,7 +35,11 @@ pub fn minimal_set_object<'r, 's>( // TODO: add text markup, entities, LaTeX fragments, superscripts and subscripts not(|i| context.check_exit_matcher(i))(input)?; - let plain_text_matcher = parser_with_context!(plain_text)(context); - - map(plain_text_matcher, Object::PlainText)(input) + alt(( + map( + parser_with_context!(text_markup)(context), + Object::TextMarkup, + ), + map(parser_with_context!(plain_text)(context), Object::PlainText), + ))(input) } diff --git a/src/parser/text_markup.rs b/src/parser/text_markup.rs new file mode 100644 index 0000000..8b50aef --- /dev/null +++ b/src/parser/text_markup.rs @@ -0,0 +1,11 @@ +use super::Context; +use crate::error::Res; +use crate::parser::TextMarkup; + +#[tracing::instrument(ret, level = "debug")] +pub fn text_markup<'r, 's>( + context: Context<'r, 's>, + input: &'s str, +) -> Res<&'s str, TextMarkup<'s>> { + todo!() +}