From f192507cd992bebcc54bb11b8744589debbf0d34 Mon Sep 17 00:00:00 2001 From: Tom Alexander Date: Fri, 15 Dec 2023 12:10:34 -0500 Subject: [PATCH] Implement the new fields for diary sexp. --- src/parser/diary_sexp.rs | 3 ++- src/types/lesser_element.rs | 9 +++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/parser/diary_sexp.rs b/src/parser/diary_sexp.rs index c58f0d37..5230e2f9 100644 --- a/src/parser/diary_sexp.rs +++ b/src/parser/diary_sexp.rs @@ -31,7 +31,7 @@ where let (remaining, value) = recognize(tuple((tag("%%("), is_not("\r\n"))))(remaining)?; let (remaining, _eol) = 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(( @@ -43,6 +43,7 @@ where affiliated_keywords, ), value: Into::<&str>::into(value), + post_blank: post_blank.map(Into::<&str>::into), }, )) } diff --git a/src/types/lesser_element.rs b/src/types/lesser_element.rs index 1a3c185b..9c4ff951 100644 --- a/src/types/lesser_element.rs +++ b/src/types/lesser_element.rs @@ -132,6 +132,7 @@ pub struct DiarySexp<'s> { pub source: &'s str, pub affiliated_keywords: AffiliatedKeywords<'s>, pub value: &'s str, + pub post_blank: Option<&'s str>, } #[derive(Debug)] @@ -370,11 +371,15 @@ impl<'s> StandardProperties<'s> for DiarySexp<'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.") } }