diff --git a/src/compare/diff.rs b/src/compare/diff.rs index e669d5d..f16111d 100644 --- a/src/compare/diff.rs +++ b/src/compare/diff.rs @@ -50,6 +50,7 @@ use crate::parser::StrikeThrough; use crate::parser::Table; use crate::parser::TableCell; use crate::parser::TableRow; +use crate::parser::Target; use crate::parser::Underline; use crate::parser::Verbatim; use crate::parser::VerseBlock; @@ -172,6 +173,7 @@ fn compare_object<'s>( Object::InlineBabelCall(obj) => compare_inline_babel_call(source, emacs, obj), Object::InlineSourceBlock(obj) => compare_inline_source_block(source, emacs, obj), Object::LineBreak(obj) => compare_line_break(source, emacs, obj), + Object::Target(obj) => compare_target(source, emacs, obj), } } @@ -1463,3 +1465,26 @@ fn compare_line_break<'s>( children: Vec::new(), }) } + +fn compare_target<'s>( + source: &'s str, + emacs: &'s Token<'s>, + rust: &'s Target<'s>, +) -> Result> { + let mut this_status = DiffStatus::Good; + let emacs_name = "target"; + 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(), + }) +} diff --git a/src/parser/mod.rs b/src/parser/mod.rs index 95e2729..1686606 100644 --- a/src/parser/mod.rs +++ b/src/parser/mod.rs @@ -43,6 +43,7 @@ mod regular_link; pub mod sexp; mod source; mod table; +mod target; mod text_markup; mod token; mod util; @@ -97,6 +98,7 @@ pub use object::RadioLink; pub use object::RadioTarget; pub use object::RegularLink; pub use object::StrikeThrough; +pub use object::Target; pub use object::Underline; pub use object::Verbatim; pub use source::Source; diff --git a/src/parser/object.rs b/src/parser/object.rs index 725845a..ea705a4 100644 --- a/src/parser/object.rs +++ b/src/parser/object.rs @@ -24,6 +24,7 @@ pub enum Object<'s> { InlineBabelCall(InlineBabelCall<'s>), InlineSourceBlock(InlineSourceBlock<'s>), LineBreak(LineBreak<'s>), + Target(Target<'s>), } #[derive(Debug, PartialEq)] @@ -155,6 +156,11 @@ pub struct LineBreak<'s> { pub source: &'s str, } +#[derive(Debug, PartialEq)] +pub struct Target<'s> { + pub source: &'s str, +} + impl<'s> Source<'s> for Object<'s> { fn get_source(&'s self) -> &'s str { match self { @@ -180,6 +186,7 @@ impl<'s> Source<'s> for Object<'s> { Object::InlineBabelCall(obj) => obj.source, Object::InlineSourceBlock(obj) => obj.source, Object::LineBreak(obj) => obj.source, + Object::Target(obj) => obj.source, } } } @@ -309,3 +316,9 @@ impl<'s> Source<'s> for LineBreak<'s> { self.source } } + +impl<'s> Source<'s> for Target<'s> { + fn get_source(&'s self) -> &'s str { + self.source + } +} diff --git a/src/parser/token.rs b/src/parser/token.rs index 8f76b0e..f3ebe82 100644 --- a/src/parser/token.rs +++ b/src/parser/token.rs @@ -63,6 +63,7 @@ impl<'r, 's> Token<'r, 's> { Object::InlineBabelCall(_) => Box::new(std::iter::empty()), Object::InlineSourceBlock(_) => Box::new(std::iter::empty()), Object::LineBreak(_) => Box::new(std::iter::empty()), + Object::Target(_) => Box::new(std::iter::empty()), }, Token::Element(elem) => match elem { Element::Paragraph(inner) => Box::new(inner.children.iter().map(Token::Object)),