From d6232dc49c3fb54c6979782eeb2905bfdbe3f20a Mon Sep 17 00:00:00 2001 From: Tom Alexander Date: Fri, 15 Dec 2023 10:49:04 -0500 Subject: [PATCH] Implement the new fields for clock. --- src/parser/clock.rs | 3 ++- src/types/lesser_element.rs | 9 +++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/parser/clock.rs b/src/parser/clock.rs index e25dd391..0ad17b0a 100644 --- a/src/parser/clock.rs +++ b/src/parser/clock.rs @@ -40,7 +40,7 @@ pub(crate) fn clock<'b, 'g, 'r, 's>( let (remaining, (timestamp, duration)) = clock_timestamp(context, remaining)?; let (remaining, _) = tuple((space0, org_line_ending))(remaining)?; - let (remaining, _trailing_ws) = + let (remaining, post_blank) = maybe_consume_trailing_whitespace_if_not_exiting(context, remaining)?; let source = get_consumed(input, remaining); Ok(( @@ -54,6 +54,7 @@ pub(crate) fn clock<'b, 'g, 'r, 's>( } else { ClockStatus::Running }, + post_blank: post_blank.map(Into::<&str>::into), }, )) } diff --git a/src/types/lesser_element.rs b/src/types/lesser_element.rs index 004f938e..1a3c185b 100644 --- a/src/types/lesser_element.rs +++ b/src/types/lesser_element.rs @@ -124,6 +124,7 @@ pub struct Clock<'s> { pub timestamp: Timestamp<'s>, pub duration: Option<&'s str>, pub status: ClockStatus, + pub post_blank: Option<&'s str>, } #[derive(Debug)] @@ -351,11 +352,15 @@ impl<'s> StandardProperties<'s> for Clock<'s> { } fn get_contents<'b>(&'b self) -> Option<&'s str> { - todo!() + None } fn get_post_blank(&self) -> PostBlank { - todo!() + self.post_blank + .map(|text| text.lines().count()) + .unwrap_or(0) + .try_into() + .expect("Too much post-blank to fit into a PostBlank.") } }