Implement the new fields for citation.
Some checks failed
clippy Build clippy has failed
rust-foreign-document-test Build rust-foreign-document-test has failed
rust-build Build rust-build has succeeded
rust-test Build rust-test has failed

This commit is contained in:
Tom Alexander 2023-12-11 14:38:14 -05:00
parent aba29df34c
commit f141a4e186
Signed by: talexander
GPG Key ID: D3A179C9A53C0EDE
2 changed files with 19 additions and 5 deletions

View File

@ -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),
},
))
}

View File

@ -224,6 +224,8 @@ pub struct Citation<'s> {
pub prefix: Vec<Object<'s>>,
pub suffix: Vec<Object<'s>>,
pub children: Vec<CitationReference<'s>>,
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
}
}