Create structure for angle links.
This commit is contained in:
parent
79ac835641
commit
ed8b1405db
@ -1,6 +1,7 @@
|
||||
use super::util::assert_bounds;
|
||||
use super::util::assert_name;
|
||||
use crate::parser::sexp::Token;
|
||||
use crate::parser::AngleLink;
|
||||
use crate::parser::Bold;
|
||||
use crate::parser::Clock;
|
||||
use crate::parser::Code;
|
||||
@ -150,6 +151,7 @@ fn compare_object<'s>(
|
||||
Object::RadioLink(obj) => compare_radio_link(source, emacs, obj),
|
||||
Object::RadioTarget(obj) => compare_radio_target(source, emacs, obj),
|
||||
Object::PlainLink(obj) => compare_plain_link(source, emacs, obj),
|
||||
Object::AngleLink(obj) => compare_angle_link(source, emacs, obj),
|
||||
}
|
||||
}
|
||||
|
||||
@ -1188,3 +1190,26 @@ fn compare_plain_link<'s>(
|
||||
children: Vec::new(),
|
||||
})
|
||||
}
|
||||
|
||||
fn compare_angle_link<'s>(
|
||||
source: &'s str,
|
||||
emacs: &'s Token<'s>,
|
||||
rust: &'s AngleLink<'s>,
|
||||
) -> Result<DiffResult, Box<dyn std::error::Error>> {
|
||||
let mut this_status = DiffStatus::Good;
|
||||
let emacs_name = "link";
|
||||
if assert_name(emacs, emacs_name).is_err() {
|
||||
this_status = DiffStatus::Bad;
|
||||
}
|
||||
|
||||
if assert_bounds(source, emacs, rust).is_err() {
|
||||
this_status = DiffStatus::Bad;
|
||||
}
|
||||
|
||||
Ok(DiffResult {
|
||||
status: this_status,
|
||||
name: emacs_name.to_owned(),
|
||||
message: None,
|
||||
children: Vec::new(),
|
||||
})
|
||||
}
|
||||
|
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)
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user