Create structure for plain links.
All checks were successful
organic-test Build organic-test has succeeded
All checks were successful
organic-test Build organic-test has succeeded
This commit is contained in:
@@ -22,6 +22,7 @@ mod object_parser;
|
||||
mod paragraph;
|
||||
mod parser_context;
|
||||
mod parser_with_context;
|
||||
mod plain_link;
|
||||
mod plain_list;
|
||||
mod plain_text;
|
||||
mod planning;
|
||||
@@ -67,6 +68,7 @@ pub use object::Bold;
|
||||
pub use object::Code;
|
||||
pub use object::Italic;
|
||||
pub use object::Object;
|
||||
pub use object::PlainLink;
|
||||
pub use object::PlainText;
|
||||
pub use object::RadioLink;
|
||||
pub use object::RadioTarget;
|
||||
|
||||
@@ -5,6 +5,7 @@ pub enum Object<'s> {
|
||||
RegularLink(RegularLink<'s>),
|
||||
RadioLink(RadioLink<'s>),
|
||||
RadioTarget(RadioTarget<'s>),
|
||||
PlainLink(PlainLink<'s>),
|
||||
Bold(Bold<'s>),
|
||||
Italic(Italic<'s>),
|
||||
Underline(Underline<'s>),
|
||||
@@ -72,6 +73,12 @@ pub struct RadioLink<'s> {
|
||||
pub children: Vec<Object<'s>>,
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq)]
|
||||
pub struct PlainLink<'s> {
|
||||
pub source: &'s str,
|
||||
pub children: Vec<Object<'s>>,
|
||||
}
|
||||
|
||||
impl<'s> Source<'s> for Object<'s> {
|
||||
fn get_source(&'s self) -> &'s str {
|
||||
match self {
|
||||
@@ -85,6 +92,7 @@ impl<'s> Source<'s> for Object<'s> {
|
||||
Object::RegularLink(obj) => obj.source,
|
||||
Object::RadioLink(obj) => obj.source,
|
||||
Object::RadioTarget(obj) => obj.source,
|
||||
Object::PlainLink(obj) => obj.source,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -142,3 +150,9 @@ impl<'s> Source<'s> for RadioTarget<'s> {
|
||||
self.source
|
||||
}
|
||||
}
|
||||
|
||||
impl<'s> Source<'s> for PlainLink<'s> {
|
||||
fn get_source(&'s self) -> &'s str {
|
||||
self.source
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ use super::regular_link::regular_link;
|
||||
use super::Context;
|
||||
use crate::error::Res;
|
||||
use crate::parser::object::Object;
|
||||
use crate::parser::plain_link::plain_link;
|
||||
use crate::parser::radio_link::radio_link;
|
||||
use crate::parser::radio_link::radio_target;
|
||||
use crate::parser::text_markup::text_markup;
|
||||
@@ -31,6 +32,7 @@ pub fn standard_set_object<'r, 's>(
|
||||
parser_with_context!(regular_link)(context),
|
||||
Object::RegularLink,
|
||||
),
|
||||
map(parser_with_context!(plain_link)(context), Object::PlainLink),
|
||||
map(parser_with_context!(plain_text)(context), Object::PlainText),
|
||||
))(input)
|
||||
}
|
||||
|
||||
10
src/parser/plain_link.rs
Normal file
10
src/parser/plain_link.rs
Normal file
@@ -0,0 +1,10 @@
|
||||
use super::Context;
|
||||
use crate::error::Res;
|
||||
use crate::parser::object::PlainLink;
|
||||
use crate::parser::util::not_yet_implemented;
|
||||
|
||||
#[tracing::instrument(ret, level = "debug")]
|
||||
pub fn plain_link<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, PlainLink<'s>> {
|
||||
not_yet_implemented()?;
|
||||
todo!();
|
||||
}
|
||||
Reference in New Issue
Block a user