Skip to content

Commit

Permalink
Fix not using short titles (#174)
Browse files Browse the repository at this point in the history
Co-authored-by: PJTSearch <pjtsignups@gmail.com>
  • Loading branch information
pjtsearch and PJTSearch authored Oct 1, 2024
1 parent 8f3e183 commit 05f9593
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 6 deletions.
8 changes: 4 additions & 4 deletions src/csl/taxonomy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -347,13 +347,13 @@ impl EntryLike for Entry {
.map(|f| f.select(form))
.map(Cow::Borrowed),
StandardVariable::Status => None,
StandardVariable::Title => entry
StandardVariable::Title => {
entry.title().map(|f| f.select(form)).map(Cow::Borrowed)
}
StandardVariable::TitleShort => entry
.title()
.map(|f| f.select(LongShortForm::Short))
.map(Cow::Borrowed),
StandardVariable::TitleShort => {
entry.title().map(|f| f.select(form)).map(Cow::Borrowed)
}
StandardVariable::URL => entry
.map(|e| e.url())
.map(|d| Cow::Owned(StringChunk::verbatim(d.to_string()).into())),
Expand Down
10 changes: 8 additions & 2 deletions src/interop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -279,8 +279,14 @@ impl TryFrom<&tex::Entry> for Entry {
item.add_affiliated_persons((a, PersonRole::Introduction));
}

if let Some(title) = map_res(entry.title())?.map(Into::into) {
item.set_title(title);
if let Some(title) = map_res(entry.title())?.map(Into::<ChunkedString>::into) {
if let Some(short_title) =
map_res(entry.short_title())?.map(Into::<ChunkedString>::into)
{
item.set_title(FormatString::with_short(title, short_title));
} else {
item.set_title(FormatString::with_value(title));
}
}

// NOTE: Ignoring subtitle and titleaddon for now
Expand Down
6 changes: 6 additions & 0 deletions src/types/strings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,12 @@ impl Serialize for ChunkedString {
}
}

impl Into<String> for ChunkedString {
fn into(self) -> String {
return self.to_string();
}
}

impl ChunkedString {
/// Creates a new empty `ChunkedString`.
pub fn new() -> Self {
Expand Down

0 comments on commit 05f9593

Please sign in to comment.