Create structure for statistics cookies.

This commit is contained in:
Tom Alexander
2023-07-22 01:49:07 -04:00
parent abb0aeacaf
commit c73e26e2d6
5 changed files with 54 additions and 0 deletions

View File

@@ -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;

View File

@@ -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
}
}

View 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!()
}

View File

@@ -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)),