Implement the new fields for target.

This commit is contained in:
Tom Alexander 2023-12-15 18:57:19 -05:00
parent 33ca43ca40
commit 6b802d36bf
Signed by: talexander
GPG Key ID: D3A179C9A53C0EDE
3 changed files with 12 additions and 3 deletions

View File

@ -0,0 +1,3 @@
<<FOO>> bar
[[FOO][baz]]

View File

@ -46,7 +46,7 @@ pub(crate) fn target<'b, 'g, 'r, 's>(
))); )));
} }
let (remaining, _) = tag(">>")(remaining)?; let (remaining, _) = tag(">>")(remaining)?;
let (remaining, _trailing_whitespace) = let (remaining, post_blank) =
maybe_consume_object_trailing_whitespace_if_not_exiting(context, remaining)?; maybe_consume_object_trailing_whitespace_if_not_exiting(context, remaining)?;
let source = get_consumed(input, remaining); let source = get_consumed(input, remaining);
@ -55,6 +55,7 @@ pub(crate) fn target<'b, 'g, 'r, 's>(
Target { Target {
source: source.into(), source: source.into(),
value: body.into(), value: body.into(),
post_blank: post_blank.map(Into::<&str>::into),
}, },
)) ))
} }

View File

@ -266,6 +266,7 @@ pub struct LineBreak<'s> {
pub struct Target<'s> { pub struct Target<'s> {
pub source: &'s str, pub source: &'s str,
pub value: &'s str, pub value: &'s str,
pub post_blank: Option<&'s str>,
} }
#[derive(Debug)] #[derive(Debug)]
@ -923,11 +924,15 @@ impl<'s> StandardProperties<'s> for Target<'s> {
} }
fn get_contents<'b>(&'b self) -> Option<&'s str> { fn get_contents<'b>(&'b self) -> Option<&'s str> {
todo!() None
} }
fn get_post_blank(&self) -> PostBlank { 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.")
} }
} }