Skip to content

Commit

Permalink
Add abstract, annote, and genre fields (#102)
Browse files Browse the repository at this point in the history
  • Loading branch information
Drodt authored Dec 12, 2023
1 parent 3e92ac8 commit ee32910
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/csl/taxonomy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -209,8 +209,13 @@ impl EntryLike for Entry {
) -> Option<Cow<'_, ChunkedString>> {
let entry = self;
match variable {
StandardVariable::Abstract => None,
StandardVariable::Annote => None,
StandardVariable::Abstract => entry
.map(|e| e.abstract_())
.map(|f| f.select(form))
.map(Cow::Borrowed),
StandardVariable::Annote => {
entry.map(|e| e.annote()).map(|f| f.select(form)).map(Cow::Borrowed)
}
StandardVariable::Archive => {
entry.map(|e| e.archive()).map(|f| f.select(form)).map(Cow::Borrowed)
}
Expand Down Expand Up @@ -264,7 +269,9 @@ impl EntryLike for Entry {
.and_then(Entry::location)
.map(|f| f.select(form))
.map(Cow::Borrowed),
StandardVariable::Genre => None,
StandardVariable::Genre => {
entry.map(|e| e.genre()).map(|f| f.select(form)).map(Cow::Borrowed)
}
StandardVariable::ISBN => {
entry.isbn().map(|d| Cow::Owned(StringChunk::verbatim(d).into()))
}
Expand Down
8 changes: 8 additions & 0 deletions src/interop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -524,6 +524,14 @@ impl TryFrom<&tex::Entry> for Entry {
}
}

if let Some(abstract_) = map_res(entry.abstract_())? {
item.set_abstract_(abstract_.into())
}

if let Some(annote) = map_res(entry.annotation())? {
item.set_annote(annote.into())
}

if let Some(series) = map_res(entry.series())? {
let title: FormatString = series.into();
let mut new = Entry::new(&entry.key, item.entry_type);
Expand Down
12 changes: 12 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -545,6 +545,18 @@ entry! {
"call-number" => call_number: FormatString,
/// Additional description to be appended in the bibliographic entry.
"note" => note: FormatString,
/// Abstract of the item (e.g. the abstract of a journal article).
"abstract" => abstract_: FormatString,
/// Short markup, decoration, or annotation to the item (e.g., to indicate
/// items included in a review);
///
/// For descriptive text (e.g., in an annotated bibliography), use `note`
/// instead.
"annote" => annote: FormatString,
/// Type, class, or subtype of the item (e.g. “Doctoral dissertation” for
/// a PhD thesis; “NIH Publication” for an NIH technical report);
/// Do not use for topical descriptions or categories (e.g. “adventure” for an adventure movie).
"genre" => genre: FormatString,
}

impl Entry {
Expand Down

0 comments on commit ee32910

Please sign in to comment.