bibclean: a name in capitals is allcaps_author, not author_list_commas

as_byline fell back to author_list_commas whenever no other fault was found,
so "STEVEN BOX" was reported as a list joined with commas. A heading with
letters and no lowercase is now allcaps_author (weight 2); the repair is the
same byline.
This commit is contained in:
funkpower committed 2026-11-24 12:00:02 -05:00
1 parent f50971a29c
commit 470e9a9e38
3 files changed
+22 -1

No files matched your search

+19
View File
@@ -169,6 +169,13 @@ pub fn as_byline(author: &str) -> Option<(String, Vec<&'static str>)> {
{
return None;
}
// Shouting, put in the case a title page prints names in: "STEVEN BOX".
if faults.is_empty()
&& original.chars().any(char::is_alphabetic)
&& !original.chars().any(char::is_lowercase)
{
faults.push("allcaps_author");
}
// Only the separator changed: "Patrick Laude, Barry McDonald".
if faults.is_empty() {
faults.push("author_list_commas");
@@ -302,6 +309,18 @@ mod tests {
as_byline(author).map(|(name, _)| name)
}
#[test]
fn a_name_in_capitals_is_named_as_shouting() {
assert_eq!(
as_byline("STEVEN BOX"),
Some(("Steven Box".to_string(), vec!["allcaps_author"]))
);
assert_eq!(
as_byline("Patrick Laude, Barry McDonald").map(|(_, faults)| faults),
Some(vec!["author_list_commas"])
);
}
#[test]
fn a_heading_is_turned_round() {
for (heading, want) in [
+1
View File
@@ -153,6 +153,7 @@ const PERSON_SUFFIXES: &[&str] = &["ed", "eds", "ii", "iii", "iv", "jr", "md", "
/// What each fault is worth when the worst records are wanted first.
const WEIGHTS: &[(&str, u32)] = &[
("account_author", 3),
("allcaps_author", 2),
("allcaps_title", 2),
("author_is_title", 4),
("author_last_first", 1),