Compare plain list item bullets.
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_quoted_string;
|
||||
use super::util::get_property_unquoted_atom;
|
||||
use crate::types::AngleLink;
|
||||
use crate::types::BabelCall;
|
||||
@@ -830,7 +831,16 @@ fn compare_plain_list_item<'s>(
|
||||
.collect::<Result<Vec<_>, _>>()?;
|
||||
child_status.push(artificial_diff_scope("contents", contents_status)?);
|
||||
|
||||
// TODO: Compare :bullet :counter :pre-blank
|
||||
// TODO: Compare :counter :pre-blank
|
||||
let bullet = get_property_quoted_string(emacs, ":bullet")?
|
||||
.ok_or("Plain list items must have a :bullet.")?;
|
||||
if bullet != rust.bullet {
|
||||
this_status = DiffStatus::Bad;
|
||||
message = Some(format!(
|
||||
"Plain list item bullet mismatch (emacs != rust) {:?} != {:?}",
|
||||
bullet, rust.bullet
|
||||
));
|
||||
}
|
||||
|
||||
// Compare checkbox
|
||||
let checkbox = get_property(emacs, ":checkbox")?
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
use super::elisp_fact::GetElispFact;
|
||||
use super::sexp::Token;
|
||||
use crate::compare::sexp::unquote;
|
||||
use crate::types::GetStandardProperties;
|
||||
use crate::types::StandardProperties;
|
||||
|
||||
@@ -202,3 +203,17 @@ pub(crate) fn get_property_unquoted_atom<'s, 'x>(
|
||||
.map(Token::as_atom)
|
||||
.map_or(Ok(None), |r| r.map(Some))?)
|
||||
}
|
||||
|
||||
/// Get a named property containing an quoted string from the emacs token.
|
||||
///
|
||||
/// Returns None if key is not found.
|
||||
pub(crate) fn get_property_quoted_string<'s, 'x>(
|
||||
emacs: &'s Token<'s>,
|
||||
key: &'x str,
|
||||
) -> Result<Option<String>, Box<dyn std::error::Error>> {
|
||||
Ok(get_property(emacs, key)?
|
||||
.map(Token::as_atom)
|
||||
.map_or(Ok(None), |r| r.map(Some))?
|
||||
.map(unquote)
|
||||
.map_or(Ok(None), |r| r.map(Some))?)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user