Create structure for angle links.
This commit is contained in:
10
src/parser/angle_link.rs
Normal file
10
src/parser/angle_link.rs
Normal file
@@ -0,0 +1,10 @@
|
||||
use super::Context;
|
||||
use crate::error::Res;
|
||||
use crate::parser::util::not_yet_implemented;
|
||||
use crate::parser::AngleLink;
|
||||
|
||||
#[tracing::instrument(ret, level = "debug")]
|
||||
pub fn angle_link<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, AngleLink<'s>> {
|
||||
not_yet_implemented()?;
|
||||
todo!();
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
mod angle_link;
|
||||
mod clock;
|
||||
mod comment;
|
||||
mod diary_sexp;
|
||||
@@ -64,6 +65,7 @@ pub use lesser_element::Planning;
|
||||
pub use lesser_element::SrcBlock;
|
||||
pub use lesser_element::TableCell;
|
||||
pub use lesser_element::VerseBlock;
|
||||
pub use object::AngleLink;
|
||||
pub use object::Bold;
|
||||
pub use object::Code;
|
||||
pub use object::Italic;
|
||||
|
||||
@@ -6,6 +6,7 @@ pub enum Object<'s> {
|
||||
RadioLink(RadioLink<'s>),
|
||||
RadioTarget(RadioTarget<'s>),
|
||||
PlainLink(PlainLink<'s>),
|
||||
AngleLink(AngleLink<'s>),
|
||||
Bold(Bold<'s>),
|
||||
Italic(Italic<'s>),
|
||||
Underline(Underline<'s>),
|
||||
@@ -80,6 +81,13 @@ pub struct PlainLink<'s> {
|
||||
pub path: &'s str,
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq)]
|
||||
pub struct AngleLink<'s> {
|
||||
pub source: &'s str,
|
||||
pub link_type: &'s str,
|
||||
pub path: &'s str,
|
||||
}
|
||||
|
||||
impl<'s> Source<'s> for Object<'s> {
|
||||
fn get_source(&'s self) -> &'s str {
|
||||
match self {
|
||||
@@ -94,6 +102,7 @@ impl<'s> Source<'s> for Object<'s> {
|
||||
Object::RadioLink(obj) => obj.source,
|
||||
Object::RadioTarget(obj) => obj.source,
|
||||
Object::PlainLink(obj) => obj.source,
|
||||
Object::AngleLink(obj) => obj.source,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -157,3 +166,9 @@ impl<'s> Source<'s> for PlainLink<'s> {
|
||||
self.source
|
||||
}
|
||||
}
|
||||
|
||||
impl<'s> Source<'s> for AngleLink<'s> {
|
||||
fn get_source(&'s self) -> &'s str {
|
||||
self.source
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ use super::plain_text::plain_text;
|
||||
use super::regular_link::regular_link;
|
||||
use super::Context;
|
||||
use crate::error::Res;
|
||||
use crate::parser::angle_link::angle_link;
|
||||
use crate::parser::object::Object;
|
||||
use crate::parser::plain_link::plain_link;
|
||||
use crate::parser::radio_link::radio_link;
|
||||
@@ -33,6 +34,7 @@ pub fn standard_set_object<'r, 's>(
|
||||
Object::RegularLink,
|
||||
),
|
||||
map(parser_with_context!(plain_link)(context), Object::PlainLink),
|
||||
map(parser_with_context!(angle_link)(context), Object::AngleLink),
|
||||
map(parser_with_context!(plain_text)(context), Object::PlainText),
|
||||
))(input)
|
||||
}
|
||||
@@ -69,6 +71,7 @@ pub fn any_object_except_plain_text<'r, 's>(
|
||||
Object::RegularLink,
|
||||
),
|
||||
map(parser_with_context!(plain_link)(context), Object::PlainLink),
|
||||
map(parser_with_context!(angle_link)(context), Object::AngleLink),
|
||||
))(input)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user