Skip to content

Offline, privacy-first grammar checker. Fast, open-source, Rust-powered

fix: don't lowercase "This" (#2651)

Andrew Dunbarab51fac0908f
diff --git a/harper-core/src/linting/use_title_case.rs b/harper-core/src/linting/use_title_case.rs
index 064dd8cdd..335862d36 100644
--- a/harper-core/src/linting/use_title_case.rs
+++ b/harper-core/src/linting/use_title_case.rs
@@ -44,7 +44,7 @@ impl<D: Dictionary + 'static> Linter for UseTitleCase<D> {
#[cfg(test)]
mod tests {
- use crate::linting::tests::assert_suggestion_result;
+ use crate::linting::tests::{assert_no_lints, assert_suggestion_result};
use crate::spell::FstDictionary;
use super::UseTitleCase;
@@ -66,4 +66,21 @@ mod tests {
"# This Is a Title\n\n## This Is a Subtitle",
);
}
+
+ #[test]
+ fn doesnt_lowercase_this_in_github_template_title() {
+ assert_no_lints(
+ "# How Has This Been Tested?",
+ UseTitleCase::new(FstDictionary::curated()),
+ );
+ }
+
+ #[test]
+ fn shoud_uppercase_possessive_determiners() {
+ assert_suggestion_result(
+ "# my/our/your/his/her/its/their",
+ UseTitleCase::new(FstDictionary::curated()),
+ "# My/Our/Your/His/Her/Its/Their",
+ );
+ }
}
diff --git a/harper-core/src/title_case.rs b/harper-core/src/title_case.rs
index d5595de86..6845d422d 100644
--- a/harper-core/src/title_case.rs
+++ b/harper-core/src/title_case.rs
@@ -157,7 +157,6 @@ fn should_capitalize_token(tok: &Token, source: &[char]) -> bool {
}
!is_short_preposition
- && !metadata.is_non_possessive_determiner()
&& !SPECIAL_CONJUNCTIONS.contains(chars_lower.as_ref())
&& !SPECIAL_ARTICLES.contains(chars_lower.as_ref())
}
@@ -520,4 +519,16 @@ mod tests {
"Alice’s Adventures in Wonderland",
);
}
+
+ #[test]
+ fn doesnt_lowercase_this_in_github_template_title() {
+ assert_eq!(
+ make_title_case_str(
+ "# How Has This Been Tested?",
+ &PlainEnglish,
+ &FstDictionary::curated()
+ ),
+ "# How Has This Been Tested?",
+ );
+ }
}
diff --git a/harper-core/tests/text/linters/Alice's Adventures in Wonderland.snap.yml b/harper-core/tests/text/linters/Alice's Adventures in Wonderland.snap.yml
index 35dc1481a..2842caef9 100644
--- a/harper-core/tests/text/linters/Alice's Adventures in Wonderland.snap.yml
+++ b/harper-core/tests/text/linters/Alice's Adventures in Wonderland.snap.yml
@@ -985,15 +985,6 @@ Suggest:
-Lint: Capitalization (127 priority)
-Message: |
- 558 | ## CHAPTER IV: The Rabbit Sends in a Little Bill
- | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Try to use title case in headings.
-Suggest:
- - Replace with: “## CHAPTER IV: The Rabbit Sends in a little Bill”
-
-
-
Lint: Readability (127 priority)
Message: |
564 | wonder?” Alice guessed in a moment that it was looking for the fan and the pair