Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ archive = ["ciborium"]
csl-json = ["citationberg/json"]

[dependencies]
citationberg = "0.6.1"
citationberg = { git = "https://github.com/DerDrodt/Citationberg.git", branch = "comma-suffix" }
indexmap = { version = "2.0.2", features = ["serde"] }
roman-numerals-rs = "3.1.0"
paste = "1.0.14"
Expand All @@ -28,9 +28,7 @@ unic-langid = { version = "0.9.6", features = ["serde"] }
unicode-segmentation = "1.6.0"
unscanny = "0.1.0"
url = { version = "2.4", features = ["serde"] }
biblatex = { version = "0.11.0", features = [
"unic-langid",
], optional = true }
biblatex = { version = "0.11.0", features = ["unic-langid"], optional = true }
ciborium = { version = "0.2.1", optional = true }
clap = { version = "4", optional = true, features = ["cargo"] }
strum = { version = "0.26", features = ["derive"], optional = true }
Expand Down
4 changes: 4 additions & 0 deletions src/csl/rendering/names.rs
Original file line number Diff line number Diff line change
Expand Up @@ -648,6 +648,7 @@ fn write_name<T: EntryLike>(
family_part.map(|p| &p.affixes).and_then(|f| f.prefix.as_ref()),
family_part.map(|p| &p.affixes).and_then(|f| f.suffix.as_ref()),
];
let comma_suffix = name.comma_suffix;

let first_name = |ctx: &mut Context<T>| {
if let Some(first) = &name.given_name {
Expand Down Expand Up @@ -858,6 +859,9 @@ fn write_name<T: EntryLike>(
ctx.pop_format(idx);

if let Some(suffix) = &name.suffix {
if comma_suffix {
ctx.push_str(sort_sep);
}
ctx.ensure_space();
ctx.push_str(suffix);
}
Expand Down
7 changes: 7 additions & 0 deletions src/csl/taxonomy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -782,13 +782,15 @@ impl EntryLike for citationberg::json::Item {
suffix: None,
given_name: None,
alias: None,
comma_suffix: false,
},
csl_json::NameValue::Item(csl_json::NameItem {
family,
given,
non_dropping_particle: None,
dropping_particle: None,
suffix,
comma_suffix,
}) => {
let mut parts = vec![family.as_str()];
if let Some(given) = given {
Expand All @@ -798,6 +800,9 @@ impl EntryLike for citationberg::json::Item {
if let Some(suffix) = suffix {
p.suffix = Some(suffix.as_str().to_owned());
}
if comma_suffix.unwrap_or_default() {
p.comma_suffix = true;
}

p
}
Expand All @@ -807,6 +812,7 @@ impl EntryLike for citationberg::json::Item {
non_dropping_particle,
dropping_particle,
suffix,
comma_suffix,
}) => Person {
name: if let Some(non_drop) = non_dropping_particle {
format!("{non_drop} {family}")
Expand All @@ -817,6 +823,7 @@ impl EntryLike for citationberg::json::Item {
suffix: suffix.clone(),
given_name: given.clone(),
alias: None,
comma_suffix: comma_suffix.unwrap_or_default(),
},
}))
})
Expand Down
1 change: 1 addition & 0 deletions src/interop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ impl From<&tex::Person> for Person {
given_name: optional(&person.given_name),
prefix: optional(&person.prefix),
suffix: optional(&person.suffix),
comma_suffix: false,
alias: None,
}
}
Expand Down
12 changes: 11 additions & 1 deletion src/types/persons.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,9 @@ derive_or_from_str! {
pub prefix: Option<String>,
/// A suffix of the family name such as 'Jr.' or 'IV'.
pub suffix: Option<String>,
/// Whether a comma should be inserted before the suffix.
#[serde(default)]
pub comma_suffix: bool,
/// Another name (often user name) the person might be known under.
pub alias: Option<String>,
}
Expand Down Expand Up @@ -228,7 +231,14 @@ impl Person {
name = name.trim_start().to_string();
}

Ok(Person { name, given_name, prefix, suffix, alias: None })
Ok(Person {
name,
given_name,
prefix,
suffix,
comma_suffix: false,
alias: None,
})
}

/// Formats the given name into initials.
Expand Down
1 change: 1 addition & 0 deletions tests/citeproc-pass.txt
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,7 @@ name_ArticularNameAsSortOrder
name_ArticularPlain
name_ArticularShortForm
name_ArticularShortFormCommaSuffix
name_ArticularWithComma
name_ArticularWithCommaNameAsSortOrder
name_AsianGlyphs
name_AuthorCount
Expand Down