Create structure for export snippets.

This commit is contained in:
Tom Alexander
2023-07-19 00:09:16 -04:00
parent eb03342506
commit 1fb8ce9af6
5 changed files with 56 additions and 0 deletions

View File

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