diff --git a/src/compare/diff.rs b/src/compare/diff.rs index b27e22a..9d06837 100644 --- a/src/compare/diff.rs +++ b/src/compare/diff.rs @@ -86,6 +86,7 @@ use crate::types::Superscript; use crate::types::Table; use crate::types::TableCell; use crate::types::TableRow; +use crate::types::TableRowType; use crate::types::Target; use crate::types::Time; use crate::types::TimeUnit; @@ -1427,12 +1428,23 @@ fn compare_table_row<'b, 's>( ) -> Result, Box> { let children = emacs.as_list()?; let mut child_status = Vec::new(); - let this_status = DiffStatus::Good; - let message = None; + let mut this_status = DiffStatus::Good; + let mut message = None; - // TODO: Compare :type - // - // :type is an unquoted atom of either standard or rule + // Compare type + let row_type = get_property_unquoted_atom(emacs, ":type")?; + let rust_row_type = rust.get_type(); + match (row_type, &rust_row_type) { + (Some("standard"), TableRowType::Standard) => {} + (Some("rule"), TableRowType::Rule) => {} + _ => { + this_status = DiffStatus::Bad; + message = Some(format!( + "Type mismatch (emacs != rust) {:?} != {:?}", + row_type, rust_row_type + )); + } + } for (emacs_child, rust_child) in children.iter().skip(2).zip(rust.children.iter()) { child_status.push(compare_ast_node(source, emacs_child, rust_child.into())?); diff --git a/src/types/greater_element.rs b/src/types/greater_element.rs index bbf88f7..17d7cd2 100644 --- a/src/types/greater_element.rs +++ b/src/types/greater_element.rs @@ -111,6 +111,12 @@ pub struct TableRow<'s> { pub children: Vec>, } +#[derive(Debug)] +pub enum TableRowType { + Standard, + Rule, +} + impl<'s> StandardProperties<'s> for PlainList<'s> { fn get_source<'b>(&'b self) -> &'s str { self.source @@ -194,3 +200,13 @@ impl<'s> PlainListItem<'s> { .map(|(checkbox_type, _)| checkbox_type) } } + +impl<'s> TableRow<'s> { + pub fn get_type(&self) -> TableRowType { + if self.children.is_empty() { + TableRowType::Rule + } else { + TableRowType::Standard + } + } +} diff --git a/src/types/mod.rs b/src/types/mod.rs index d95adcb..d0b9b97 100644 --- a/src/types/mod.rs +++ b/src/types/mod.rs @@ -35,6 +35,7 @@ pub use greater_element::QuoteBlock; pub use greater_element::SpecialBlock; pub use greater_element::Table; pub use greater_element::TableRow; +pub use greater_element::TableRowType; pub use lesser_element::BabelCall; pub use lesser_element::Clock; pub use lesser_element::Comment;