Unify status name handling on the emacs name.

This commit is contained in:
Tom Alexander 2023-04-19 16:04:30 -04:00
parent 31da2e970c
commit d3bb642a10
Signed by: talexander
GPG Key ID: D3A179C9A53C0EDE

View File

@ -76,7 +76,8 @@ pub fn compare_document<'s>(
let children = emacs.as_list()?;
let mut child_status = Vec::new();
let mut this_status = DiffStatus::Good;
if assert_name(emacs, "org-data").is_err() {
let emacs_name = "org-data";
if assert_name(emacs, emacs_name).is_err() {
this_status = DiffStatus::Bad;
}
@ -112,7 +113,7 @@ pub fn compare_document<'s>(
Ok(DiffResult {
status: this_status,
name: "document".to_owned(),
name: emacs_name.to_owned(),
message: None,
children: child_status,
})
@ -126,7 +127,8 @@ fn compare_section<'s>(
let children = emacs.as_list()?;
let mut this_status = DiffStatus::Good;
let mut child_status = Vec::new();
if assert_name(emacs, "section").is_err() {
let emacs_name = "section";
if assert_name(emacs, emacs_name).is_err() {
this_status = DiffStatus::Bad;
}
@ -140,7 +142,7 @@ fn compare_section<'s>(
Ok(DiffResult {
status: this_status,
name: "section".to_owned(),
name: emacs_name.to_owned(),
message: None,
children: child_status,
})
@ -154,7 +156,8 @@ fn compare_heading<'s>(
let children = emacs.as_list()?;
let mut child_status = Vec::new();
let mut this_status = DiffStatus::Good;
if assert_name(emacs, "headline").is_err() {
let emacs_name = "headline";
if assert_name(emacs, emacs_name).is_err() {
this_status = DiffStatus::Bad;
}
@ -175,7 +178,7 @@ fn compare_heading<'s>(
Ok(DiffResult {
status: this_status,
name: "heading".to_owned(),
name: emacs_name.to_owned(),
message: None,
children: child_status,
})
@ -205,7 +208,8 @@ fn compare_paragraph<'s>(
let children = emacs.as_list()?;
let mut child_status = Vec::new();
let mut this_status = DiffStatus::Good;
if assert_name(emacs, "paragraph").is_err() {
let emacs_name = "paragraph";
if assert_name(emacs, emacs_name).is_err() {
this_status = DiffStatus::Bad;
}
@ -217,7 +221,7 @@ fn compare_paragraph<'s>(
Ok(DiffResult {
status: this_status,
name: "paragraph".to_owned(),
name: emacs_name.to_owned(),
message: None,
children: child_status,
})
@ -231,7 +235,8 @@ fn compare_plain_list<'s>(
let children = emacs.as_list()?;
let mut child_status = Vec::new();
let mut this_status = DiffStatus::Good;
if assert_name(emacs, "plain-list").is_err() {
let emacs_name = "plain-list";
if assert_name(emacs, emacs_name).is_err() {
this_status = DiffStatus::Bad;
}
@ -245,7 +250,7 @@ fn compare_plain_list<'s>(
Ok(DiffResult {
status: this_status,
name: "plain-list".to_owned(),
name: emacs_name.to_owned(),
message: None,
children: child_status,
})
@ -259,7 +264,8 @@ fn compare_plain_list_item<'s>(
let children = emacs.as_list()?;
let mut child_status = Vec::new();
let mut this_status = DiffStatus::Good;
if assert_name(emacs, "item").is_err() {
let emacs_name = "item";
if assert_name(emacs, emacs_name).is_err() {
this_status = DiffStatus::Bad;
}
@ -273,7 +279,7 @@ fn compare_plain_list_item<'s>(
Ok(DiffResult {
status: this_status,
name: "plain-list-item".to_owned(),
name: emacs_name.to_owned(),
message: None,
children: child_status,
})
@ -287,14 +293,12 @@ fn compare_greater_block<'s>(
let children = emacs.as_list()?;
let mut child_status = Vec::new();
let mut this_status = DiffStatus::Good;
if assert_name(
emacs,
match rust.name.to_lowercase().as_str() {
let emacs_name = match rust.name.to_lowercase().as_str() {
"center" => "center-block",
"quote" => "quote-block",
_ => todo!(),
},
).is_err() {
};
if assert_name(emacs, emacs_name).is_err() {
this_status = DiffStatus::Bad;
}
@ -308,7 +312,7 @@ fn compare_greater_block<'s>(
Ok(DiffResult {
status: this_status,
name: "greater-block".to_owned(),
name: emacs_name.to_owned(),
message: None,
children: child_status,
})
@ -350,7 +354,8 @@ fn compare_footnote_definition<'s>(
let children = emacs.as_list()?;
let mut child_status = Vec::new();
let mut this_status = DiffStatus::Good;
if assert_name(emacs, "footnote-definition").is_err() {
let emacs_name = "footnote-definition";
if assert_name(emacs, emacs_name).is_err() {
this_status = DiffStatus::Bad;
}
@ -364,7 +369,7 @@ fn compare_footnote_definition<'s>(
Ok(DiffResult {
status: this_status,
name: "footnote-definition".to_owned(),
name: emacs_name.to_owned(),
message: None,
children: child_status,
})
@ -378,7 +383,8 @@ fn compare_comment<'s>(
let children = emacs.as_list()?;
let mut child_status = Vec::new();
let mut this_status = DiffStatus::Good;
if assert_name(emacs, "comment").is_err() {
let emacs_name = "comment";
if assert_name(emacs, emacs_name).is_err() {
this_status = DiffStatus::Bad;
}
@ -388,7 +394,7 @@ fn compare_comment<'s>(
Ok(DiffResult {
status: this_status,
name: "comment".to_owned(),
name: emacs_name.to_owned(),
message: None,
children: child_status,
})
@ -402,7 +408,8 @@ fn compare_drawer<'s>(
let children = emacs.as_list()?;
let mut child_status = Vec::new();
let mut this_status = DiffStatus::Good;
if assert_name(emacs, "drawer").is_err() {
let emacs_name = "drawer";
if assert_name(emacs, emacs_name).is_err() {
this_status = DiffStatus::Bad;
}
@ -416,7 +423,7 @@ fn compare_drawer<'s>(
Ok(DiffResult {
status: this_status,
name: "drawer".to_owned(),
name: emacs_name.to_owned(),
message: None,
children: child_status,
})