383 lines
8.1 KiB
Rust
383 lines
8.1 KiB
Rust
use super::source::Source;
|
|
|
|
#[derive(Debug, PartialEq)]
|
|
pub enum Object<'s> {
|
|
Bold(Bold<'s>),
|
|
Italic(Italic<'s>),
|
|
Underline(Underline<'s>),
|
|
StrikeThrough(StrikeThrough<'s>),
|
|
Code(Code<'s>),
|
|
Verbatim(Verbatim<'s>),
|
|
PlainText(PlainText<'s>),
|
|
RegularLink(RegularLink<'s>),
|
|
RadioLink(RadioLink<'s>),
|
|
RadioTarget(RadioTarget<'s>),
|
|
PlainLink(PlainLink<'s>),
|
|
AngleLink(AngleLink<'s>),
|
|
OrgMacro(OrgMacro<'s>),
|
|
Entity(Entity<'s>),
|
|
LatexFragment(LatexFragment<'s>),
|
|
ExportSnippet(ExportSnippet<'s>),
|
|
FootnoteReference(FootnoteReference<'s>),
|
|
Citation(Citation<'s>),
|
|
CitationReference(CitationReference<'s>),
|
|
InlineBabelCall(InlineBabelCall<'s>),
|
|
InlineSourceBlock(InlineSourceBlock<'s>),
|
|
LineBreak(LineBreak<'s>),
|
|
Target(Target<'s>),
|
|
StatisticsCookie(StatisticsCookie<'s>),
|
|
Subscript(Subscript<'s>),
|
|
Superscript(Superscript<'s>),
|
|
Timestamp(Timestamp<'s>),
|
|
}
|
|
|
|
#[derive(Debug, PartialEq)]
|
|
pub struct Bold<'s> {
|
|
pub source: &'s str,
|
|
pub children: Vec<Object<'s>>,
|
|
}
|
|
|
|
#[derive(Debug, PartialEq)]
|
|
pub struct Italic<'s> {
|
|
pub source: &'s str,
|
|
pub children: Vec<Object<'s>>,
|
|
}
|
|
|
|
#[derive(Debug, PartialEq)]
|
|
pub struct Underline<'s> {
|
|
pub source: &'s str,
|
|
pub children: Vec<Object<'s>>,
|
|
}
|
|
|
|
#[derive(Debug, PartialEq)]
|
|
pub struct StrikeThrough<'s> {
|
|
pub source: &'s str,
|
|
pub children: Vec<Object<'s>>,
|
|
}
|
|
|
|
#[derive(Debug, PartialEq)]
|
|
pub struct Code<'s> {
|
|
pub source: &'s str,
|
|
pub contents: &'s str,
|
|
}
|
|
|
|
#[derive(Debug, PartialEq)]
|
|
pub struct Verbatim<'s> {
|
|
pub source: &'s str,
|
|
pub contents: &'s str,
|
|
}
|
|
|
|
#[derive(Debug, PartialEq)]
|
|
pub struct PlainText<'s> {
|
|
pub source: &'s str,
|
|
}
|
|
|
|
#[derive(Debug, PartialEq)]
|
|
pub struct RegularLink<'s> {
|
|
pub source: &'s str,
|
|
}
|
|
|
|
#[derive(Debug, PartialEq)]
|
|
pub struct RadioTarget<'s> {
|
|
pub source: &'s str,
|
|
pub children: Vec<Object<'s>>,
|
|
}
|
|
|
|
#[derive(Debug, PartialEq)]
|
|
pub struct RadioLink<'s> {
|
|
pub source: &'s str,
|
|
pub children: Vec<Object<'s>>,
|
|
}
|
|
|
|
#[derive(Debug, PartialEq)]
|
|
pub struct PlainLink<'s> {
|
|
pub source: &'s str,
|
|
pub link_type: &'s str,
|
|
pub path: &'s str,
|
|
}
|
|
|
|
#[derive(Debug, PartialEq)]
|
|
pub struct AngleLink<'s> {
|
|
pub source: &'s str,
|
|
pub link_type: &'s str,
|
|
pub path: &'s str,
|
|
}
|
|
|
|
#[derive(Debug, PartialEq)]
|
|
pub struct OrgMacro<'s> {
|
|
pub source: &'s str,
|
|
pub macro_name: &'s str,
|
|
pub macro_args: Vec<&'s str>,
|
|
}
|
|
|
|
#[derive(Debug, PartialEq)]
|
|
pub struct Entity<'s> {
|
|
pub source: &'s str,
|
|
pub entity_name: &'s str,
|
|
}
|
|
|
|
#[derive(Debug, PartialEq)]
|
|
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: Option<&'s str>,
|
|
}
|
|
|
|
#[derive(Debug, PartialEq)]
|
|
pub struct FootnoteReference<'s> {
|
|
pub source: &'s str,
|
|
pub label: Option<&'s str>,
|
|
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,
|
|
}
|
|
|
|
#[derive(Debug, PartialEq)]
|
|
pub struct InlineBabelCall<'s> {
|
|
pub source: &'s str,
|
|
}
|
|
|
|
#[derive(Debug, PartialEq)]
|
|
pub struct InlineSourceBlock<'s> {
|
|
pub source: &'s str,
|
|
}
|
|
|
|
#[derive(Debug, PartialEq)]
|
|
pub struct LineBreak<'s> {
|
|
pub source: &'s str,
|
|
}
|
|
|
|
#[derive(Debug, PartialEq)]
|
|
pub struct Target<'s> {
|
|
pub source: &'s str,
|
|
}
|
|
|
|
#[derive(Debug, PartialEq)]
|
|
pub struct StatisticsCookie<'s> {
|
|
pub source: &'s str,
|
|
}
|
|
|
|
#[derive(Debug, PartialEq)]
|
|
pub struct Subscript<'s> {
|
|
pub source: &'s str,
|
|
}
|
|
|
|
#[derive(Debug, PartialEq)]
|
|
pub struct Superscript<'s> {
|
|
pub source: &'s str,
|
|
}
|
|
|
|
#[derive(Debug, PartialEq)]
|
|
pub struct Timestamp<'s> {
|
|
pub source: &'s str,
|
|
}
|
|
|
|
impl<'s> Source<'s> for Object<'s> {
|
|
fn get_source(&'s self) -> &'s str {
|
|
match self {
|
|
Object::Bold(obj) => obj.source,
|
|
Object::Italic(obj) => obj.source,
|
|
Object::Underline(obj) => obj.source,
|
|
Object::StrikeThrough(obj) => obj.source,
|
|
Object::Code(obj) => obj.source,
|
|
Object::Verbatim(obj) => obj.source,
|
|
Object::PlainText(obj) => obj.source,
|
|
Object::RegularLink(obj) => obj.source,
|
|
Object::RadioLink(obj) => obj.source,
|
|
Object::RadioTarget(obj) => obj.source,
|
|
Object::PlainLink(obj) => obj.source,
|
|
Object::AngleLink(obj) => obj.source,
|
|
Object::OrgMacro(obj) => obj.source,
|
|
Object::Entity(obj) => obj.source,
|
|
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,
|
|
Object::InlineBabelCall(obj) => obj.source,
|
|
Object::InlineSourceBlock(obj) => obj.source,
|
|
Object::LineBreak(obj) => obj.source,
|
|
Object::Target(obj) => obj.source,
|
|
Object::Timestamp(obj) => obj.source,
|
|
Object::StatisticsCookie(obj) => obj.source,
|
|
Object::Subscript(obj) => obj.source,
|
|
Object::Superscript(obj) => obj.source,
|
|
}
|
|
}
|
|
}
|
|
|
|
impl<'s> Source<'s> for Bold<'s> {
|
|
fn get_source(&'s self) -> &'s str {
|
|
self.source
|
|
}
|
|
}
|
|
|
|
impl<'s> Source<'s> for Italic<'s> {
|
|
fn get_source(&'s self) -> &'s str {
|
|
self.source
|
|
}
|
|
}
|
|
|
|
impl<'s> Source<'s> for Underline<'s> {
|
|
fn get_source(&'s self) -> &'s str {
|
|
self.source
|
|
}
|
|
}
|
|
|
|
impl<'s> Source<'s> for StrikeThrough<'s> {
|
|
fn get_source(&'s self) -> &'s str {
|
|
self.source
|
|
}
|
|
}
|
|
|
|
impl<'s> Source<'s> for Code<'s> {
|
|
fn get_source(&'s self) -> &'s str {
|
|
self.source
|
|
}
|
|
}
|
|
|
|
impl<'s> Source<'s> for Verbatim<'s> {
|
|
fn get_source(&'s self) -> &'s str {
|
|
self.source
|
|
}
|
|
}
|
|
|
|
impl<'s> Source<'s> for RegularLink<'s> {
|
|
fn get_source(&'s self) -> &'s str {
|
|
self.source
|
|
}
|
|
}
|
|
|
|
impl<'s> Source<'s> for RadioLink<'s> {
|
|
fn get_source(&'s self) -> &'s str {
|
|
self.source
|
|
}
|
|
}
|
|
|
|
impl<'s> Source<'s> for RadioTarget<'s> {
|
|
fn get_source(&'s self) -> &'s str {
|
|
self.source
|
|
}
|
|
}
|
|
|
|
impl<'s> Source<'s> for PlainLink<'s> {
|
|
fn get_source(&'s self) -> &'s str {
|
|
self.source
|
|
}
|
|
}
|
|
|
|
impl<'s> Source<'s> for AngleLink<'s> {
|
|
fn get_source(&'s self) -> &'s str {
|
|
self.source
|
|
}
|
|
}
|
|
|
|
impl<'s> Source<'s> for OrgMacro<'s> {
|
|
fn get_source(&'s self) -> &'s str {
|
|
self.source
|
|
}
|
|
}
|
|
|
|
impl<'s> Source<'s> for Entity<'s> {
|
|
fn get_source(&'s self) -> &'s str {
|
|
self.source
|
|
}
|
|
}
|
|
|
|
impl<'s> Source<'s> for LatexFragment<'s> {
|
|
fn get_source(&'s self) -> &'s str {
|
|
self.source
|
|
}
|
|
}
|
|
|
|
impl<'s> Source<'s> for ExportSnippet<'s> {
|
|
fn get_source(&'s self) -> &'s str {
|
|
self.source
|
|
}
|
|
}
|
|
|
|
impl<'s> Source<'s> for FootnoteReference<'s> {
|
|
fn get_source(&'s self) -> &'s str {
|
|
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
|
|
}
|
|
}
|
|
|
|
impl<'s> Source<'s> for InlineBabelCall<'s> {
|
|
fn get_source(&'s self) -> &'s str {
|
|
self.source
|
|
}
|
|
}
|
|
|
|
impl<'s> Source<'s> for InlineSourceBlock<'s> {
|
|
fn get_source(&'s self) -> &'s str {
|
|
self.source
|
|
}
|
|
}
|
|
|
|
impl<'s> Source<'s> for LineBreak<'s> {
|
|
fn get_source(&'s self) -> &'s str {
|
|
self.source
|
|
}
|
|
}
|
|
|
|
impl<'s> Source<'s> for Target<'s> {
|
|
fn get_source(&'s self) -> &'s str {
|
|
self.source
|
|
}
|
|
}
|
|
|
|
impl<'s> Source<'s> for StatisticsCookie<'s> {
|
|
fn get_source(&'s self) -> &'s str {
|
|
self.source
|
|
}
|
|
}
|
|
|
|
impl<'s> Source<'s> for Subscript<'s> {
|
|
fn get_source(&'s self) -> &'s str {
|
|
self.source
|
|
}
|
|
}
|
|
|
|
impl<'s> Source<'s> for Superscript<'s> {
|
|
fn get_source(&'s self) -> &'s str {
|
|
self.source
|
|
}
|
|
}
|
|
|
|
impl<'s> Source<'s> for Timestamp<'s> {
|
|
fn get_source(&'s self) -> &'s str {
|
|
self.source
|
|
}
|
|
}
|
|
|
|
impl<'s> Source<'s> for PlainText<'s> {
|
|
fn get_source(&'s self) -> &'s str {
|
|
self.source
|
|
}
|
|
}
|