Compare footnote section.

This commit is contained in:
Tom Alexander
2023-10-02 10:48:34 -04:00
parent d78ce10a0b
commit 178894680b
6 changed files with 46 additions and 3 deletions

View File

@@ -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")
}