Skip to content

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

fix: allow lowercase mp3 after an (#3369)

cfcryptotrader-rgbef2b49de37e0
diff --git a/harper-core/src/indefinite_article.rs b/harper-core/src/indefinite_article.rs
index dbf703869..969d85bd0 100644
--- a/harper-core/src/indefinite_article.rs
+++ b/harper-core/src/indefinite_article.rs
@@ -68,6 +68,12 @@ pub fn starts_with_vowel(word: &[char], dialect: Dialect) -> Option<InitialSound
return Some(InitialSound::Either);
}
+ // Treat formats like `mp3` the same as `MP3`: the leading `m` is read as
+ // the letter name “em”, so it takes `an` rather than `a`.
+ if matches!(word, ['m', 'p', digit, ..] if digit.is_ascii_digit()) {
+ return Some(InitialSound::Vowel);
+ }
+
if matches!(word, ['e', 'u', 'l', 'e', ..]) {
return Some(InitialSound::Vowel);
}
diff --git a/harper-core/src/linting/an_a.rs b/harper-core/src/linting/an_a.rs
index 365c62664..d82012ca0 100644
--- a/harper-core/src/linting/an_a.rs
+++ b/harper-core/src/linting/an_a.rs
@@ -236,11 +236,21 @@ mod tests {
assert_lint_count("an MP and an MP3?", AnA::new(Dialect::American), 0);
}
+ #[test]
+ fn allow_an_lowercase_mp3() {
+ assert_lint_count("an mp3 file", AnA::new(Dialect::American), 0);
+ }
+
#[test]
fn disallow_a_mp_and_a_mp3() {
assert_lint_count("a MP and a MP3?", AnA::new(Dialect::American), 2);
}
+ #[test]
+ fn disallow_a_lowercase_mp3() {
+ assert_lint_count("a mp3 file", AnA::new(Dialect::American), 1);
+ }
+
#[test]
fn recognize_acronyms() {
// a