pub use citum_schema::citation::{Citation, CitationItem, CitationMode, LocatorType};
pub use citum_schema::reference::{
Contributor, ContributorList, EdtfString, FlatName, InputReference as Reference,
MultilingualString, NumOrStr, SimpleName, StructuredName, Title,
};
pub type Bibliography = indexmap::IndexMap<String, Reference>;
#[cfg(test)]
#[allow(
clippy::unwrap_used,
clippy::expect_used,
clippy::panic,
clippy::indexing_slicing,
clippy::todo,
clippy::unimplemented,
clippy::unreachable,
clippy::get_unwrap,
reason = "Panicking is acceptable and often desired in tests."
)]
mod tests {
use super::*;
#[test]
fn test_parse_csl_json() {
let json = r#"{
"id": "kuhn1962",
"type": "book",
"author": [{"family": "Kuhn", "given": "Thomas S."}],
"title": "The Structure of Scientific Revolutions",
"issued": {"date-parts": [[1962]]},
"publisher": "University of Chicago Press",
"publisher-place": "Chicago"
}"#;
let legacy: csl_legacy::csl_json::Reference = serde_json::from_str(json).unwrap();
let reference: Reference = legacy.into();
assert_eq!(reference.id().unwrap(), "kuhn1962");
assert_eq!(reference.ref_type(), "book");
if let Some(Contributor::ContributorList(list)) = reference.author()
&& let Contributor::StructuredName(name) = &list.0[0]
{
assert_eq!(name.family, MultilingualString::Simple("Kuhn".to_string()));
}
}
}