Trim whitespace from raw value.

This commit is contained in:
Tom Alexander 2023-10-02 16:32:33 -04:00
parent dec3242e72
commit 9846cde2f0
Signed by: talexander
GPG Key ID: D3A179C9A53C0EDE
2 changed files with 15 additions and 2 deletions

View File

@ -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<HourInner> = get_property_numeric(emacs, ":hour-start")?;
let minute_start: Option<MinuteInner> = 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.

View File

@ -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()
}
}