diff --git a/src/parser/citation.rs b/src/parser/citation.rs index 69d7c62..983048f 100644 --- a/src/parser/citation.rs +++ b/src/parser/citation.rs @@ -46,16 +46,22 @@ pub(crate) fn citation<'b, 'g, 'r, 's>( let (remaining, prefix) = must_balance_bracket(opt(parser_with_context!(global_prefix)(context)))(remaining)?; + let contents_begin = remaining; let (remaining, references) = separated_list1(tag(";"), parser_with_context!(citation_reference)(context))(remaining)?; + let contents_end = { + let (rem, _) = opt(tag(";"))(remaining)?; + rem + }; let (remaining, suffix) = must_balance_bracket(opt(map( tuple((tag(";"), parser_with_context!(global_suffix)(context))), |(_, suffix)| suffix, )))(remaining)?; let (remaining, _) = tag("]")(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); + let contents = contents_begin.get_until(contents_end); Ok(( remaining, Citation { @@ -64,6 +70,8 @@ pub(crate) fn citation<'b, 'g, 'r, 's>( prefix: prefix.unwrap_or(Vec::new()), suffix: suffix.unwrap_or(Vec::new()), children: references, + contents: Into::<&str>::into(contents), + post_blank: post_blank.map(Into::<&str>::into), }, )) } diff --git a/src/types/object.rs b/src/types/object.rs index a535fd1..894cc1a 100644 --- a/src/types/object.rs +++ b/src/types/object.rs @@ -224,6 +224,8 @@ pub struct Citation<'s> { pub prefix: Vec>, pub suffix: Vec>, pub children: Vec>, + pub contents: &'s str, + pub post_blank: Option<&'s str>, } #[derive(Debug)] @@ -832,11 +834,15 @@ impl<'s> StandardProperties<'s> for Citation<'s> { } fn get_contents<'b>(&'b self) -> Option<&'s str> { - todo!() + Some(self.contents) } 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.") } } @@ -846,11 +852,11 @@ impl<'s> StandardProperties<'s> for CitationReference<'s> { } fn get_contents<'b>(&'b self) -> Option<&'s str> { - todo!() + None } fn get_post_blank(&self) -> PostBlank { - todo!() + 0 } }