0.2.2 — a subtitle begins with a capital

title_case counted small words from the start of the whole string, so
every subtitle that opened with one was set in lower case: 'Aesthetic in
Kant: a Critique', 'Born Fighting: the Scots-Irish'. A colon starts a
title of its own and the first word of one is capitalised however small
it is.

Found by book-pipeline, which had been proposing a title page's capitals
verbatim into a catalogue and needed this to stop.
This commit is contained in:
funkpower committed 2026-09-21 11:30:26 -04:00
1 parent 60943420b4
commit 05b712d084
4 files changed
+104 -55

No files matched your search

+6 -1
View File
@@ -260,9 +260,14 @@ mod tests {
#[test]
fn an_underscored_title_is_cleaned_before_it_is_cased() {
let cleaned = clean(&book("THE FALL_ AND THE RISE_txt", "Arendt, Hannah"));
// "And" is capitalised because the colon starts a subtitle, and the
// first word of one is capitalised however small it is. This asserted
// "and" until the rule was found to be counting small words from the
// start of the whole string, which set every subtitle opening "A",
// "The" or "An" in lower case.
assert_eq!(
cleaned.book.title.as_deref(),
Some("The Fall: and the Rise")
Some("The Fall: And the Rise")
);
assert_eq!(cleaned.changes.len(), 2);
}