Give object structs their own file separate from the parsers.
This commit is contained in:
parent
bcf5f5a9c8
commit
54b02f4e74
@ -1,7 +1,7 @@
|
||||
use crate::parser::comment::comment;
|
||||
use crate::parser::element::element;
|
||||
use crate::parser::exiting::ExitClass;
|
||||
use crate::parser::object::standard_set_object;
|
||||
use crate::parser::object_parser::standard_set_object;
|
||||
use crate::parser::parser_context::ContextElement;
|
||||
use crate::parser::parser_context::ContextTree;
|
||||
use crate::parser::parser_context::ExitMatcherNode;
|
||||
|
@ -11,6 +11,7 @@ mod greater_element;
|
||||
mod lesser_element;
|
||||
mod list;
|
||||
mod object;
|
||||
mod object_parser;
|
||||
mod paragraph;
|
||||
mod parser_context;
|
||||
mod parser_with_context;
|
||||
|
@ -1,11 +1,4 @@
|
||||
use nom::combinator::map;
|
||||
use nom::combinator::not;
|
||||
|
||||
use super::error::Res;
|
||||
use super::parser_with_context::parser_with_context;
|
||||
use super::plain_text::plain_text;
|
||||
use super::source::Source;
|
||||
use super::Context;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub enum Object<'s> {
|
||||
@ -42,29 +35,3 @@ impl<'s> Source<'s> for Object<'s> {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[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)?;
|
||||
|
||||
let plain_text_matcher = parser_with_context!(plain_text)(context);
|
||||
|
||||
map(plain_text_matcher, 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)?;
|
||||
|
||||
let plain_text_matcher = parser_with_context!(plain_text)(context);
|
||||
|
||||
map(plain_text_matcher, Object::PlainText)(input)
|
||||
}
|
||||
|
35
src/parser/object_parser.rs
Normal file
35
src/parser/object_parser.rs
Normal file
@ -0,0 +1,35 @@
|
||||
use nom::combinator::map;
|
||||
use nom::combinator::not;
|
||||
|
||||
use crate::parser::object::Object;
|
||||
|
||||
use super::error::Res;
|
||||
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)?;
|
||||
|
||||
let plain_text_matcher = parser_with_context!(plain_text)(context);
|
||||
|
||||
map(plain_text_matcher, 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)?;
|
||||
|
||||
let plain_text_matcher = parser_with_context!(plain_text)(context);
|
||||
|
||||
map(plain_text_matcher, Object::PlainText)(input)
|
||||
}
|
@ -6,15 +6,12 @@ use nom::multi::many1;
|
||||
use nom::multi::many_till;
|
||||
use nom::sequence::tuple;
|
||||
|
||||
use crate::parser::error::CustomError;
|
||||
use crate::parser::error::MyError;
|
||||
use crate::parser::exiting::ExitClass;
|
||||
use crate::parser::object::standard_set_object;
|
||||
use crate::parser::object_parser::standard_set_object;
|
||||
use crate::parser::parser_context::ContextElement;
|
||||
use crate::parser::parser_context::ExitMatcherNode;
|
||||
use crate::parser::parser_with_context::parser_with_context;
|
||||
use crate::parser::util::exit_matcher_parser;
|
||||
use crate::parser::util::immediate_in_section;
|
||||
use crate::parser::util::maybe_consume_trailing_whitespace_if_not_exiting;
|
||||
use crate::parser::util::start_of_line;
|
||||
|
||||
|
@ -17,8 +17,8 @@ use crate::parser::error::Res;
|
||||
use crate::parser::exiting::ExitClass;
|
||||
use crate::parser::greater_element::TableRow;
|
||||
use crate::parser::lesser_element::TableCell;
|
||||
use crate::parser::object::minimal_set_object;
|
||||
use crate::parser::object::Object;
|
||||
use crate::parser::object_parser::minimal_set_object;
|
||||
use crate::parser::parser_context::ContextElement;
|
||||
use crate::parser::parser_context::ExitMatcherNode;
|
||||
use crate::parser::parser_with_context::parser_with_context;
|
||||
|
Loading…
x
Reference in New Issue
Block a user