Compare document category.
This commit is contained in:
parent
93f1bcd744
commit
d1dac0b8de
1
org_mode_samples/document/category.org
Normal file
1
org_mode_samples/document/category.org
Normal file
@ -0,0 +1 @@
|
|||||||
|
#+CATEGORY: theory
|
@ -438,7 +438,28 @@ pub fn compare_document<'s>(
|
|||||||
Ok(_) => {}
|
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
|
// Skipping "org-data" and its properties
|
||||||
for (i, token) in children.iter().skip(2).enumerate() {
|
for (i, token) in children.iter().skip(2).enumerate() {
|
||||||
|
@ -148,6 +148,7 @@ fn _document<'b, 'g, 'r, 's>(
|
|||||||
remaining,
|
remaining,
|
||||||
Document {
|
Document {
|
||||||
source: source.into(),
|
source: source.into(),
|
||||||
|
category: None,
|
||||||
zeroth_section,
|
zeroth_section,
|
||||||
children,
|
children,
|
||||||
},
|
},
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
use super::macros::ref_getter;
|
use super::macros::ref_getter;
|
||||||
|
use super::macros::simple_getter;
|
||||||
use super::Element;
|
use super::Element;
|
||||||
use super::GetStandardProperties;
|
use super::GetStandardProperties;
|
||||||
use super::Object;
|
use super::Object;
|
||||||
@ -10,6 +11,7 @@ pub type HeadlineLevel = u16;
|
|||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct Document<'s> {
|
pub struct Document<'s> {
|
||||||
pub(crate) source: &'s str,
|
pub(crate) source: &'s str,
|
||||||
|
pub(crate) category: Option<&'s str>,
|
||||||
pub(crate) zeroth_section: Option<Section<'s>>,
|
pub(crate) zeroth_section: Option<Section<'s>>,
|
||||||
pub(crate) children: Vec<Heading<'s>>,
|
pub(crate) children: Vec<Heading<'s>>,
|
||||||
}
|
}
|
||||||
@ -73,6 +75,7 @@ impl<'s> StandardProperties<'s> for Heading<'s> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl<'s> Document<'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_zeroth_section, zeroth_section, Option<Section<'s>>);
|
||||||
ref_getter!(get_children, children, Vec<Heading<'s>>);
|
ref_getter!(get_children, children, Vec<Heading<'s>>);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user