Move over the rest of the types.
This commit is contained in:
56
src/types/document.rs
Normal file
56
src/types/document.rs
Normal file
@@ -0,0 +1,56 @@
|
||||
#[derive(Debug)]
|
||||
pub struct Document<'s> {
|
||||
pub source: &'s str,
|
||||
pub zeroth_section: Option<Section<'s>>,
|
||||
pub children: Vec<Heading<'s>>,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct Heading<'s> {
|
||||
pub source: &'s str,
|
||||
pub stars: usize,
|
||||
pub todo_keyword: Option<&'s str>,
|
||||
// TODO: add todo-type enum
|
||||
pub title: Vec<Object<'s>>,
|
||||
pub tags: Vec<&'s str>,
|
||||
pub children: Vec<DocumentElement<'s>>,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct Section<'s> {
|
||||
pub source: &'s str,
|
||||
pub children: Vec<Element<'s>>,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub enum DocumentElement<'s> {
|
||||
Heading(Heading<'s>),
|
||||
Section(Section<'s>),
|
||||
}
|
||||
|
||||
impl<'s> Source<'s> for Document<'s> {
|
||||
fn get_source(&'s self) -> &'s str {
|
||||
self.source
|
||||
}
|
||||
}
|
||||
|
||||
impl<'s> Source<'s> for DocumentElement<'s> {
|
||||
fn get_source(&'s self) -> &'s str {
|
||||
match self {
|
||||
DocumentElement::Heading(obj) => obj.source,
|
||||
DocumentElement::Section(obj) => obj.source,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'s> Source<'s> for Section<'s> {
|
||||
fn get_source(&'s self) -> &'s str {
|
||||
self.source
|
||||
}
|
||||
}
|
||||
|
||||
impl<'s> Source<'s> for Heading<'s> {
|
||||
fn get_source(&'s self) -> &'s str {
|
||||
self.source
|
||||
}
|
||||
}
|
||||
103
src/types/element.rs
Normal file
103
src/types/element.rs
Normal file
@@ -0,0 +1,103 @@
|
||||
use super::greater_element::DynamicBlock;
|
||||
use super::greater_element::FootnoteDefinition;
|
||||
use super::greater_element::GreaterBlock;
|
||||
use super::greater_element::PlainList;
|
||||
use super::greater_element::PropertyDrawer;
|
||||
use super::greater_element::Table;
|
||||
use super::lesser_element::Clock;
|
||||
use super::lesser_element::Comment;
|
||||
use super::lesser_element::CommentBlock;
|
||||
use super::lesser_element::DiarySexp;
|
||||
use super::lesser_element::ExampleBlock;
|
||||
use super::lesser_element::ExportBlock;
|
||||
use super::lesser_element::FixedWidthArea;
|
||||
use super::lesser_element::HorizontalRule;
|
||||
use super::lesser_element::Keyword;
|
||||
use super::lesser_element::LatexEnvironment;
|
||||
use super::lesser_element::Paragraph;
|
||||
use super::lesser_element::Planning;
|
||||
use super::lesser_element::SrcBlock;
|
||||
use super::lesser_element::VerseBlock;
|
||||
use super::Drawer;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub enum Element<'s> {
|
||||
Paragraph(Paragraph<'s>),
|
||||
PlainList(PlainList<'s>),
|
||||
GreaterBlock(GreaterBlock<'s>),
|
||||
DynamicBlock(DynamicBlock<'s>),
|
||||
FootnoteDefinition(FootnoteDefinition<'s>),
|
||||
Comment(Comment<'s>),
|
||||
Drawer(Drawer<'s>),
|
||||
PropertyDrawer(PropertyDrawer<'s>),
|
||||
Table(Table<'s>),
|
||||
VerseBlock(VerseBlock<'s>),
|
||||
CommentBlock(CommentBlock<'s>),
|
||||
ExampleBlock(ExampleBlock<'s>),
|
||||
ExportBlock(ExportBlock<'s>),
|
||||
SrcBlock(SrcBlock<'s>),
|
||||
Clock(Clock<'s>),
|
||||
DiarySexp(DiarySexp<'s>),
|
||||
Planning(Planning<'s>),
|
||||
FixedWidthArea(FixedWidthArea<'s>),
|
||||
HorizontalRule(HorizontalRule<'s>),
|
||||
Keyword(Keyword<'s>),
|
||||
LatexEnvironment(LatexEnvironment<'s>),
|
||||
}
|
||||
|
||||
impl<'s> Source<'s> for Element<'s> {
|
||||
fn get_source(&'s self) -> &'s str {
|
||||
match self {
|
||||
Element::Paragraph(obj) => obj.source,
|
||||
Element::PlainList(obj) => obj.source,
|
||||
Element::GreaterBlock(obj) => obj.source,
|
||||
Element::DynamicBlock(obj) => obj.source,
|
||||
Element::FootnoteDefinition(obj) => obj.source,
|
||||
Element::Comment(obj) => obj.source,
|
||||
Element::Drawer(obj) => obj.source,
|
||||
Element::PropertyDrawer(obj) => obj.source,
|
||||
Element::Table(obj) => obj.source,
|
||||
Element::VerseBlock(obj) => obj.source,
|
||||
Element::CommentBlock(obj) => obj.source,
|
||||
Element::ExampleBlock(obj) => obj.source,
|
||||
Element::ExportBlock(obj) => obj.source,
|
||||
Element::SrcBlock(obj) => obj.source,
|
||||
Element::Clock(obj) => obj.source,
|
||||
Element::DiarySexp(obj) => obj.source,
|
||||
Element::Planning(obj) => obj.source,
|
||||
Element::FixedWidthArea(obj) => obj.source,
|
||||
Element::HorizontalRule(obj) => obj.source,
|
||||
Element::Keyword(obj) => obj.source,
|
||||
Element::LatexEnvironment(obj) => obj.source,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'s> SetSource<'s> for Element<'s> {
|
||||
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||
fn set_source(&mut self, source: &'s str) {
|
||||
match self {
|
||||
Element::Paragraph(obj) => obj.source = source,
|
||||
Element::PlainList(obj) => obj.source = source,
|
||||
Element::GreaterBlock(obj) => obj.source = source,
|
||||
Element::DynamicBlock(obj) => obj.source = source,
|
||||
Element::FootnoteDefinition(obj) => obj.source = source,
|
||||
Element::Comment(obj) => obj.source = source,
|
||||
Element::Drawer(obj) => obj.source = source,
|
||||
Element::PropertyDrawer(obj) => obj.source = source,
|
||||
Element::Table(obj) => obj.source = source,
|
||||
Element::VerseBlock(obj) => obj.source = source,
|
||||
Element::CommentBlock(obj) => obj.source = source,
|
||||
Element::ExampleBlock(obj) => obj.source = source,
|
||||
Element::ExportBlock(obj) => obj.source = source,
|
||||
Element::SrcBlock(obj) => obj.source = source,
|
||||
Element::Clock(obj) => obj.source = source,
|
||||
Element::DiarySexp(obj) => obj.source = source,
|
||||
Element::Planning(obj) => obj.source = source,
|
||||
Element::FixedWidthArea(obj) => obj.source = source,
|
||||
Element::HorizontalRule(obj) => obj.source = source,
|
||||
Element::Keyword(obj) => obj.source = source,
|
||||
Element::LatexEnvironment(obj) => obj.source = source,
|
||||
}
|
||||
}
|
||||
}
|
||||
126
src/types/greater_element.rs
Normal file
126
src/types/greater_element.rs
Normal file
@@ -0,0 +1,126 @@
|
||||
use super::element::Element;
|
||||
use super::lesser_element::TableCell;
|
||||
use super::Object;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct PlainList<'s> {
|
||||
pub source: &'s str,
|
||||
pub children: Vec<PlainListItem<'s>>,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct PlainListItem<'s> {
|
||||
pub source: &'s str,
|
||||
pub indentation: usize,
|
||||
pub bullet: &'s str,
|
||||
pub tag: Vec<Object<'s>>,
|
||||
pub children: Vec<Element<'s>>,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct GreaterBlock<'s> {
|
||||
pub source: &'s str,
|
||||
pub name: &'s str,
|
||||
pub parameters: Option<&'s str>,
|
||||
pub children: Vec<Element<'s>>,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct DynamicBlock<'s> {
|
||||
pub source: &'s str,
|
||||
pub name: &'s str,
|
||||
pub parameters: Option<&'s str>,
|
||||
pub children: Vec<Element<'s>>,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct FootnoteDefinition<'s> {
|
||||
pub source: &'s str,
|
||||
pub label: &'s str,
|
||||
pub children: Vec<Element<'s>>,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct Drawer<'s> {
|
||||
pub source: &'s str,
|
||||
pub name: &'s str,
|
||||
pub children: Vec<Element<'s>>,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct PropertyDrawer<'s> {
|
||||
pub source: &'s str,
|
||||
pub children: Vec<NodeProperty<'s>>,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct NodeProperty<'s> {
|
||||
pub source: &'s str,
|
||||
pub value: Option<&'s str>,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct Table<'s> {
|
||||
pub source: &'s str,
|
||||
pub children: Vec<TableRow<'s>>,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct TableRow<'s> {
|
||||
pub source: &'s str,
|
||||
pub children: Vec<TableCell<'s>>,
|
||||
}
|
||||
|
||||
impl<'s> Source<'s> for PlainList<'s> {
|
||||
fn get_source(&'s self) -> &'s str {
|
||||
self.source
|
||||
}
|
||||
}
|
||||
|
||||
impl<'s> Source<'s> for PlainListItem<'s> {
|
||||
fn get_source(&'s self) -> &'s str {
|
||||
self.source
|
||||
}
|
||||
}
|
||||
|
||||
impl<'s> Source<'s> for GreaterBlock<'s> {
|
||||
fn get_source(&'s self) -> &'s str {
|
||||
self.source
|
||||
}
|
||||
}
|
||||
|
||||
impl<'s> Source<'s> for DynamicBlock<'s> {
|
||||
fn get_source(&'s self) -> &'s str {
|
||||
self.source
|
||||
}
|
||||
}
|
||||
|
||||
impl<'s> Source<'s> for FootnoteDefinition<'s> {
|
||||
fn get_source(&'s self) -> &'s str {
|
||||
self.source
|
||||
}
|
||||
}
|
||||
|
||||
impl<'s> Source<'s> for Drawer<'s> {
|
||||
fn get_source(&'s self) -> &'s str {
|
||||
self.source
|
||||
}
|
||||
}
|
||||
|
||||
impl<'s> Source<'s> for PropertyDrawer<'s> {
|
||||
fn get_source(&'s self) -> &'s str {
|
||||
self.source
|
||||
}
|
||||
}
|
||||
|
||||
impl<'s> Source<'s> for Table<'s> {
|
||||
fn get_source(&'s self) -> &'s str {
|
||||
self.source
|
||||
}
|
||||
}
|
||||
|
||||
impl<'s> Source<'s> for TableRow<'s> {
|
||||
fn get_source(&'s self) -> &'s str {
|
||||
self.source
|
||||
}
|
||||
}
|
||||
191
src/types/lesser_element.rs
Normal file
191
src/types/lesser_element.rs
Normal file
@@ -0,0 +1,191 @@
|
||||
use super::object::Object;
|
||||
use super::PlainText;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct Paragraph<'s> {
|
||||
pub source: &'s str,
|
||||
pub children: Vec<Object<'s>>,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct Comment<'s> {
|
||||
pub source: &'s str,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct TableCell<'s> {
|
||||
pub source: &'s str,
|
||||
pub children: Vec<Object<'s>>,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct VerseBlock<'s> {
|
||||
pub source: &'s str,
|
||||
pub name: &'s str,
|
||||
pub data: Option<&'s str>,
|
||||
pub children: Vec<Object<'s>>,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct CommentBlock<'s> {
|
||||
pub source: &'s str,
|
||||
pub name: &'s str,
|
||||
pub data: Option<&'s str>,
|
||||
pub contents: &'s str,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct ExampleBlock<'s> {
|
||||
pub source: &'s str,
|
||||
pub name: &'s str,
|
||||
pub data: Option<&'s str>,
|
||||
pub contents: &'s str,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct ExportBlock<'s> {
|
||||
pub source: &'s str,
|
||||
pub name: &'s str,
|
||||
pub data: Option<&'s str>,
|
||||
pub contents: &'s str,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct SrcBlock<'s> {
|
||||
pub source: &'s str,
|
||||
pub name: &'s str,
|
||||
pub data: Option<&'s str>,
|
||||
pub contents: &'s str,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct Clock<'s> {
|
||||
pub source: &'s str,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct DiarySexp<'s> {
|
||||
pub source: &'s str,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct Planning<'s> {
|
||||
pub source: &'s str,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct FixedWidthArea<'s> {
|
||||
pub source: &'s str,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct HorizontalRule<'s> {
|
||||
pub source: &'s str,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct Keyword<'s> {
|
||||
pub source: &'s str,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct LatexEnvironment<'s> {
|
||||
pub source: &'s str,
|
||||
}
|
||||
|
||||
impl<'s> Paragraph<'s> {
|
||||
pub fn of_text(input: &'s str) -> Self {
|
||||
let mut objects = Vec::with_capacity(1);
|
||||
objects.push(Object::PlainText(PlainText { source: input }));
|
||||
Paragraph {
|
||||
source: input,
|
||||
children: objects,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'s> Source<'s> for Paragraph<'s> {
|
||||
fn get_source(&'s self) -> &'s str {
|
||||
self.source
|
||||
}
|
||||
}
|
||||
|
||||
impl<'s> Source<'s> for TableCell<'s> {
|
||||
fn get_source(&'s self) -> &'s str {
|
||||
self.source
|
||||
}
|
||||
}
|
||||
|
||||
impl<'s> Source<'s> for Comment<'s> {
|
||||
fn get_source(&'s self) -> &'s str {
|
||||
self.source
|
||||
}
|
||||
}
|
||||
|
||||
impl<'s> Source<'s> for VerseBlock<'s> {
|
||||
fn get_source(&'s self) -> &'s str {
|
||||
self.source
|
||||
}
|
||||
}
|
||||
impl<'s> Source<'s> for CommentBlock<'s> {
|
||||
fn get_source(&'s self) -> &'s str {
|
||||
self.source
|
||||
}
|
||||
}
|
||||
impl<'s> Source<'s> for ExampleBlock<'s> {
|
||||
fn get_source(&'s self) -> &'s str {
|
||||
self.source
|
||||
}
|
||||
}
|
||||
impl<'s> Source<'s> for ExportBlock<'s> {
|
||||
fn get_source(&'s self) -> &'s str {
|
||||
self.source
|
||||
}
|
||||
}
|
||||
impl<'s> Source<'s> for SrcBlock<'s> {
|
||||
fn get_source(&'s self) -> &'s str {
|
||||
self.source
|
||||
}
|
||||
}
|
||||
|
||||
impl<'s> Source<'s> for Clock<'s> {
|
||||
fn get_source(&'s self) -> &'s str {
|
||||
self.source
|
||||
}
|
||||
}
|
||||
|
||||
impl<'s> Source<'s> for DiarySexp<'s> {
|
||||
fn get_source(&'s self) -> &'s str {
|
||||
self.source
|
||||
}
|
||||
}
|
||||
|
||||
impl<'s> Source<'s> for Planning<'s> {
|
||||
fn get_source(&'s self) -> &'s str {
|
||||
self.source
|
||||
}
|
||||
}
|
||||
|
||||
impl<'s> Source<'s> for FixedWidthArea<'s> {
|
||||
fn get_source(&'s self) -> &'s str {
|
||||
self.source
|
||||
}
|
||||
}
|
||||
|
||||
impl<'s> Source<'s> for HorizontalRule<'s> {
|
||||
fn get_source(&'s self) -> &'s str {
|
||||
self.source
|
||||
}
|
||||
}
|
||||
|
||||
impl<'s> Source<'s> for Keyword<'s> {
|
||||
fn get_source(&'s self) -> &'s str {
|
||||
self.source
|
||||
}
|
||||
}
|
||||
|
||||
impl<'s> Source<'s> for LatexEnvironment<'s> {
|
||||
fn get_source(&'s self) -> &'s str {
|
||||
self.source
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
mod document;
|
||||
mod element;
|
||||
mod greater_element;
|
||||
mod lesser_element;
|
||||
mod object;
|
||||
mod source;
|
||||
pub use document::Document;
|
||||
pub use document::DocumentElement;
|
||||
pub use document::Heading;
|
||||
pub use document::Section;
|
||||
pub use element::Element;
|
||||
pub use greater_element::Drawer;
|
||||
pub use greater_element::DynamicBlock;
|
||||
pub use greater_element::FootnoteDefinition;
|
||||
pub use greater_element::GreaterBlock;
|
||||
pub use greater_element::PlainList;
|
||||
pub use greater_element::PlainListItem;
|
||||
pub use greater_element::PropertyDrawer;
|
||||
pub use greater_element::Table;
|
||||
pub use greater_element::TableRow;
|
||||
pub use lesser_element::Clock;
|
||||
pub use lesser_element::Comment;
|
||||
pub use lesser_element::CommentBlock;
|
||||
pub use lesser_element::DiarySexp;
|
||||
pub use lesser_element::ExampleBlock;
|
||||
pub use lesser_element::ExportBlock;
|
||||
pub use lesser_element::FixedWidthArea;
|
||||
pub use lesser_element::HorizontalRule;
|
||||
pub use lesser_element::Keyword;
|
||||
pub use lesser_element::LatexEnvironment;
|
||||
pub use lesser_element::Paragraph;
|
||||
pub use lesser_element::Planning;
|
||||
pub use lesser_element::SrcBlock;
|
||||
pub use lesser_element::TableCell;
|
||||
pub use lesser_element::VerseBlock;
|
||||
pub use object::AngleLink;
|
||||
pub use object::Bold;
|
||||
pub use object::Citation;
|
||||
pub use object::CitationReference;
|
||||
pub use object::Code;
|
||||
pub use object::Entity;
|
||||
pub use object::ExportSnippet;
|
||||
pub use object::FootnoteReference;
|
||||
pub use object::InlineBabelCall;
|
||||
pub use object::InlineSourceBlock;
|
||||
pub use object::Italic;
|
||||
pub use object::LatexFragment;
|
||||
pub use object::LineBreak;
|
||||
pub use object::Object;
|
||||
pub use object::OrgMacro;
|
||||
pub use object::PlainLink;
|
||||
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::Subscript;
|
||||
pub use object::Superscript;
|
||||
pub use object::Target;
|
||||
pub use object::Timestamp;
|
||||
pub use object::Underline;
|
||||
pub use object::Verbatim;
|
||||
pub use source::SetSource;
|
||||
pub use source::Source;
|
||||
|
||||
380
src/types/object.rs
Normal file
380
src/types/object.rs
Normal file
@@ -0,0 +1,380 @@
|
||||
#[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
|
||||
}
|
||||
}
|
||||
6
src/types/source.rs
Normal file
6
src/types/source.rs
Normal file
@@ -0,0 +1,6 @@
|
||||
pub trait Source<'s> {
|
||||
fn get_source(&'s self) -> &'s str;
|
||||
}
|
||||
pub trait SetSource<'s> {
|
||||
fn set_source(&mut self, source: &'s str);
|
||||
}
|
||||
Reference in New Issue
Block a user