diff --git a/src/compare/diff.rs b/src/compare/diff.rs index 3ec5328..61f0479 100644 --- a/src/compare/diff.rs +++ b/src/compare/diff.rs @@ -16,6 +16,7 @@ use crate::parser::Element; use crate::parser::Entity; use crate::parser::ExampleBlock; use crate::parser::ExportBlock; +use crate::parser::ExportSnippet; use crate::parser::FixedWidthArea; use crate::parser::FootnoteDefinition; use crate::parser::GreaterBlock; @@ -158,6 +159,7 @@ fn compare_object<'s>( Object::OrgMacro(obj) => compare_org_macro(source, emacs, obj), Object::Entity(obj) => compare_entity(source, emacs, obj), Object::LatexFragment(obj) => compare_latex_fragment(source, emacs, obj), + Object::ExportSnippet(obj) => compare_export_snippet(source, emacs, obj), } } @@ -1288,3 +1290,26 @@ fn compare_latex_fragment<'s>( children: Vec::new(), }) } + +fn compare_export_snippet<'s>( + source: &'s str, + emacs: &'s Token<'s>, + rust: &'s ExportSnippet<'s>, +) -> Result> { + let mut this_status = DiffStatus::Good; + let emacs_name = "export-snippet"; + 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/export_snippet.rs b/src/parser/export_snippet.rs new file mode 100644 index 0000000..08ad0b7 --- /dev/null +++ b/src/parser/export_snippet.rs @@ -0,0 +1,13 @@ +use super::Context; +use crate::error::Res; +use crate::parser::util::not_yet_implemented; +use crate::parser::ExportSnippet; + +#[tracing::instrument(ret, level = "debug")] +pub fn export_snippet<'r, 's>( + context: Context<'r, 's>, + input: &'s str, +) -> Res<&'s str, ExportSnippet<'s>> { + not_yet_implemented()?; + todo!() +} diff --git a/src/parser/mod.rs b/src/parser/mod.rs index 0f41c30..45d687b 100644 --- a/src/parser/mod.rs +++ b/src/parser/mod.rs @@ -9,6 +9,7 @@ mod element; mod element_parser; mod entity; mod exiting; +mod export_snippet; mod fixed_width_area; mod footnote_definition; mod greater_block; @@ -73,6 +74,7 @@ pub use object::AngleLink; pub use object::Bold; pub use object::Code; pub use object::Entity; +pub use object::ExportSnippet; pub use object::Italic; pub use object::LatexFragment; pub use object::Object; diff --git a/src/parser/object.rs b/src/parser/object.rs index 7aa01f5..1a48673 100644 --- a/src/parser/object.rs +++ b/src/parser/object.rs @@ -17,6 +17,7 @@ pub enum Object<'s> { OrgMacro(OrgMacro<'s>), Entity(Entity<'s>), LatexFragment(LatexFragment<'s>), + ExportSnippet(ExportSnippet<'s>), } #[derive(Debug, PartialEq)] @@ -109,6 +110,13 @@ pub struct LatexFragment<'s> { pub source: &'s str, } +#[derive(Debug, PartialEq)] +pub struct ExportSnippet<'s> { + pub source: &'s str, + pub backend: &'s str, + pub contents: &'s str, +} + impl<'s> Source<'s> for Object<'s> { fn get_source(&'s self) -> &'s str { match self { @@ -127,6 +135,7 @@ impl<'s> Source<'s> for Object<'s> { Object::OrgMacro(obj) => obj.source, Object::Entity(obj) => obj.source, Object::LatexFragment(obj) => obj.source, + Object::ExportSnippet(obj) => obj.source, } } } @@ -214,3 +223,9 @@ impl<'s> Source<'s> for LatexFragment<'s> { self.source } } + +impl<'s> Source<'s> for ExportSnippet<'s> { + fn get_source(&'s self) -> &'s str { + self.source + } +} diff --git a/src/parser/token.rs b/src/parser/token.rs index 04deabf..c97cbe1 100644 --- a/src/parser/token.rs +++ b/src/parser/token.rs @@ -54,6 +54,7 @@ impl<'r, 's> Token<'r, 's> { Object::OrgMacro(_) => Box::new(std::iter::empty()), Object::Entity(_) => Box::new(std::iter::empty()), Object::LatexFragment(_) => Box::new(std::iter::empty()), + Object::ExportSnippet(_) => Box::new(std::iter::empty()), }, Token::Element(elem) => match elem { Element::Paragraph(inner) => Box::new(inner.children.iter().map(Token::Object)),