From f55d0b230454c3549619b6579e9ab394fdc1318e Mon Sep 17 00:00:00 2001 From: Laurenz Date: Tue, 5 Sep 2023 12:14:21 +0200 Subject: [PATCH] Fix title case again Co-Authored-By: Martin Haug --- src/interop.rs | 10 +++++++++- src/lang/mod.rs | 2 +- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/interop.rs b/src/interop.rs index a85d2c7d..c69ce0a6 100644 --- a/src/interop.rs +++ b/src/interop.rs @@ -97,7 +97,15 @@ fn format_title_case(chunks: &[Spanned]) -> String { let mut out = String::new(); for chunk in chunks { match &chunk.v { - Chunk::Normal(s) => out.push_str(&TitleCase::new().apply(s)), + Chunk::Normal(s) => out.push_str( + &TitleCase { + trim_end: false, + trim_start: false, + always_capitalize_last_word: false, + ..Default::default() + } + .apply(s), + ), Chunk::Verbatim(s) => out.push_str(s), Chunk::Math(s) => { out.push('$'); diff --git a/src/lang/mod.rs b/src/lang/mod.rs index 721fb11f..f794e39d 100644 --- a/src/lang/mod.rs +++ b/src/lang/mod.rs @@ -181,7 +181,7 @@ impl Case for TitleCase { let word = &title[index..index + len].to_lowercase(); if self.use_exception_dictionary - && en::NEVER_CAPITALIZE.binary_search(&word.as_str()).is_ok() + && en::NEVER_CAPITALIZE.binary_search(&word.trim_end()).is_ok() { res.extend(c.to_lowercase()); } else {