Add capitalization.

This commit is contained in:
Tom Alexander 2023-10-11 12:42:42 -04:00
parent 8e0a7dea0f
commit e767892dd5
Signed by: talexander
GPG Key ID: D3A179C9A53C0EDE
3 changed files with 83 additions and 0 deletions

View File

@ -27,3 +27,37 @@
#+attr_latex: mm
#+attr_html: nn
1. bar
#+NAME: A
#+CAPTION: B *LOREM* IPSUM
#+RESULTS: C
#+HEADERS: D
#+HEADER: E
#+LABEL: F
#+PLOT: G
#+RESNAME: H
#+RESULT: I
#+SOURCE: J
#+SRCNAME: K
#+TBLNAME: L
#+ATTR_LATEX: M
#+ATTR_HTML: N
#+NAME: AA
#+CAPTION: BB *LOREM* IPSUM
#+RESULTS: CC
#+HEADERS: DD
#+HEADER: EE
#+LABEL: FF
#+PLOT: GG
#+RESNAME: HH
#+RESULT: II
#+SOURCE: JJ
#+SRCNAME: KK
#+TBLNAME: LL
#+ATTR_LATEX: MM
#+ATTR_HTML: NN
1. BAR

View File

@ -20,8 +20,10 @@ use super::elisp_fact::ElispFact;
use super::elisp_fact::GetElispFact;
use super::sexp::unquote;
use super::sexp::Token;
use super::util::affiliated_keywords_names;
use super::util::assert_no_children;
use super::util::compare_additional_properties;
use super::util::compare_affiliated_keywords;
use super::util::compare_children;
use super::util::compare_children_iter;
use super::util::compare_standard_properties;
@ -755,10 +757,21 @@ fn compare_plain_list<'b, 's>(
&mut message,
)?;
compare_affiliated_keywords(emacs, rust)?.apply(
&mut child_status,
&mut this_status,
&mut message,
);
let affiliated_keywords_names: Vec<String> = affiliated_keywords_names(rust).collect();
for diff in compare_properties!(
source,
emacs,
rust,
affiliated_keywords_names
.iter()
.map(String::as_str)
.map(EmacsField::Required),
(
EmacsField::Optional(":name"),
|r| r.name,

View File

@ -8,6 +8,7 @@ use super::sexp::Token;
use crate::compare::diff::compare_ast_node;
use crate::compare::sexp::unquote;
use crate::types::AstNode;
use crate::types::GetAffiliatedKeywords;
use crate::types::GetStandardProperties;
use crate::types::StandardProperties;
@ -337,3 +338,38 @@ where
}
Ok(ComparePropertiesResult::NoChange)
}
pub(crate) fn compare_affiliated_keywords<'b, 's, GAK>(
emacs: &'b Token<'s>,
rust: &'b GAK,
) -> Result<ComparePropertiesResult<'b, 's>, Box<dyn std::error::Error>>
where
GAK: GetAffiliatedKeywords<'s>,
{
let affiliated_keywords = rust.get_affiliated_keywords();
for (rust_name, rust_value) in affiliated_keywords.keywords.iter() {
let emacs_property_name = format!(":{}", rust_name);
let emacs_property = get_property(emacs, emacs_property_name.as_str())?;
if let Some(emacs_property) = emacs_property {
// foo
} else {
let this_status = DiffStatus::Bad;
let message = Some(format!(
"{} mismatch (emacs != rust) {:?} != {:?}",
rust_name, emacs_property, rust_value
));
return Ok(ComparePropertiesResult::SelfChange(this_status, message));
}
}
Ok(ComparePropertiesResult::NoChange)
}
pub(crate) fn affiliated_keywords_names<'s, GAK>(rust: &'s GAK) -> impl Iterator<Item = String> + 's
where
GAK: GetAffiliatedKeywords<'s>,
{
rust.get_affiliated_keywords()
.keywords
.keys()
.map(|k| format!(":{}", k))
}