Implement the new fields for export snippet.

This commit is contained in:
Tom Alexander 2023-12-11 14:41:49 -05:00
parent f141a4e186
commit 67a9103b07
Signed by: talexander
GPG Key ID: D3A179C9A53C0EDE
2 changed files with 9 additions and 3 deletions

View File

@ -39,7 +39,7 @@ pub(crate) fn export_snippet<'b, 'g, 'r, 's>(
parser_with_context!(contents)(&parser_context), parser_with_context!(contents)(&parser_context),
)))(remaining)?; )))(remaining)?;
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);
Ok(( Ok((
@ -48,6 +48,7 @@ pub(crate) fn export_snippet<'b, 'g, 'r, 's>(
source: source.into(), source: source.into(),
backend: backend_name.into(), backend: backend_name.into(),
contents: backend_contents.map(|(_colon, backend_contents)| backend_contents.into()), contents: backend_contents.map(|(_colon, backend_contents)| backend_contents.into()),
post_blank: post_blank.map(Into::<&str>::into),
}, },
)) ))
} }

View File

@ -206,6 +206,7 @@ pub struct ExportSnippet<'s> {
pub source: &'s str, pub source: &'s str,
pub backend: &'s str, pub backend: &'s str,
pub contents: Option<&'s str>, pub contents: Option<&'s str>,
pub post_blank: Option<&'s str>,
} }
#[derive(Debug)] #[derive(Debug)]
@ -802,11 +803,15 @@ impl<'s> StandardProperties<'s> for ExportSnippet<'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(|text| text.chars().count())
.unwrap_or(0)
.try_into()
.expect("Too much post-blank to fit into a PostBlank.")
} }
} }