Create structure for statistics cookies.
This commit is contained in:
parent
abb0aeacaf
commit
c73e26e2d6
@ -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<DiffResult, Box<dyn std::error::Error>> {
|
||||
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(),
|
||||
})
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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
|
||||
}
|
||||
}
|
||||
|
13
src/parser/statistics_cookie.rs
Normal file
13
src/parser/statistics_cookie.rs
Normal file
@ -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!()
|
||||
}
|
@ -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)),
|
||||
|
Loading…
Reference in New Issue
Block a user