Compare footnote section.
This commit is contained in:
@@ -9,6 +9,7 @@ use super::sexp::unquote;
|
||||
use super::sexp::Token;
|
||||
use super::util::compare_standard_properties;
|
||||
use super::util::get_property;
|
||||
use super::util::get_property_boolean;
|
||||
use super::util::get_property_quoted_string;
|
||||
use super::util::get_property_unquoted_atom;
|
||||
use crate::types::AngleLink;
|
||||
@@ -726,7 +727,17 @@ fn compare_heading<'s>(
|
||||
));
|
||||
}
|
||||
|
||||
// TODO: Compare :pre-blank :footnote-section-p :scheduled :closed
|
||||
// Compare footnote-section-p
|
||||
let footnote_section = get_property_boolean(emacs, ":footnote-section-p")?;
|
||||
if footnote_section != rust.is_footnote_section {
|
||||
this_status = DiffStatus::Bad;
|
||||
message = Some(format!(
|
||||
"footnote section mismatch (emacs != rust) {:?} != {:?}",
|
||||
footnote_section, rust.is_footnote_section
|
||||
));
|
||||
}
|
||||
|
||||
// TODO: Compare :pre-blank :scheduled :closed
|
||||
//
|
||||
// :scheduled and :closed seem to only appear when the headline has a planning
|
||||
|
||||
|
||||
@@ -217,3 +217,19 @@ pub(crate) fn get_property_quoted_string<'s, 'x>(
|
||||
.map(unquote)
|
||||
.map_or(Ok(None), |r| r.map(Some))?)
|
||||
}
|
||||
|
||||
/// Get a named property containing a boolean value.
|
||||
///
|
||||
/// This uses the elisp convention of nil == false, non-nil == true.
|
||||
///
|
||||
/// Returns false if key is not found.
|
||||
pub(crate) fn get_property_boolean<'s, 'x>(
|
||||
emacs: &'s Token<'s>,
|
||||
key: &'x str,
|
||||
) -> Result<bool, Box<dyn std::error::Error>> {
|
||||
Ok(get_property(emacs, key)?
|
||||
.map(Token::as_atom)
|
||||
.map_or(Ok(None), |r| r.map(Some))?
|
||||
.unwrap_or("nil")
|
||||
!= "nil")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user