diff --git a/src/compare/diff.rs b/src/compare/diff.rs index e9bd492..052df3f 100644 --- a/src/compare/diff.rs +++ b/src/compare/diff.rs @@ -2161,8 +2161,6 @@ fn compare_diary_sexp<'b, 's>( let mut this_status = DiffStatus::Good; let mut message = None; - // TODO: Compare :value - // TODO: Compare :caption // Compare name let name = get_property_quoted_string(emacs, ":name")?; @@ -2174,6 +2172,16 @@ fn compare_diary_sexp<'b, 's>( )); } + // Compare value + let value = get_property_quoted_string(emacs, ":value")?; + if value.as_ref().map(String::as_str) != Some(rust.value) { + this_status = DiffStatus::Bad; + message = Some(format!( + "Value mismatch (emacs != rust) {:?} != {:?}", + value, rust.value + )); + } + Ok(DiffResult { status: this_status, name: rust.get_elisp_name(), diff --git a/src/parser/diary_sexp.rs b/src/parser/diary_sexp.rs index 5c506f5..235fcab 100644 --- a/src/parser/diary_sexp.rs +++ b/src/parser/diary_sexp.rs @@ -1,14 +1,13 @@ -use nom::branch::alt; use nom::bytes::complete::is_not; use nom::bytes::complete::tag; -use nom::character::complete::line_ending; -use nom::combinator::eof; +use nom::combinator::recognize; use nom::multi::many0; use nom::sequence::tuple; use super::keyword::affiliated_keyword; use super::org_source::OrgSource; use super::util::get_name; +use super::util::org_line_ending; use crate::context::RefContext; use crate::error::Res; use crate::parser::util::get_consumed; @@ -22,9 +21,8 @@ pub(crate) fn diary_sexp<'b, 'g, 'r, 's>( ) -> Res, DiarySexp<'s>> { let (input, affiliated_keywords) = many0(affiliated_keyword)(input)?; start_of_line(input)?; - let (remaining, _clock) = tag("%%(")(input)?; - let (remaining, _contents) = is_not("\r\n")(remaining)?; - let (remaining, _eol) = alt((line_ending, eof))(remaining)?; + let (remaining, value) = recognize(tuple((tag("%%("), is_not("\r\n"))))(input)?; + let (remaining, _eol) = org_line_ending(remaining)?; let source = get_consumed(input, remaining); Ok(( @@ -32,6 +30,7 @@ pub(crate) fn diary_sexp<'b, 'g, 'r, 's>( DiarySexp { source: source.into(), name: get_name(&affiliated_keywords), + value: Into::<&str>::into(value), }, )) } diff --git a/src/types/lesser_element.rs b/src/types/lesser_element.rs index dd19efe..402636f 100644 --- a/src/types/lesser_element.rs +++ b/src/types/lesser_element.rs @@ -102,6 +102,7 @@ pub struct Clock<'s> { pub struct DiarySexp<'s> { pub source: &'s str, pub name: Option<&'s str>, + pub value: &'s str, } #[derive(Debug)]