Create structure for timestamps.
This commit is contained in:
parent
73e15286dc
commit
fa5fc41121
@ -54,6 +54,7 @@ use crate::parser::Table;
|
|||||||
use crate::parser::TableCell;
|
use crate::parser::TableCell;
|
||||||
use crate::parser::TableRow;
|
use crate::parser::TableRow;
|
||||||
use crate::parser::Target;
|
use crate::parser::Target;
|
||||||
|
use crate::parser::Timestamp;
|
||||||
use crate::parser::Underline;
|
use crate::parser::Underline;
|
||||||
use crate::parser::Verbatim;
|
use crate::parser::Verbatim;
|
||||||
use crate::parser::VerseBlock;
|
use crate::parser::VerseBlock;
|
||||||
@ -180,6 +181,7 @@ fn compare_object<'s>(
|
|||||||
Object::StatisticsCookie(obj) => compare_statistics_cookie(source, emacs, obj),
|
Object::StatisticsCookie(obj) => compare_statistics_cookie(source, emacs, obj),
|
||||||
Object::Subscript(obj) => compare_subscript(source, emacs, obj),
|
Object::Subscript(obj) => compare_subscript(source, emacs, obj),
|
||||||
Object::Superscript(obj) => compare_superscript(source, emacs, obj),
|
Object::Superscript(obj) => compare_superscript(source, emacs, obj),
|
||||||
|
Object::Timestamp(obj) => compare_timestamp(source, emacs, obj),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1563,3 +1565,26 @@ fn compare_superscript<'s>(
|
|||||||
children: Vec::new(),
|
children: Vec::new(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn compare_timestamp<'s>(
|
||||||
|
source: &'s str,
|
||||||
|
emacs: &'s Token<'s>,
|
||||||
|
rust: &'s Timestamp<'s>,
|
||||||
|
) -> Result<DiffResult, Box<dyn std::error::Error>> {
|
||||||
|
let mut this_status = DiffStatus::Good;
|
||||||
|
let emacs_name = "timestamp";
|
||||||
|
if assert_name(emacs, emacs_name).is_err() {
|
||||||
|
this_status = DiffStatus::Bad;
|
||||||
|
}
|
||||||
|
|
||||||
|
if assert_bounds(source, emacs, rust).is_err() {
|
||||||
|
this_status = DiffStatus::Bad;
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(DiffResult {
|
||||||
|
status: this_status,
|
||||||
|
name: emacs_name.to_owned(),
|
||||||
|
message: None,
|
||||||
|
children: Vec::new(),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
@ -47,6 +47,7 @@ mod subscript_and_superscript;
|
|||||||
mod table;
|
mod table;
|
||||||
mod target;
|
mod target;
|
||||||
mod text_markup;
|
mod text_markup;
|
||||||
|
mod timestamp;
|
||||||
mod token;
|
mod token;
|
||||||
mod util;
|
mod util;
|
||||||
pub use document::document;
|
pub use document::document;
|
||||||
@ -104,6 +105,7 @@ pub use object::StrikeThrough;
|
|||||||
pub use object::Subscript;
|
pub use object::Subscript;
|
||||||
pub use object::Superscript;
|
pub use object::Superscript;
|
||||||
pub use object::Target;
|
pub use object::Target;
|
||||||
|
pub use object::Timestamp;
|
||||||
pub use object::Underline;
|
pub use object::Underline;
|
||||||
pub use object::Verbatim;
|
pub use object::Verbatim;
|
||||||
pub use source::Source;
|
pub use source::Source;
|
||||||
|
@ -28,6 +28,7 @@ pub enum Object<'s> {
|
|||||||
StatisticsCookie(StatisticsCookie<'s>),
|
StatisticsCookie(StatisticsCookie<'s>),
|
||||||
Subscript(Subscript<'s>),
|
Subscript(Subscript<'s>),
|
||||||
Superscript(Superscript<'s>),
|
Superscript(Superscript<'s>),
|
||||||
|
Timestamp(Timestamp<'s>),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, PartialEq)]
|
#[derive(Debug, PartialEq)]
|
||||||
@ -179,6 +180,11 @@ pub struct Superscript<'s> {
|
|||||||
pub source: &'s str,
|
pub source: &'s str,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, PartialEq)]
|
||||||
|
pub struct Timestamp<'s> {
|
||||||
|
pub source: &'s str,
|
||||||
|
}
|
||||||
|
|
||||||
impl<'s> Source<'s> for Object<'s> {
|
impl<'s> Source<'s> for Object<'s> {
|
||||||
fn get_source(&'s self) -> &'s str {
|
fn get_source(&'s self) -> &'s str {
|
||||||
match self {
|
match self {
|
||||||
@ -205,6 +211,7 @@ impl<'s> Source<'s> for Object<'s> {
|
|||||||
Object::InlineSourceBlock(obj) => obj.source,
|
Object::InlineSourceBlock(obj) => obj.source,
|
||||||
Object::LineBreak(obj) => obj.source,
|
Object::LineBreak(obj) => obj.source,
|
||||||
Object::Target(obj) => obj.source,
|
Object::Target(obj) => obj.source,
|
||||||
|
Object::Timestamp(obj) => obj.source,
|
||||||
Object::StatisticsCookie(obj) => obj.source,
|
Object::StatisticsCookie(obj) => obj.source,
|
||||||
Object::Subscript(obj) => obj.source,
|
Object::Subscript(obj) => obj.source,
|
||||||
Object::Superscript(obj) => obj.source,
|
Object::Superscript(obj) => obj.source,
|
||||||
@ -361,3 +368,9 @@ impl<'s> Source<'s> for Superscript<'s> {
|
|||||||
self.source
|
self.source
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<'s> Source<'s> for Timestamp<'s> {
|
||||||
|
fn get_source(&'s self) -> &'s str {
|
||||||
|
self.source
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -26,16 +26,17 @@ use crate::parser::subscript_and_superscript::subscript;
|
|||||||
use crate::parser::subscript_and_superscript::superscript;
|
use crate::parser::subscript_and_superscript::superscript;
|
||||||
use crate::parser::target::target;
|
use crate::parser::target::target;
|
||||||
use crate::parser::text_markup::text_markup;
|
use crate::parser::text_markup::text_markup;
|
||||||
|
use crate::parser::timestamp::timestamp;
|
||||||
|
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[tracing::instrument(ret, level = "debug")]
|
||||||
pub fn standard_set_object<'r, 's>(
|
pub fn standard_set_object<'r, 's>(
|
||||||
context: Context<'r, 's>,
|
context: Context<'r, 's>,
|
||||||
input: &'s str,
|
input: &'s str,
|
||||||
) -> Res<&'s str, Object<'s>> {
|
) -> Res<&'s str, Object<'s>> {
|
||||||
// TODO: subscript and superscript, timestamps.
|
|
||||||
not(|i| context.check_exit_matcher(i))(input)?;
|
not(|i| context.check_exit_matcher(i))(input)?;
|
||||||
|
|
||||||
alt((
|
alt((
|
||||||
|
map(parser_with_context!(timestamp)(context), Object::Timestamp),
|
||||||
map(parser_with_context!(subscript)(context), Object::Subscript),
|
map(parser_with_context!(subscript)(context), Object::Subscript),
|
||||||
map(
|
map(
|
||||||
parser_with_context!(superscript)(context),
|
parser_with_context!(superscript)(context),
|
||||||
@ -116,6 +117,7 @@ pub fn any_object_except_plain_text<'r, 's>(
|
|||||||
) -> Res<&'s str, Object<'s>> {
|
) -> Res<&'s str, Object<'s>> {
|
||||||
// Used for exit matchers so this does not check exit matcher condition.
|
// Used for exit matchers so this does not check exit matcher condition.
|
||||||
alt((
|
alt((
|
||||||
|
map(parser_with_context!(timestamp)(context), Object::Timestamp),
|
||||||
map(parser_with_context!(subscript)(context), Object::Subscript),
|
map(parser_with_context!(subscript)(context), Object::Subscript),
|
||||||
map(
|
map(
|
||||||
parser_with_context!(superscript)(context),
|
parser_with_context!(superscript)(context),
|
||||||
@ -170,8 +172,12 @@ pub fn regular_link_description_object_set<'r, 's>(
|
|||||||
context: Context<'r, 's>,
|
context: Context<'r, 's>,
|
||||||
input: &'s str,
|
input: &'s str,
|
||||||
) -> Res<&'s str, Object<'s>> {
|
) -> 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 ]]
|
// TODO: It can also contain another link, but only when it is a plain or angle link. It can contain square brackets, but not ]]
|
||||||
alt((
|
alt((
|
||||||
|
map(
|
||||||
|
parser_with_context!(export_snippet)(context),
|
||||||
|
Object::ExportSnippet,
|
||||||
|
),
|
||||||
map(
|
map(
|
||||||
parser_with_context!(statistics_cookie)(context),
|
parser_with_context!(statistics_cookie)(context),
|
||||||
Object::StatisticsCookie,
|
Object::StatisticsCookie,
|
||||||
|
10
src/parser/timestamp.rs
Normal file
10
src/parser/timestamp.rs
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
use super::Context;
|
||||||
|
use crate::error::Res;
|
||||||
|
use crate::parser::util::not_yet_implemented;
|
||||||
|
use crate::parser::Timestamp;
|
||||||
|
|
||||||
|
#[tracing::instrument(ret, level = "debug")]
|
||||||
|
pub fn timestamp<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, Timestamp<'s>> {
|
||||||
|
not_yet_implemented()?;
|
||||||
|
todo!()
|
||||||
|
}
|
@ -67,6 +67,7 @@ impl<'r, 's> Token<'r, 's> {
|
|||||||
Object::StatisticsCookie(_) => Box::new(std::iter::empty()),
|
Object::StatisticsCookie(_) => Box::new(std::iter::empty()),
|
||||||
Object::Subscript(_) => Box::new(std::iter::empty()), // TODO: Iterate over children
|
Object::Subscript(_) => Box::new(std::iter::empty()), // TODO: Iterate over children
|
||||||
Object::Superscript(_) => Box::new(std::iter::empty()), // TODO: Iterate over children
|
Object::Superscript(_) => Box::new(std::iter::empty()), // TODO: Iterate over children
|
||||||
|
Object::Timestamp(_) => Box::new(std::iter::empty()),
|
||||||
},
|
},
|
||||||
Token::Element(elem) => match elem {
|
Token::Element(elem) => match elem {
|
||||||
Element::Paragraph(inner) => Box::new(inner.children.iter().map(Token::Object)),
|
Element::Paragraph(inner) => Box::new(inner.children.iter().map(Token::Object)),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user