Offline, privacy-first grammar checker. Fast, open-source, Rust-powered
feat: add correction of degrees kelvin to -> kelvin (#1829)
Lukas Werner80d873ce16f8
diff --git a/harper-core/src/linting/phrase_corrections/mod.rs b/harper-core/src/linting/phrase_corrections/mod.rsindex 65ebc222f..d7119ef24 100644--- a/harper-core/src/linting/phrase_corrections/mod.rs+++ b/harper-core/src/linting/phrase_corrections/mod.rs@@ -300,6 +300,20 @@ pub fn lint_group() -> LintGroup {"Corrects the eggcorn `day in age` to `day and age`, which properly means the current era or time period.",LintKind::Eggcorn),+ "DegreesKelvin" => (+ ["degrees kelvin", "degrees Kelvin", "degree kelvin", "degree Kelvin"],+ ["kelvins", "kelvin"],+ "Use `kelvins` when discussing the unit Kelvin.",+ "Corrects use of `degrees kelvin` to `kelvins`.",+ LintKind::Usage+ ),+ "DegreesKelvinSymbol" => (+ ["°K"],+ ["K"],+ "Use just the symbol `K` when discussing the unit Kelvin.",+ "Corrects use of `°K` to `K`.",+ LintKind::Usage+ ),"DoNotWant" => (["don't wan", "do not wan"],["don't want", "do not want"],diff --git a/harper-core/src/linting/phrase_corrections/tests.rs b/harper-core/src/linting/phrase_corrections/tests.rsindex 8ab377ec2..c7e5c44b3 100644--- a/harper-core/src/linting/phrase_corrections/tests.rs+++ b/harper-core/src/linting/phrase_corrections/tests.rs@@ -327,6 +327,12 @@ fn corrects_mixed_case() {);}+#[test]+fn corrects_degrees_kelvin() {+ assert_suggestion_result("degrees kelvin", lint_group(), "kelvins");+ assert_suggestion_result("°K", lint_group(), "K");+}+#[test]fn does_not_flag_already_correct() {assert_lint_count("I don't want to leave.", lint_group(), 0);diff --git a/harper-core/src/punctuation.rs b/harper-core/src/punctuation.rsindex f9b73f543..63d5e59c4 100644--- a/harper-core/src/punctuation.rs+++ b/harper-core/src/punctuation.rs@@ -8,6 +8,8 @@ use crate::Currency;)]#[serde(tag = "kind")]pub enum Punctuation {+ /// `°`+ Degree,/// `…`Ellipsis,/// `–`@@ -83,6 +85,7 @@ impl Punctuation {let punct = match c {'@' => Punctuation::At,'~' => Punctuation::Tilde,+ '°' => Punctuation::Degree,'=' => Punctuation::Equal,'<' => Punctuation::LessThan,'>' => Punctuation::GreaterThan,