From 9846cde2f04f8a3f93a1440d21f3e0982abdeff9 Mon Sep 17 00:00:00 2001 From: Tom Alexander Date: Mon, 2 Oct 2023 16:32:33 -0400 Subject: [PATCH] Trim whitespace from raw value. --- src/compare/diff.rs | 11 +++++++++-- src/types/object.rs | 6 ++++++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/compare/diff.rs b/src/compare/diff.rs index 98a7bdc..79288b7 100644 --- a/src/compare/diff.rs +++ b/src/compare/diff.rs @@ -43,6 +43,7 @@ use crate::types::GetStandardProperties; use crate::types::GreaterBlock; use crate::types::Heading; use crate::types::HorizontalRule; +use crate::types::HourInner; use crate::types::InlineBabelCall; use crate::types::InlineSourceBlock; use crate::types::Italic; @@ -50,6 +51,7 @@ use crate::types::Keyword; use crate::types::LatexEnvironment; use crate::types::LatexFragment; use crate::types::LineBreak; +use crate::types::MinuteInner; use crate::types::Month; use crate::types::MonthInner; use crate::types::NodeProperty; @@ -2163,11 +2165,12 @@ fn compare_timestamp<'b, 's>( // Compare raw-value let raw_value = get_property_quoted_string(emacs, ":raw-value")? .ok_or("Timestamps should have a :raw-value.")?; - if raw_value != rust.source { + if raw_value != rust.get_raw_value() { this_status = DiffStatus::Bad; message = Some(format!( "Raw value mismatch (emacs != rust) {:?} != {:?}", - raw_value, rust.source + raw_value, + rust.get_raw_value() )); } @@ -2241,6 +2244,10 @@ fn compare_timestamp<'b, 's>( )); } + // Compare time start + let hour_start: Option = get_property_numeric(emacs, ":hour-start")?; + let minute_start: Option = get_property_numeric(emacs, ":minute-start")?; + // TODO: Compare :hour-start :minute-start :hour-end :minute-end :repeater-type :repeater-value :repeater-unit :warning-type :warning-value :warning-unit // // :type unquoted atom either diary, active, inactive, active-range, or inactive-range. diff --git a/src/types/object.rs b/src/types/object.rs index 885745a..229e2a9 100644 --- a/src/types/object.rs +++ b/src/types/object.rs @@ -586,3 +586,9 @@ impl<'s> StandardProperties<'s> for PlainText<'s> { self.source } } + +impl<'s> Timestamp<'s> { + pub fn get_raw_value(&self) -> &'s str { + self.source.trim_end() + } +}