diff --git a/org_mode_samples/affiliated_keyword/empty_caption.org b/org_mode_samples/affiliated_keyword/empty_caption.org new file mode 100644 index 0000000..08d802f --- /dev/null +++ b/org_mode_samples/affiliated_keyword/empty_caption.org @@ -0,0 +1,5 @@ +#+caption: +#+caption: *foo* +#+caption[bar]: +#+begin_src bash +#+end_src diff --git a/src/compare/compare_field.rs b/src/compare/compare_field.rs index 3d40dd9..9ab611f 100644 --- a/src/compare/compare_field.rs +++ b/src/compare/compare_field.rs @@ -548,6 +548,21 @@ where let mut full_status: Vec> = Vec::with_capacity(outer_rust_list.len()); for (kw_e, kw_r) in outer_emacs_list.iter().zip(outer_rust_list) { + match (kw_e.as_atom(), kw_r) { + (Ok("nil"), (None, mandatory_value)) if mandatory_value.is_empty() => { + // If its an empty keyword then it becomes nil in the elisp. + continue; + } + (Ok("nil"), _) => { + let this_status = DiffStatus::Bad; + let message = Some(format!( + "{} mismatch (emacs != rust) {:?} != {:?}", + emacs_field, kw_e, kw_r + )); + return Ok(ComparePropertiesResult::SelfChange(this_status, message)); + } + _ => {} + } let kw_e = kw_e.as_list()?; let child_status_length = kw_r.1.len() + kw_r.0.as_ref().map(|opt| opt.len()).unwrap_or(0); let mut child_status: Vec> = Vec::with_capacity(child_status_length); @@ -556,18 +571,31 @@ where let mut kw_e = kw_e.iter(); // First element is a list representing the mandatory value. if let Some(val_e) = kw_e.next() { - let el = val_e.as_list()?; - if el.len() != kw_r.1.len() { - let this_status = DiffStatus::Bad; - let message = Some(format!( - "{} mismatch (emacs != rust) {:?} != {:?}", - emacs_field, kw_e, kw_r - )); - return Ok(ComparePropertiesResult::SelfChange(this_status, message)); - } - for (e, r) in el.iter().zip(kw_r.1.iter()) { - child_status.push(compare_ast_node(source, e, r.into())?); - } + match (val_e.as_atom(), kw_r) { + (Ok("nil"), (_, mandatory_value)) if mandatory_value.is_empty() => {} + (Ok("nil"), _) => { + let this_status = DiffStatus::Bad; + let message = Some(format!( + "{} mismatch (emacs != rust) {:?} != {:?}", + emacs_field, kw_e, kw_r + )); + return Ok(ComparePropertiesResult::SelfChange(this_status, message)); + } + _ => { + let el = val_e.as_list()?; + if el.len() != kw_r.1.len() { + let this_status = DiffStatus::Bad; + let message = Some(format!( + "{} mismatch (emacs != rust) {:?} != {:?}", + emacs_field, kw_e, kw_r + )); + return Ok(ComparePropertiesResult::SelfChange(this_status, message)); + } + for (e, r) in el.iter().zip(kw_r.1.iter()) { + child_status.push(compare_ast_node(source, e, r.into())?); + } + } + }; } else { let this_status = DiffStatus::Bad; let message = Some(format!(