diff --git a/src/compare/diff.rs b/src/compare/diff.rs index f16111d..74cde67 100644 --- a/src/compare/diff.rs +++ b/src/compare/diff.rs @@ -46,6 +46,7 @@ use crate::parser::RadioTarget; use crate::parser::RegularLink; use crate::parser::Section; use crate::parser::SrcBlock; +use crate::parser::StatisticsCookie; use crate::parser::StrikeThrough; use crate::parser::Table; use crate::parser::TableCell; @@ -174,6 +175,7 @@ fn compare_object<'s>( Object::InlineSourceBlock(obj) => compare_inline_source_block(source, emacs, obj), Object::LineBreak(obj) => compare_line_break(source, emacs, obj), Object::Target(obj) => compare_target(source, emacs, obj), + Object::StatisticsCookie(obj) => compare_statistics_cookie(source, emacs, obj), } } @@ -1488,3 +1490,26 @@ fn compare_target<'s>( children: Vec::new(), }) } + +fn compare_statistics_cookie<'s>( + source: &'s str, + emacs: &'s Token<'s>, + rust: &'s StatisticsCookie<'s>, +) -> Result> { + let mut this_status = DiffStatus::Good; + let emacs_name = "statistics-cookie"; + 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(), + }) +} diff --git a/src/parser/mod.rs b/src/parser/mod.rs index 1686606..3f0f284 100644 --- a/src/parser/mod.rs +++ b/src/parser/mod.rs @@ -42,6 +42,7 @@ mod radio_link; mod regular_link; pub mod sexp; mod source; +mod statistics_cookie; mod table; mod target; mod text_markup; @@ -97,6 +98,7 @@ pub use object::PlainText; pub use object::RadioLink; pub use object::RadioTarget; pub use object::RegularLink; +pub use object::StatisticsCookie; pub use object::StrikeThrough; pub use object::Target; pub use object::Underline; diff --git a/src/parser/object.rs b/src/parser/object.rs index ea705a4..300e038 100644 --- a/src/parser/object.rs +++ b/src/parser/object.rs @@ -25,6 +25,7 @@ pub enum Object<'s> { InlineSourceBlock(InlineSourceBlock<'s>), LineBreak(LineBreak<'s>), Target(Target<'s>), + StatisticsCookie(StatisticsCookie<'s>), } #[derive(Debug, PartialEq)] @@ -161,6 +162,11 @@ pub struct Target<'s> { pub source: &'s str, } +#[derive(Debug, PartialEq)] +pub struct StatisticsCookie<'s> { + pub source: &'s str, +} + impl<'s> Source<'s> for Object<'s> { fn get_source(&'s self) -> &'s str { match self { @@ -187,6 +193,7 @@ impl<'s> Source<'s> for Object<'s> { Object::InlineSourceBlock(obj) => obj.source, Object::LineBreak(obj) => obj.source, Object::Target(obj) => obj.source, + Object::StatisticsCookie(obj) => obj.source, } } } @@ -322,3 +329,9 @@ impl<'s> Source<'s> for Target<'s> { self.source } } + +impl<'s> Source<'s> for StatisticsCookie<'s> { + fn get_source(&'s self) -> &'s str { + self.source + } +} diff --git a/src/parser/statistics_cookie.rs b/src/parser/statistics_cookie.rs new file mode 100644 index 0000000..43008a6 --- /dev/null +++ b/src/parser/statistics_cookie.rs @@ -0,0 +1,13 @@ +use super::Context; +use crate::error::Res; +use crate::parser::util::not_yet_implemented; +use crate::parser::StatisticsCookie; + +#[tracing::instrument(ret, level = "debug")] +pub fn statistics_cookie<'r, 's>( + context: Context<'r, 's>, + input: &'s str, +) -> Res<&'s str, StatisticsCookie<'s>> { + not_yet_implemented()?; + todo!() +} diff --git a/src/parser/token.rs b/src/parser/token.rs index f3ebe82..b9ea9dd 100644 --- a/src/parser/token.rs +++ b/src/parser/token.rs @@ -64,6 +64,7 @@ impl<'r, 's> Token<'r, 's> { Object::InlineSourceBlock(_) => Box::new(std::iter::empty()), Object::LineBreak(_) => Box::new(std::iter::empty()), Object::Target(_) => Box::new(std::iter::empty()), + Object::StatisticsCookie(_) => Box::new(std::iter::empty()), }, Token::Element(elem) => match elem { Element::Paragraph(inner) => Box::new(inner.children.iter().map(Token::Object)),