Skip to content

Commit

Permalink
Fix title case again
Browse files Browse the repository at this point in the history
Co-Authored-By: Martin Haug <mhaug@live.de>
  • Loading branch information
laurmaedje and reknih committed Sep 5, 2023
1 parent 53035f1 commit f55d0b2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
10 changes: 9 additions & 1 deletion src/interop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,15 @@ fn format_title_case(chunks: &[Spanned<Chunk>]) -> 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('$');
Expand Down
2 changes: 1 addition & 1 deletion src/lang/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit f55d0b2

Please sign in to comment.