Compare document category.

This commit is contained in:
Tom Alexander 2023-09-29 20:23:02 -04:00
parent 93f1bcd744
commit d1dac0b8de
Signed by: talexander
GPG Key ID: D3A179C9A53C0EDE
4 changed files with 27 additions and 1 deletions

View File

@ -0,0 +1 @@
#+CATEGORY: theory

View File

@ -438,7 +438,28 @@ pub fn compare_document<'s>(
Ok(_) => {}
}
// TODO: Compare :path :CATEGORY
// TODO: Compare :path
// Compare category
let category = get_property_quoted_string(emacs, ":CATEGORY")?;
match (category.as_ref(), rust.category) {
(None, None) => {}
(None, Some(_)) | (Some(_), None) => {
this_status = DiffStatus::Bad;
message = Some(format!(
"Category mismatch (emacs != rust) {:?} != {:?}",
category, rust.category
));
}
(Some(e), Some(r)) if e != r => {
this_status = DiffStatus::Bad;
message = Some(format!(
"Category mismatch (emacs != rust) {:?} != {:?}",
category, rust.category
));
}
(Some(_), Some(_)) => {}
};
// Skipping "org-data" and its properties
for (i, token) in children.iter().skip(2).enumerate() {

View File

@ -148,6 +148,7 @@ fn _document<'b, 'g, 'r, 's>(
remaining,
Document {
source: source.into(),
category: None,
zeroth_section,
children,
},

View File

@ -1,4 +1,5 @@
use super::macros::ref_getter;
use super::macros::simple_getter;
use super::Element;
use super::GetStandardProperties;
use super::Object;
@ -10,6 +11,7 @@ pub type HeadlineLevel = u16;
#[derive(Debug)]
pub struct Document<'s> {
pub(crate) source: &'s str,
pub(crate) category: Option<&'s str>,
pub(crate) zeroth_section: Option<Section<'s>>,
pub(crate) children: Vec<Heading<'s>>,
}
@ -73,6 +75,7 @@ impl<'s> StandardProperties<'s> for Heading<'s> {
}
impl<'s> Document<'s> {
simple_getter!(get_category, category, Option<&'s str>);
ref_getter!(get_zeroth_section, zeroth_section, Option<Section<'s>>);
ref_getter!(get_children, children, Vec<Heading<'s>>);
}