You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
organic/src/parser/object_parser.rs

60 lines
2.1 KiB
Rust

use crate::error::Res;
use crate::parser::text_markup::text_markup;
use nom::branch::alt;
use nom::combinator::map;
use nom::combinator::not;
use crate::parser::object::Object;
use super::parser_with_context::parser_with_context;
use super::plain_text::plain_text;
use super::Context;
#[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: 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)?;
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")]
pub fn minimal_set_object<'r, 's>(
context: Context<'r, 's>,
input: &'s str,
) -> Res<&'s str, Object<'s>> {
// TODO: add text markup, entities, LaTeX fragments, superscripts and subscripts
not(|i| context.check_exit_matcher(i))(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")]
pub fn any_object_except_plain_text<'r, 's>(
context: Context<'r, 's>,
input: &'s str,
) -> Res<&'s str, Object<'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)?;
alt((map(
parser_with_context!(text_markup)(context),
Object::TextMarkup,
),))(input)
}