mirror of
https://git.pumpin.online/funkpower/catena.git
synced 2026-11-24 19:32:56 +00:00
Merge pull request 'colophon: a byline line opening on an article names nobody' (#22) from colophon-title-words into main
This commit is contained in:
commit
1670753b2d
1 file changed
+13
@@ -320,6 +320,12 @@ fn people(who: &str) -> Vec<String> {
|
||||
.flat_map(|part| part.split(" and "))
|
||||
.map(|name| name.trim().trim_end_matches(['.', ',']).trim().to_string())
|
||||
.filter(|name| name.len() >= 3 && name.split_whitespace().count() <= 5)
|
||||
// "A Novel", "A History": an article opens a line of the title, and
|
||||
// would otherwise be read as the initial A.
|
||||
.filter(|name| {
|
||||
let first = name.split_whitespace().next().unwrap_or("");
|
||||
!["a", "an", "the"].contains(&first.to_lowercase().as_str())
|
||||
})
|
||||
.filter_map(|name| bibclean::author::clean(&name))
|
||||
.filter(|name| crate::cip::reads_as_a_name(name))
|
||||
.filter(|name| name.split_whitespace().count() >= 2 || is_known_mononym(name))
|
||||
@@ -669,6 +675,13 @@ mod person_tests {
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_line_opening_on_an_article_names_nobody() {
|
||||
assert!(people("A Novel").is_empty());
|
||||
assert!(people("A Psychoanalytic View").is_empty());
|
||||
assert_eq!(people("A. J. Ayer"), ["A. J. Ayer"]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn initials_are_still_a_person() {
|
||||
for line in ["A. J. Ayer", "A.J. Ayer", "Anne Carson"] {
|
||||
|
||||
Reference in new issue
Block a user