Offline, privacy-first grammar checker. Fast, open-source, Rust-powered
fix(core): address edge cases in `title_case` module (#2284)
Elijah Potter611475176d63
diff --git a/harper-core/dictionary.dict b/harper-core/dictionary.dictindex d0d7ab8ec..d740f1eef 100644--- a/harper-core/dictionary.dict+++ b/harper-core/dictionary.dict@@ -7820,6 +7820,7 @@ PRC/ONg # mainland ChinaPRO/NPS/ONgJ # postscript; multiple meanings as implied by the attributes?P.S. # postscript+U.S./Og # United StatesPST/ONgPSU/Sg # power supply unitPT/NOJ@@ -54136,3 +54137,4 @@ topicalization/Nmgtypological/JQvolitive/NSgJworldbuild/Vd>G+WordCamp/gOdiff --git a/harper-core/src/title_case.rs b/harper-core/src/title_case.rsindex 453825abc..264ca2ed7 100644--- a/harper-core/src/title_case.rs+++ b/harper-core/src/title_case.rs@@ -243,4 +243,28 @@ mod tests {"United States")}++ #[test]+ fn keeps_decimal() {+ assert_eq!(+ make_title_case_str(+ "harper turns 1.0 today",+ &PlainEnglish,+ &FstDictionary::curated()+ ),+ "Harper Turns 1.0 Today"+ )+ }++ #[test]+ fn fixes_odd_capitalized_proper_nouns() {+ assert_eq!(+ make_title_case_str(+ "i spoke at wordcamp u.s. in 2025",+ &PlainEnglish,+ &FstDictionary::curated()+ ),+ "I Spoke at WordCamp U.S. in 2025",+ );+ }}diff --git a/harper-core/tests/text/linters/Computer science.snap.yml b/harper-core/tests/text/linters/Computer science.snap.ymlindex b20ba6cc1..9e5c6d2de 100644--- a/harper-core/tests/text/linters/Computer science.snap.yml+++ b/harper-core/tests/text/linters/Computer science.snap.yml@@ -491,17 +491,6 @@ Message: |-Lint: Spelling (63 priority)-Message: |- 137 | "In the U.S., however, informatics is linked with applied computing, or- | ^~~~ Did you mean to spell `U.S.` this way?-Suggest:- - Replace with: “P.S.”- - Replace with: “UBS”- - Replace with: “USA”---Lint: Spelling (63 priority)Message: |140 | A folkloric quotation, often attributed to—but almost certainly not firstdiff --git a/harper-core/tests/text/tagged/Computer science.md b/harper-core/tests/text/tagged/Computer science.mdindex 1b88867c3..7d570c31f 100644--- a/harper-core/tests/text/tagged/Computer science.md+++ b/harper-core/tests/text/tagged/Computer science.md@@ -269,7 +269,7 @@> adopted in the UK ( as in the School of Informatics , University of Edinburgh ) .# VP/J NPr/J/R/P D+ NPr+ . NSg/R NPr/J/R/P D N🅪Sg/VB P Nᴹ . NSg P NPr+ . .> " In the U.S. , however , informatics is linked with applied computing , or-# . NPr/J/R/P D+ ? . C . Nᴹ VL3 VP/J P VP/J Nᴹ/Vg/J+ . NPr/C+# . NPr/J/R/P D+ NPr+ . C . Nᴹ VL3 VP/J P VP/J Nᴹ/Vg/J+ . NPr/C> computing in the context of another domain . "# Nᴹ/Vg/J+ NPr/J/R/P D N🅪Sg/VB P I/D NSg+ . .>