Implement the new fields for inline babel call and inline source block.

This commit is contained in:
Tom Alexander 2023-12-11 14:47:22 -05:00
parent 67a9103b07
commit 0b42139393
Signed by: talexander
GPG Key ID: D3A179C9A53C0EDE
3 changed files with 18 additions and 6 deletions

View File

@ -38,7 +38,7 @@ pub(crate) fn inline_babel_call<'b, 'g, 'r, 's>(
let (remaining, arguments) = argument(context, remaining)?; let (remaining, arguments) = argument(context, remaining)?;
let (remaining, end_header) = opt(parser_with_context!(header)(context))(remaining)?; let (remaining, end_header) = opt(parser_with_context!(header)(context))(remaining)?;
let value = get_consumed(input, 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)?; maybe_consume_object_trailing_whitespace_if_not_exiting(context, remaining)?;
let source = get_consumed(input, remaining); let source = get_consumed(input, remaining);
Ok(( Ok((
@ -54,6 +54,7 @@ pub(crate) fn inline_babel_call<'b, 'g, 'r, 's>(
None None
}, },
end_header: end_header.map(Into::<&str>::into), end_header: end_header.map(Into::<&str>::into),
post_blank: post_blank.map(Into::<&str>::into),
}, },
)) ))
} }

View File

@ -38,7 +38,7 @@ pub(crate) fn inline_source_block<'b, 'g, 'r, 's>(
let (remaining, language) = lang(context, remaining)?; let (remaining, language) = lang(context, remaining)?;
let (remaining, parameters) = opt(parser_with_context!(header)(context))(remaining)?; let (remaining, parameters) = opt(parser_with_context!(header)(context))(remaining)?;
let (remaining, value) = body(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)?; 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 inline_source_block<'b, 'g, 'r, 's>(
language: language.into(), language: language.into(),
parameters: parameters.map(Into::<&str>::into), parameters: parameters.map(Into::<&str>::into),
value: value.into(), value: value.into(),
post_blank: post_blank.map(Into::<&str>::into),
}, },
)) ))
} }

View File

@ -245,6 +245,7 @@ pub struct InlineBabelCall<'s> {
pub inside_header: Option<&'s str>, pub inside_header: Option<&'s str>,
pub arguments: Option<&'s str>, pub arguments: Option<&'s str>,
pub end_header: Option<&'s str>, pub end_header: Option<&'s str>,
pub post_blank: Option<&'s str>,
} }
#[derive(Debug)] #[derive(Debug)]
@ -253,6 +254,7 @@ pub struct InlineSourceBlock<'s> {
pub language: &'s str, pub language: &'s str,
pub parameters: Option<&'s str>, pub parameters: Option<&'s str>,
pub value: &'s str, pub value: &'s str,
pub post_blank: Option<&'s str>,
} }
#[derive(Debug)] #[derive(Debug)]
@ -871,11 +873,15 @@ impl<'s> StandardProperties<'s> for InlineBabelCall<'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.")
} }
} }
@ -885,11 +891,15 @@ impl<'s> StandardProperties<'s> for InlineSourceBlock<'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.")
} }
} }