Create structure for citations.

This commit is contained in:
Tom Alexander
2023-07-20 00:38:16 -04:00
parent 4e791b175e
commit d5c611674e
6 changed files with 105 additions and 0 deletions

View File

@@ -19,6 +19,8 @@ pub enum Object<'s> {
LatexFragment(LatexFragment<'s>),
ExportSnippet(ExportSnippet<'s>),
FootnoteReference(FootnoteReference<'s>),
Citation(Citation<'s>),
CitationReference(CitationReference<'s>),
}
#[derive(Debug, PartialEq)]
@@ -125,6 +127,16 @@ pub struct FootnoteReference<'s> {
pub definition: Vec<Object<'s>>,
}
#[derive(Debug, PartialEq)]
pub struct Citation<'s> {
pub source: &'s str,
}
#[derive(Debug, PartialEq)]
pub struct CitationReference<'s> {
pub source: &'s str,
}
impl<'s> Source<'s> for Object<'s> {
fn get_source(&'s self) -> &'s str {
match self {
@@ -145,6 +157,8 @@ impl<'s> Source<'s> for Object<'s> {
Object::LatexFragment(obj) => obj.source,
Object::ExportSnippet(obj) => obj.source,
Object::FootnoteReference(obj) => obj.source,
Object::Citation(obj) => obj.source,
Object::CitationReference(obj) => obj.source,
}
}
}
@@ -244,3 +258,15 @@ impl<'s> Source<'s> for FootnoteReference<'s> {
self.source
}
}
impl<'s> Source<'s> for Citation<'s> {
fn get_source(&'s self) -> &'s str {
self.source
}
}
impl<'s> Source<'s> for CitationReference<'s> {
fn get_source(&'s self) -> &'s str {
self.source
}
}