diff --git a/src/compare/diff.rs b/src/compare/diff.rs index 7509d36..8b96c6e 100644 --- a/src/compare/diff.rs +++ b/src/compare/diff.rs @@ -1838,27 +1838,47 @@ fn compare_table_cell<'b, 's>( } fn compare_verse_block<'b, 's>( - _source: &'s str, + source: &'s str, emacs: &'b Token<'s>, rust: &'b VerseBlock<'s>, ) -> Result, Box> { - let children = emacs.as_list()?; - let child_status = Vec::new(); let mut this_status = DiffStatus::Good; + let mut child_status = Vec::new(); let mut message = None; - // TODO: Compare :caption - // Compare name - let name = get_property_quoted_string(emacs, ":name")?; - if name.as_ref().map(String::as_str) != rust.name { - this_status = DiffStatus::Bad; - message = Some(format!( - "Name mismatch (emacs != rust) {:?} != {:?}", - name, rust.name - )); - } + compare_children( + source, + emacs, + &rust.children, + &mut child_status, + &mut this_status, + &mut message, + )?; - for (_emacs_child, _rust_child) in children.iter().skip(2).zip(rust.children.iter()) {} + for diff in compare_properties!( + source, + emacs, + rust, + ( + EmacsField::Optional(":name"), + |r| r.name, + compare_property_quoted_string + ), + ( + EmacsField::Optional(":caption"), + compare_identity, + compare_noop + ) + ) { + match diff { + ComparePropertiesResult::NoChange => {} + ComparePropertiesResult::SelfChange(new_status, new_message) => { + this_status = new_status; + message = new_message + } + ComparePropertiesResult::DiffEntry(diff_entry) => child_status.push(diff_entry), + } + } Ok(DiffResult { status: this_status,