Offline, privacy-first grammar checker. Fast, open-source, Rust-powered
fix(core): title case should only care about first letter
Elijah Potterc2c89f1fc626
diff --git a/harper-core/src/title_case.rs b/harper-core/src/title_case.rsindex 584277179..e6dcca712 100644--- a/harper-core/src/title_case.rs+++ b/harper-core/src/title_case.rs@@ -46,7 +46,6 @@ pub fn make_title_case(toks: &[Token], source: &[char], dict: &impl Dictionary).iter_mut().enumerate().for_each(|(idx, c)| *c = correct_caps[idx]);- continue;}}};@@ -58,11 +57,6 @@ pub fn make_title_case(toks: &[Token], source: &[char], dict: &impl Dictionary)if should_capitalize {output[word.span.start - start_index] =output[word.span.start - start_index].to_ascii_uppercase();-- // The rest of the word should be lowercase.- for v in &mut output[word.span.start + 1 - start_index..word.span.end - start_index] {- *v = v.to_ascii_lowercase();- }} else {// The whole word should be lowercase.for i in word.span {@@ -135,14 +129,6 @@ mod tests {)}- #[test]- fn start_as_uppercase() {- assert_eq!(- make_title_case_str("THIS IS A TEST", &PlainEnglish, &FstDictionary::curated()),- "This Is a Test"- )- }-/// Check that "about" remains uppercase#[test]fn about_uppercase_with_numbers() {diff --git a/packages/harper.js/src/Linter.test.ts b/packages/harper.js/src/Linter.test.tsindex f8726ef5a..dde925752 100644--- a/packages/harper.js/src/Linter.test.ts+++ b/packages/harper.js/src/Linter.test.ts@@ -98,7 +98,7 @@ for (const [linterName, Linter] of Object.entries(linters)) {test(`${linterName} can make things title case`, async () => {const linter = new Linter();- const titleCase = await linter.toTitleCase('THIS IS A TEST FOR MAKING TITLES');+ const titleCase = await linter.toTitleCase('this is a test for making titles');expect(titleCase).toBe('This Is a Test for Making Titles');});