From 6b802d36bfc01477152ffc5421540a008d7ab535 Mon Sep 17 00:00:00 2001 From: Tom Alexander Date: Fri, 15 Dec 2023 18:57:19 -0500 Subject: [PATCH] Implement the new fields for target. --- org_mode_samples/object/target/simple.org | 3 +++ src/parser/target.rs | 3 ++- src/types/object.rs | 9 +++++++-- 3 files changed, 12 insertions(+), 3 deletions(-) create mode 100644 org_mode_samples/object/target/simple.org diff --git a/org_mode_samples/object/target/simple.org b/org_mode_samples/object/target/simple.org new file mode 100644 index 00000000..2a5e00bf --- /dev/null +++ b/org_mode_samples/object/target/simple.org @@ -0,0 +1,3 @@ +<> bar + +[[FOO][baz]] diff --git a/src/parser/target.rs b/src/parser/target.rs index d91fa2ff..10dde096 100644 --- a/src/parser/target.rs +++ b/src/parser/target.rs @@ -46,7 +46,7 @@ pub(crate) fn target<'b, 'g, 'r, 's>( ))); } let (remaining, _) = tag(">>")(remaining)?; - let (remaining, _trailing_whitespace) = + let (remaining, post_blank) = maybe_consume_object_trailing_whitespace_if_not_exiting(context, remaining)?; let source = get_consumed(input, remaining); @@ -55,6 +55,7 @@ pub(crate) fn target<'b, 'g, 'r, 's>( Target { source: source.into(), value: body.into(), + post_blank: post_blank.map(Into::<&str>::into), }, )) } diff --git a/src/types/object.rs b/src/types/object.rs index b4a80955..05bf8881 100644 --- a/src/types/object.rs +++ b/src/types/object.rs @@ -266,6 +266,7 @@ pub struct LineBreak<'s> { pub struct Target<'s> { pub source: &'s str, pub value: &'s str, + pub post_blank: Option<&'s str>, } #[derive(Debug)] @@ -923,11 +924,15 @@ impl<'s> StandardProperties<'s> for Target<'s> { } fn get_contents<'b>(&'b self) -> Option<&'s str> { - todo!() + None } fn get_post_blank(&self) -> PostBlank { - todo!() + self.post_blank + .map(|post_blank| post_blank.chars().count()) + .unwrap_or(0) + .try_into() + .expect("Too much post-blank to fit into a PostBlank.") } }