compare_properties paragraph.
This commit is contained in:
parent
33c53a14ab
commit
7a38d1ead3
@ -596,6 +596,7 @@ fn compare_section<'b, 's>(
|
|||||||
.into())
|
.into())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(dead_code)]
|
||||||
fn new_compare_heading<'b, 's>(
|
fn new_compare_heading<'b, 's>(
|
||||||
source: &'s str,
|
source: &'s str,
|
||||||
emacs: &'b Token<'s>,
|
emacs: &'b Token<'s>,
|
||||||
@ -1004,24 +1005,42 @@ fn compare_paragraph<'b, 's>(
|
|||||||
emacs: &'b Token<'s>,
|
emacs: &'b Token<'s>,
|
||||||
rust: &'b Paragraph<'s>,
|
rust: &'b Paragraph<'s>,
|
||||||
) -> Result<DiffEntry<'b, 's>, Box<dyn std::error::Error>> {
|
) -> Result<DiffEntry<'b, 's>, Box<dyn std::error::Error>> {
|
||||||
let children = emacs.as_list()?;
|
|
||||||
let mut child_status = Vec::new();
|
|
||||||
let mut this_status = DiffStatus::Good;
|
let mut this_status = DiffStatus::Good;
|
||||||
|
let mut child_status = Vec::new();
|
||||||
let mut message = None;
|
let mut message = None;
|
||||||
|
|
||||||
// TODO: Compare :caption
|
compare_children(
|
||||||
// Compare name
|
source,
|
||||||
let name = get_property_quoted_string(emacs, ":name")?;
|
emacs,
|
||||||
if name.as_ref().map(String::as_str) != rust.name {
|
&rust.children,
|
||||||
this_status = DiffStatus::Bad;
|
&mut child_status,
|
||||||
message = Some(format!(
|
&mut this_status,
|
||||||
"Name mismatch (emacs != rust) {:?} != {:?}",
|
&mut message,
|
||||||
name, rust.name
|
)?;
|
||||||
));
|
|
||||||
}
|
|
||||||
|
|
||||||
for (emacs_child, rust_child) in children.iter().skip(2).zip(rust.children.iter()) {
|
for diff in compare_properties!(
|
||||||
child_status.push(compare_ast_node(source, emacs_child, rust_child.into())?);
|
source,
|
||||||
|
emacs,
|
||||||
|
rust,
|
||||||
|
(
|
||||||
|
EmacsField::Optional(":name"),
|
||||||
|
|r| r.name,
|
||||||
|
compare_property_quoted_string
|
||||||
|
),
|
||||||
|
(
|
||||||
|
EmacsField::Optional(":caption"),
|
||||||
|
compare_identity,
|
||||||
|
compare_noop
|
||||||
|
)
|
||||||
|
) {
|
||||||
|
match diff {
|
||||||
|
ComparePropertiesResult::NoChange => {}
|
||||||
|
ComparePropertiesResult::SelfChange(new_status, new_message) => {
|
||||||
|
this_status = new_status;
|
||||||
|
message = new_message
|
||||||
|
}
|
||||||
|
ComparePropertiesResult::DiffEntry(diff_entry) => child_status.push(diff_entry),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(DiffResult {
|
Ok(DiffResult {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user