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