190 lines
3.9 KiB
Rust
190 lines
3.9 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>),
|
|
}
|
|
|
|
#[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>,
|
|
}
|
|
|
|
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,
|
|
}
|
|
}
|
|
}
|
|
|
|
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
|
|
}
|
|
}
|