diff --git a/src/csl/taxonomy.rs b/src/csl/taxonomy.rs index 29a1c98..ebaa8b3 100644 --- a/src/csl/taxonomy.rs +++ b/src/csl/taxonomy.rs @@ -679,21 +679,48 @@ impl EntryLike for Entry { } } +#[cfg(feature = "csl-json")] +fn resolve_csl_json_standard_variable( + item: &citationberg::json::Item, + variable: StandardVariable, +) -> Option> { + match item.0.get(&variable.to_string())? { + csl_json::Value::String(s) => { + Some(Cow::Owned(StringChunk::normal(s.clone()).into())) + } + csl_json::Value::Number(n) => { + Some(Cow::Owned(StringChunk::normal(n.to_string()).into())) + } + _ => None, + } +} + #[cfg(feature = "csl-json")] impl EntryLike for citationberg::json::Item { fn resolve_standard_variable( &self, - _: LongShortForm, + form: LongShortForm, variable: StandardVariable, ) -> Option> { - match self.0.get(&variable.to_string())? { - csl_json::Value::String(s) => { - Some(Cow::Owned(StringChunk::normal(s.clone()).into())) - } - csl_json::Value::Number(n) => { - Some(Cow::Owned(StringChunk::normal(n.to_string()).into())) - } - _ => None, + match variable { + StandardVariable::Title => match form { + LongShortForm::Short => { + // Per citeproc tests, a 'title-short' without 'title' is + // valid and should be used when the short form is + // selected. + resolve_csl_json_standard_variable(self, StandardVariable::TitleShort) + .or_else(|| { + resolve_csl_json_standard_variable( + self, + StandardVariable::Title, + ) + }) + } + LongShortForm::Long => { + resolve_csl_json_standard_variable(self, StandardVariable::Title) + } + }, + _ => resolve_csl_json_standard_variable(self, variable), } } diff --git a/src/types/strings.rs b/src/types/strings.rs index e33d140..c374fe9 100644 --- a/src/types/strings.rs +++ b/src/types/strings.rs @@ -251,12 +251,6 @@ impl Serialize for ChunkedString { } } -impl From for String { - fn from(value: ChunkedString) -> Self { - value.to_string() - } -} - impl ChunkedString { /// Creates a new empty `ChunkedString`. pub fn new() -> Self { diff --git a/tests/citeproc-pass.txt b/tests/citeproc-pass.txt index f132d31..0aad4bf 100644 --- a/tests/citeproc-pass.txt +++ b/tests/citeproc-pass.txt @@ -128,8 +128,11 @@ disambiguate_YearSuffixMacroSameYearExplicit disambiguate_YearSuffixMacroSameYearImplicit disambiguate_YearSuffixWithEtAlSubsequent flipflop_OrphanQuote +form_TitleShort +form_TitleShortNoLong form_TitleTestNoLongFalse fullstyles_APA +group_ShortOutputOnly group_SuppressValueWithEmptySubgroup integration_CitationSort integration_CitationSortTwice