2023-03-23 17:51:49 -04:00
|
|
|
use super::source::Source;
|
2023-03-23 17:02:08 -04:00
|
|
|
|
2023-04-24 19:25:22 -04:00
|
|
|
#[derive(Debug, PartialEq)]
|
2023-03-23 16:49:52 -04:00
|
|
|
pub enum Object<'s> {
|
2023-04-22 20:22:07 -04:00
|
|
|
Bold(Bold<'s>),
|
|
|
|
Italic(Italic<'s>),
|
|
|
|
Underline(Underline<'s>),
|
|
|
|
StrikeThrough(StrikeThrough<'s>),
|
|
|
|
Code(Code<'s>),
|
|
|
|
Verbatim(Verbatim<'s>),
|
2023-03-23 16:49:52 -04:00
|
|
|
PlainText(PlainText<'s>),
|
2023-07-13 23:26:51 -04:00
|
|
|
RegularLink(RegularLink<'s>),
|
|
|
|
RadioLink(RadioLink<'s>),
|
|
|
|
RadioTarget(RadioTarget<'s>),
|
|
|
|
PlainLink(PlainLink<'s>),
|
|
|
|
AngleLink(AngleLink<'s>),
|
|
|
|
OrgMacro(OrgMacro<'s>),
|
2023-07-18 20:05:39 -04:00
|
|
|
Entity(Entity<'s>),
|
2023-07-18 20:51:06 -04:00
|
|
|
LatexFragment(LatexFragment<'s>),
|
2023-07-19 00:09:16 -04:00
|
|
|
ExportSnippet(ExportSnippet<'s>),
|
2023-07-19 18:56:46 -04:00
|
|
|
FootnoteReference(FootnoteReference<'s>),
|
2023-07-20 00:38:16 -04:00
|
|
|
Citation(Citation<'s>),
|
|
|
|
CitationReference(CitationReference<'s>),
|
2023-07-21 19:53:02 -04:00
|
|
|
InlineBabelCall(InlineBabelCall<'s>),
|
2023-07-21 22:29:04 -04:00
|
|
|
InlineSourceBlock(InlineSourceBlock<'s>),
|
2023-07-21 23:48:37 -04:00
|
|
|
LineBreak(LineBreak<'s>),
|
2023-07-22 01:15:04 -04:00
|
|
|
Target(Target<'s>),
|
2023-07-22 01:49:07 -04:00
|
|
|
StatisticsCookie(StatisticsCookie<'s>),
|
2023-07-24 14:19:19 -04:00
|
|
|
Subscript(Subscript<'s>),
|
|
|
|
Superscript(Superscript<'s>),
|
2023-07-24 17:34:07 -04:00
|
|
|
Timestamp(Timestamp<'s>),
|
2023-03-23 16:49:52 -04:00
|
|
|
}
|
|
|
|
|
2023-04-24 19:25:22 -04:00
|
|
|
#[derive(Debug, PartialEq)]
|
2023-04-22 20:22:07 -04:00
|
|
|
pub struct Bold<'s> {
|
|
|
|
pub source: &'s str,
|
|
|
|
pub children: Vec<Object<'s>>,
|
|
|
|
}
|
|
|
|
|
2023-04-24 19:25:22 -04:00
|
|
|
#[derive(Debug, PartialEq)]
|
2023-04-22 20:22:07 -04:00
|
|
|
pub struct Italic<'s> {
|
|
|
|
pub source: &'s str,
|
|
|
|
pub children: Vec<Object<'s>>,
|
|
|
|
}
|
|
|
|
|
2023-04-24 19:25:22 -04:00
|
|
|
#[derive(Debug, PartialEq)]
|
2023-04-22 20:22:07 -04:00
|
|
|
pub struct Underline<'s> {
|
|
|
|
pub source: &'s str,
|
|
|
|
pub children: Vec<Object<'s>>,
|
|
|
|
}
|
|
|
|
|
2023-04-24 19:25:22 -04:00
|
|
|
#[derive(Debug, PartialEq)]
|
2023-04-22 20:22:07 -04:00
|
|
|
pub struct StrikeThrough<'s> {
|
2023-03-23 16:49:52 -04:00
|
|
|
pub source: &'s str,
|
2023-04-22 19:34:13 -04:00
|
|
|
pub children: Vec<Object<'s>>,
|
2023-03-23 16:49:52 -04:00
|
|
|
}
|
|
|
|
|
2023-04-24 19:25:22 -04:00
|
|
|
#[derive(Debug, PartialEq)]
|
2023-04-22 20:22:07 -04:00
|
|
|
pub struct Code<'s> {
|
|
|
|
pub source: &'s str,
|
|
|
|
pub contents: &'s str,
|
|
|
|
}
|
|
|
|
|
2023-04-24 19:25:22 -04:00
|
|
|
#[derive(Debug, PartialEq)]
|
2023-04-22 20:22:07 -04:00
|
|
|
pub struct Verbatim<'s> {
|
|
|
|
pub source: &'s str,
|
|
|
|
pub contents: &'s str,
|
|
|
|
}
|
|
|
|
|
2023-04-24 19:25:22 -04:00
|
|
|
#[derive(Debug, PartialEq)]
|
2023-03-23 16:49:52 -04:00
|
|
|
pub struct PlainText<'s> {
|
|
|
|
pub source: &'s str,
|
|
|
|
}
|
|
|
|
|
2023-04-24 19:25:22 -04:00
|
|
|
#[derive(Debug, PartialEq)]
|
2023-03-23 17:02:08 -04:00
|
|
|
pub struct RegularLink<'s> {
|
|
|
|
pub source: &'s str,
|
2023-03-23 16:49:52 -04:00
|
|
|
}
|
|
|
|
|
2023-04-24 19:25:22 -04:00
|
|
|
#[derive(Debug, PartialEq)]
|
2023-04-24 18:55:15 -04:00
|
|
|
pub struct RadioTarget<'s> {
|
|
|
|
pub source: &'s str,
|
|
|
|
pub children: Vec<Object<'s>>,
|
|
|
|
}
|
|
|
|
|
2023-04-24 19:25:22 -04:00
|
|
|
#[derive(Debug, PartialEq)]
|
2023-04-24 18:55:15 -04:00
|
|
|
pub struct RadioLink<'s> {
|
|
|
|
pub source: &'s str,
|
|
|
|
pub children: Vec<Object<'s>>,
|
|
|
|
}
|
|
|
|
|
2023-07-13 18:18:07 -04:00
|
|
|
#[derive(Debug, PartialEq)]
|
|
|
|
pub struct PlainLink<'s> {
|
|
|
|
pub source: &'s str,
|
2023-07-13 19:09:44 -04:00
|
|
|
pub link_type: &'s str,
|
|
|
|
pub path: &'s str,
|
2023-07-13 18:18:07 -04:00
|
|
|
}
|
|
|
|
|
2023-07-13 22:42:42 -04:00
|
|
|
#[derive(Debug, PartialEq)]
|
|
|
|
pub struct AngleLink<'s> {
|
|
|
|
pub source: &'s str,
|
|
|
|
pub link_type: &'s str,
|
|
|
|
pub path: &'s str,
|
|
|
|
}
|
|
|
|
|
2023-07-13 23:26:51 -04:00
|
|
|
#[derive(Debug, PartialEq)]
|
|
|
|
pub struct OrgMacro<'s> {
|
|
|
|
pub source: &'s str,
|
|
|
|
pub macro_name: &'s str,
|
|
|
|
pub macro_args: Vec<&'s str>,
|
|
|
|
}
|
|
|
|
|
2023-07-18 20:05:39 -04:00
|
|
|
#[derive(Debug, PartialEq)]
|
|
|
|
pub struct Entity<'s> {
|
|
|
|
pub source: &'s str,
|
|
|
|
pub entity_name: &'s str,
|
|
|
|
}
|
|
|
|
|
2023-07-18 20:51:06 -04:00
|
|
|
#[derive(Debug, PartialEq)]
|
|
|
|
pub struct LatexFragment<'s> {
|
|
|
|
pub source: &'s str,
|
|
|
|
}
|
|
|
|
|
2023-07-19 00:09:16 -04:00
|
|
|
#[derive(Debug, PartialEq)]
|
|
|
|
pub struct ExportSnippet<'s> {
|
|
|
|
pub source: &'s str,
|
|
|
|
pub backend: &'s str,
|
2023-07-19 00:37:51 -04:00
|
|
|
pub contents: Option<&'s str>,
|
2023-07-19 00:09:16 -04:00
|
|
|
}
|
|
|
|
|
2023-07-19 18:56:46 -04:00
|
|
|
#[derive(Debug, PartialEq)]
|
|
|
|
pub struct FootnoteReference<'s> {
|
|
|
|
pub source: &'s str,
|
2023-07-19 21:14:09 -04:00
|
|
|
pub label: Option<&'s str>,
|
2023-07-19 18:56:46 -04:00
|
|
|
pub definition: Vec<Object<'s>>,
|
|
|
|
}
|
|
|
|
|
2023-07-20 00:38:16 -04:00
|
|
|
#[derive(Debug, PartialEq)]
|
|
|
|
pub struct Citation<'s> {
|
|
|
|
pub source: &'s str,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Debug, PartialEq)]
|
|
|
|
pub struct CitationReference<'s> {
|
|
|
|
pub source: &'s str,
|
|
|
|
}
|
|
|
|
|
2023-07-21 19:53:02 -04:00
|
|
|
#[derive(Debug, PartialEq)]
|
|
|
|
pub struct InlineBabelCall<'s> {
|
|
|
|
pub source: &'s str,
|
|
|
|
}
|
|
|
|
|
2023-07-21 22:29:04 -04:00
|
|
|
#[derive(Debug, PartialEq)]
|
|
|
|
pub struct InlineSourceBlock<'s> {
|
|
|
|
pub source: &'s str,
|
|
|
|
}
|
|
|
|
|
2023-07-21 23:48:37 -04:00
|
|
|
#[derive(Debug, PartialEq)]
|
|
|
|
pub struct LineBreak<'s> {
|
|
|
|
pub source: &'s str,
|
|
|
|
}
|
|
|
|
|
2023-07-22 01:15:04 -04:00
|
|
|
#[derive(Debug, PartialEq)]
|
|
|
|
pub struct Target<'s> {
|
|
|
|
pub source: &'s str,
|
|
|
|
}
|
|
|
|
|
2023-07-22 01:49:07 -04:00
|
|
|
#[derive(Debug, PartialEq)]
|
|
|
|
pub struct StatisticsCookie<'s> {
|
|
|
|
pub source: &'s str,
|
|
|
|
}
|
|
|
|
|
2023-07-24 14:19:19 -04:00
|
|
|
#[derive(Debug, PartialEq)]
|
|
|
|
pub struct Subscript<'s> {
|
|
|
|
pub source: &'s str,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Debug, PartialEq)]
|
|
|
|
pub struct Superscript<'s> {
|
|
|
|
pub source: &'s str,
|
|
|
|
}
|
|
|
|
|
2023-07-24 17:34:07 -04:00
|
|
|
#[derive(Debug, PartialEq)]
|
|
|
|
pub struct Timestamp<'s> {
|
|
|
|
pub source: &'s str,
|
|
|
|
}
|
|
|
|
|
2023-03-23 16:49:52 -04:00
|
|
|
impl<'s> Source<'s> for Object<'s> {
|
|
|
|
fn get_source(&'s self) -> &'s str {
|
|
|
|
match self {
|
2023-04-22 20:22:07 -04:00
|
|
|
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,
|
2023-03-23 16:49:52 -04:00
|
|
|
Object::PlainText(obj) => obj.source,
|
2023-03-23 17:02:08 -04:00
|
|
|
Object::RegularLink(obj) => obj.source,
|
2023-04-24 18:55:15 -04:00
|
|
|
Object::RadioLink(obj) => obj.source,
|
|
|
|
Object::RadioTarget(obj) => obj.source,
|
2023-07-13 18:18:07 -04:00
|
|
|
Object::PlainLink(obj) => obj.source,
|
2023-07-13 22:42:42 -04:00
|
|
|
Object::AngleLink(obj) => obj.source,
|
2023-07-13 23:26:51 -04:00
|
|
|
Object::OrgMacro(obj) => obj.source,
|
2023-07-18 20:05:39 -04:00
|
|
|
Object::Entity(obj) => obj.source,
|
2023-07-18 20:51:06 -04:00
|
|
|
Object::LatexFragment(obj) => obj.source,
|
2023-07-19 00:09:16 -04:00
|
|
|
Object::ExportSnippet(obj) => obj.source,
|
2023-07-19 18:56:46 -04:00
|
|
|
Object::FootnoteReference(obj) => obj.source,
|
2023-07-20 00:38:16 -04:00
|
|
|
Object::Citation(obj) => obj.source,
|
|
|
|
Object::CitationReference(obj) => obj.source,
|
2023-07-21 19:53:02 -04:00
|
|
|
Object::InlineBabelCall(obj) => obj.source,
|
2023-07-21 22:29:04 -04:00
|
|
|
Object::InlineSourceBlock(obj) => obj.source,
|
2023-07-21 23:48:37 -04:00
|
|
|
Object::LineBreak(obj) => obj.source,
|
2023-07-22 01:15:04 -04:00
|
|
|
Object::Target(obj) => obj.source,
|
2023-07-24 17:34:07 -04:00
|
|
|
Object::Timestamp(obj) => obj.source,
|
2023-07-22 01:49:07 -04:00
|
|
|
Object::StatisticsCookie(obj) => obj.source,
|
2023-07-24 14:19:19 -04:00
|
|
|
Object::Subscript(obj) => obj.source,
|
|
|
|
Object::Superscript(obj) => obj.source,
|
2023-03-23 16:49:52 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2023-04-22 20:48:01 -04:00
|
|
|
|
|
|
|
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
|
|
|
|
}
|
|
|
|
}
|
2023-04-23 16:17:52 -04:00
|
|
|
|
|
|
|
impl<'s> Source<'s> for RegularLink<'s> {
|
|
|
|
fn get_source(&'s self) -> &'s str {
|
|
|
|
self.source
|
|
|
|
}
|
|
|
|
}
|
2023-04-24 18:55:15 -04:00
|
|
|
|
|
|
|
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
|
|
|
|
}
|
|
|
|
}
|
2023-07-13 18:18:07 -04:00
|
|
|
|
|
|
|
impl<'s> Source<'s> for PlainLink<'s> {
|
|
|
|
fn get_source(&'s self) -> &'s str {
|
|
|
|
self.source
|
|
|
|
}
|
|
|
|
}
|
2023-07-13 22:42:42 -04:00
|
|
|
|
|
|
|
impl<'s> Source<'s> for AngleLink<'s> {
|
|
|
|
fn get_source(&'s self) -> &'s str {
|
|
|
|
self.source
|
|
|
|
}
|
|
|
|
}
|
2023-07-13 23:26:51 -04:00
|
|
|
|
|
|
|
impl<'s> Source<'s> for OrgMacro<'s> {
|
|
|
|
fn get_source(&'s self) -> &'s str {
|
|
|
|
self.source
|
|
|
|
}
|
|
|
|
}
|
2023-07-18 20:05:39 -04:00
|
|
|
|
|
|
|
impl<'s> Source<'s> for Entity<'s> {
|
|
|
|
fn get_source(&'s self) -> &'s str {
|
|
|
|
self.source
|
|
|
|
}
|
|
|
|
}
|
2023-07-18 20:51:06 -04:00
|
|
|
|
|
|
|
impl<'s> Source<'s> for LatexFragment<'s> {
|
|
|
|
fn get_source(&'s self) -> &'s str {
|
|
|
|
self.source
|
|
|
|
}
|
|
|
|
}
|
2023-07-19 00:09:16 -04:00
|
|
|
|
|
|
|
impl<'s> Source<'s> for ExportSnippet<'s> {
|
|
|
|
fn get_source(&'s self) -> &'s str {
|
|
|
|
self.source
|
|
|
|
}
|
|
|
|
}
|
2023-07-19 18:56:46 -04:00
|
|
|
|
|
|
|
impl<'s> Source<'s> for FootnoteReference<'s> {
|
|
|
|
fn get_source(&'s self) -> &'s str {
|
|
|
|
self.source
|
|
|
|
}
|
|
|
|
}
|
2023-07-20 00:38:16 -04:00
|
|
|
|
|
|
|
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
|
|
|
|
}
|
|
|
|
}
|
2023-07-21 19:53:02 -04:00
|
|
|
|
|
|
|
impl<'s> Source<'s> for InlineBabelCall<'s> {
|
|
|
|
fn get_source(&'s self) -> &'s str {
|
|
|
|
self.source
|
|
|
|
}
|
|
|
|
}
|
2023-07-21 22:29:04 -04:00
|
|
|
|
|
|
|
impl<'s> Source<'s> for InlineSourceBlock<'s> {
|
|
|
|
fn get_source(&'s self) -> &'s str {
|
|
|
|
self.source
|
|
|
|
}
|
|
|
|
}
|
2023-07-21 23:48:37 -04:00
|
|
|
|
|
|
|
impl<'s> Source<'s> for LineBreak<'s> {
|
|
|
|
fn get_source(&'s self) -> &'s str {
|
|
|
|
self.source
|
|
|
|
}
|
|
|
|
}
|
2023-07-22 01:15:04 -04:00
|
|
|
|
|
|
|
impl<'s> Source<'s> for Target<'s> {
|
|
|
|
fn get_source(&'s self) -> &'s str {
|
|
|
|
self.source
|
|
|
|
}
|
|
|
|
}
|
2023-07-22 01:49:07 -04:00
|
|
|
|
|
|
|
impl<'s> Source<'s> for StatisticsCookie<'s> {
|
|
|
|
fn get_source(&'s self) -> &'s str {
|
|
|
|
self.source
|
|
|
|
}
|
|
|
|
}
|
2023-07-24 14:19:19 -04:00
|
|
|
|
|
|
|
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
|
|
|
|
}
|
|
|
|
}
|
2023-07-24 17:34:07 -04:00
|
|
|
|
|
|
|
impl<'s> Source<'s> for Timestamp<'s> {
|
|
|
|
fn get_source(&'s self) -> &'s str {
|
|
|
|
self.source
|
|
|
|
}
|
|
|
|
}
|
2023-08-29 14:40:58 -04:00
|
|
|
|
|
|
|
impl<'s> Source<'s> for PlainText<'s> {
|
|
|
|
fn get_source(&'s self) -> &'s str {
|
|
|
|
self.source
|
|
|
|
}
|
|
|
|
}
|