From 0b421393937c82f11265fd331da98a061fd95bcc Mon Sep 17 00:00:00 2001 From: Tom Alexander Date: Mon, 11 Dec 2023 14:47:22 -0500 Subject: [PATCH] Implement the new fields for inline babel call and inline source block. --- src/parser/inline_babel_call.rs | 3 ++- src/parser/inline_source_block.rs | 3 ++- src/types/object.rs | 18 ++++++++++++++---- 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/src/parser/inline_babel_call.rs b/src/parser/inline_babel_call.rs index f059da0..7f67a71 100644 --- a/src/parser/inline_babel_call.rs +++ b/src/parser/inline_babel_call.rs @@ -38,7 +38,7 @@ pub(crate) fn inline_babel_call<'b, 'g, 'r, 's>( let (remaining, arguments) = argument(context, remaining)?; let (remaining, end_header) = opt(parser_with_context!(header)(context))(remaining)?; let value = get_consumed(input, 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); Ok(( @@ -54,6 +54,7 @@ pub(crate) fn inline_babel_call<'b, 'g, 'r, 's>( None }, end_header: end_header.map(Into::<&str>::into), + post_blank: post_blank.map(Into::<&str>::into), }, )) } diff --git a/src/parser/inline_source_block.rs b/src/parser/inline_source_block.rs index f0e22a7..11ce69b 100644 --- a/src/parser/inline_source_block.rs +++ b/src/parser/inline_source_block.rs @@ -38,7 +38,7 @@ pub(crate) fn inline_source_block<'b, 'g, 'r, 's>( let (remaining, language) = lang(context, remaining)?; let (remaining, parameters) = opt(parser_with_context!(header)(context))(remaining)?; let (remaining, value) = body(context, 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); Ok(( @@ -48,6 +48,7 @@ pub(crate) fn inline_source_block<'b, 'g, 'r, 's>( language: language.into(), parameters: parameters.map(Into::<&str>::into), value: value.into(), + post_blank: post_blank.map(Into::<&str>::into), }, )) } diff --git a/src/types/object.rs b/src/types/object.rs index 892616a..b4a8095 100644 --- a/src/types/object.rs +++ b/src/types/object.rs @@ -245,6 +245,7 @@ pub struct InlineBabelCall<'s> { pub inside_header: Option<&'s str>, pub arguments: Option<&'s str>, pub end_header: Option<&'s str>, + pub post_blank: Option<&'s str>, } #[derive(Debug)] @@ -253,6 +254,7 @@ pub struct InlineSourceBlock<'s> { pub language: &'s str, pub parameters: Option<&'s str>, pub value: &'s str, + pub post_blank: Option<&'s str>, } #[derive(Debug)] @@ -871,11 +873,15 @@ impl<'s> StandardProperties<'s> for InlineBabelCall<'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.chars().count()) + .unwrap_or(0) + .try_into() + .expect("Too much post-blank to fit into a PostBlank.") } } @@ -885,11 +891,15 @@ impl<'s> StandardProperties<'s> for InlineSourceBlock<'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.chars().count()) + .unwrap_or(0) + .try_into() + .expect("Too much post-blank to fit into a PostBlank.") } }