diff --git a/src/compare/diff.rs b/src/compare/diff.rs index 186898e..c5a4111 100644 --- a/src/compare/diff.rs +++ b/src/compare/diff.rs @@ -74,9 +74,11 @@ pub fn compare_document<'s>( rust: &'s Document<'s>, ) -> Result> { let children = emacs.as_list()?; - assert_name(emacs, "org-data")?; let mut child_status = Vec::new(); let mut this_status = DiffStatus::Good; + if assert_name(emacs, "org-data").is_err() { + this_status = DiffStatus::Bad; + } // Skipping "org-data" and the first parameter which is often nil for (i, token) in children.iter().skip(2).enumerate() { @@ -122,9 +124,11 @@ fn compare_section<'s>( rust: &'s Section<'s>, ) -> Result> { let children = emacs.as_list()?; - assert_name(emacs, "section")?; - let mut child_status = Vec::new(); let mut this_status = DiffStatus::Good; + let mut child_status = Vec::new(); + if assert_name(emacs, "section").is_err() { + this_status = DiffStatus::Bad; + } if assert_bounds(source, emacs, rust).is_err() { this_status = DiffStatus::Bad; @@ -148,9 +152,11 @@ fn compare_heading<'s>( rust: &'s Heading<'s>, ) -> Result> { let children = emacs.as_list()?; - assert_name(emacs, "headline")?; let mut child_status = Vec::new(); let mut this_status = DiffStatus::Good; + if assert_name(emacs, "headline").is_err() { + this_status = DiffStatus::Bad; + } if assert_bounds(source, emacs, rust).is_err() { this_status = DiffStatus::Bad; @@ -197,9 +203,11 @@ fn compare_paragraph<'s>( rust: &'s Paragraph<'s>, ) -> Result> { let children = emacs.as_list()?; - assert_name(emacs, "paragraph")?; let mut child_status = Vec::new(); let mut this_status = DiffStatus::Good; + if assert_name(emacs, "paragraph").is_err() { + this_status = DiffStatus::Bad; + } if assert_bounds(source, emacs, rust).is_err() { this_status = DiffStatus::Bad; @@ -221,9 +229,11 @@ fn compare_plain_list<'s>( rust: &'s PlainList<'s>, ) -> Result> { let children = emacs.as_list()?; - assert_name(emacs, "plain-list")?; let mut child_status = Vec::new(); let mut this_status = DiffStatus::Good; + if assert_name(emacs, "plain-list").is_err() { + this_status = DiffStatus::Bad; + } if assert_bounds(source, emacs, rust).is_err() { this_status = DiffStatus::Bad; @@ -247,9 +257,11 @@ fn compare_plain_list_item<'s>( rust: &'s PlainListItem<'s>, ) -> Result> { let children = emacs.as_list()?; - assert_name(emacs, "item")?; let mut child_status = Vec::new(); let mut this_status = DiffStatus::Good; + if assert_name(emacs, "item").is_err() { + this_status = DiffStatus::Bad; + } if assert_bounds(source, emacs, rust).is_err() { this_status = DiffStatus::Bad; @@ -273,16 +285,18 @@ fn compare_greater_block<'s>( rust: &'s GreaterBlock<'s>, ) -> Result> { let children = emacs.as_list()?; - assert_name( + let mut child_status = Vec::new(); + let mut this_status = DiffStatus::Good; + if assert_name( emacs, match rust.name.to_lowercase().as_str() { "center" => "center-block", "quote" => "quote-block", _ => todo!(), }, - )?; - let mut child_status = Vec::new(); - let mut this_status = DiffStatus::Good; + ).is_err() { + this_status = DiffStatus::Bad; + } if assert_bounds(source, emacs, rust).is_err() { this_status = DiffStatus::Bad; @@ -306,9 +320,11 @@ fn compare_dynamic_block<'s>( rust: &'s DynamicBlock<'s>, ) -> Result> { let children = emacs.as_list()?; - assert_name(emacs, "dynamic-block")?; let mut child_status = Vec::new(); let mut this_status = DiffStatus::Good; + if assert_name(emacs, "dynamic-block").is_err() { + this_status = DiffStatus::Bad; + } if assert_bounds(source, emacs, rust).is_err() { this_status = DiffStatus::Bad; @@ -332,9 +348,11 @@ fn compare_footnote_definition<'s>( rust: &'s FootnoteDefinition<'s>, ) -> Result> { let children = emacs.as_list()?; - assert_name(emacs, "footnote-definition")?; let mut child_status = Vec::new(); let mut this_status = DiffStatus::Good; + if assert_name(emacs, "footnote-definition").is_err() { + this_status = DiffStatus::Bad; + } if assert_bounds(source, emacs, rust).is_err() { this_status = DiffStatus::Bad; @@ -358,9 +376,11 @@ fn compare_comment<'s>( rust: &'s Comment<'s>, ) -> Result> { let children = emacs.as_list()?; - assert_name(emacs, "comment")?; let mut child_status = Vec::new(); let mut this_status = DiffStatus::Good; + if assert_name(emacs, "comment").is_err() { + this_status = DiffStatus::Bad; + } if assert_bounds(source, emacs, rust).is_err() { this_status = DiffStatus::Bad; @@ -380,9 +400,11 @@ fn compare_drawer<'s>( rust: &'s Drawer<'s>, ) -> Result> { let children = emacs.as_list()?; - assert_name(emacs, "drawer")?; let mut child_status = Vec::new(); let mut this_status = DiffStatus::Good; + if assert_name(emacs, "drawer").is_err() { + this_status = DiffStatus::Bad; + } if assert_bounds(source, emacs, rust).is_err() { this_status = DiffStatus::Bad;