Separate out the text markup types into their own types.
This commit is contained in:
@@ -2,8 +2,12 @@ use super::source::Source;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub enum Object<'s> {
|
||||
#[allow(dead_code)]
|
||||
TextMarkup(TextMarkup<'s>),
|
||||
Bold(Bold<'s>),
|
||||
Italic(Italic<'s>),
|
||||
Underline(Underline<'s>),
|
||||
StrikeThrough(StrikeThrough<'s>),
|
||||
Code(Code<'s>),
|
||||
Verbatim(Verbatim<'s>),
|
||||
|
||||
PlainText(PlainText<'s>),
|
||||
|
||||
@@ -12,11 +16,41 @@ pub enum Object<'s> {
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct TextMarkup<'s> {
|
||||
pub struct Bold<'s> {
|
||||
pub source: &'s str,
|
||||
pub children: Vec<Object<'s>>,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct Italic<'s> {
|
||||
pub source: &'s str,
|
||||
pub children: Vec<Object<'s>>,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct Underline<'s> {
|
||||
pub source: &'s str,
|
||||
pub children: Vec<Object<'s>>,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct StrikeThrough<'s> {
|
||||
pub source: &'s str,
|
||||
pub children: Vec<Object<'s>>,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct Code<'s> {
|
||||
pub source: &'s str,
|
||||
pub contents: &'s str,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct Verbatim<'s> {
|
||||
pub source: &'s str,
|
||||
pub contents: &'s str,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct PlainText<'s> {
|
||||
pub source: &'s str,
|
||||
@@ -30,7 +64,12 @@ pub struct RegularLink<'s> {
|
||||
impl<'s> Source<'s> for Object<'s> {
|
||||
fn get_source(&'s self) -> &'s str {
|
||||
match self {
|
||||
Object::TextMarkup(obj) => obj.source,
|
||||
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,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user