Implement the new fields for radio link.

This commit is contained in:
Tom Alexander 2023-12-11 14:10:27 -05:00
parent 4753f4c7c6
commit 68dccd54b1
Signed by: talexander
GPG Key ID: D3A179C9A53C0EDE
2 changed files with 13 additions and 3 deletions

View File

@ -39,7 +39,7 @@ pub(crate) fn radio_link<'b, 'g, 'r, 's>(
let rematched_target = rematch_target(context, radio_target, input);
if let Ok((remaining, rematched_target)) = rematched_target {
let path = get_consumed(input, remaining);
let (remaining, _) = space0(remaining)?;
let (remaining, post_blank) = space0(remaining)?;
let source = get_consumed(input, remaining);
return Ok((
remaining,
@ -47,6 +47,11 @@ pub(crate) fn radio_link<'b, 'g, 'r, 's>(
source: source.into(),
children: rematched_target,
path: path.into(),
post_blank: if post_blank.len() > 0 {
Some(Into::<&str>::into(post_blank))
} else {
None
},
},
));
}

View File

@ -128,6 +128,7 @@ pub struct RadioTarget<'s> {
pub struct RadioLink<'s> {
pub source: &'s str,
pub path: &'s str,
pub post_blank: Option<&'s str>,
pub children: Vec<Object<'s>>,
}
@ -671,11 +672,15 @@ impl<'s> StandardProperties<'s> for RadioLink<'s> {
}
fn get_contents<'b>(&'b self) -> Option<&'s str> {
todo!()
Some(self.path)
}
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.")
}
}