Skip to content

Commit 296fd8c

Browse files
committed
Make Colons exemptable through a project Vocab
Amends the previous commit, which claimed the proper-noun exemption couldn't be expressed. It can — Vale applies Vocab accept.txt entries as exceptions to any check, not only Vale.Spelling and Vale.Terms. Two things stopped it working here: - the token matched ': C', so the matched text was never the proper noun and there was nothing for the vocabulary to compare against - `nonword: true` opts out of vocabulary matching altogether Matching the word itself via a lookbehind, and dropping `nonword`, makes `accept.txt` work exactly as reported in issue #20: with Kubernetes in a project vocabulary, "You need one thing: Kubernetes." is now silent while "... : Terraform." still flags. The notice-label exemptions move into the lookbehind so they still apply now that the match starts at the word. Alerts also read better: "'Concise' should be in lowercase" rather than "': C'".
1 parent a343f3e commit 296fd8c

2 files changed

Lines changed: 9 additions & 8 deletions

File tree

Google/Colons.yml

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
extends: existence
22
message: "'%s' should be in lowercase."
33
link: 'https://developers.google.com/style/colons'
4-
nonword: true
54
level: warning
65
scope: sentence
7-
# The guide exempts text after a notice label ('Caution: Deleting this is
8-
# permanent.'), so the four label types are excluded here. It also exempts
9-
# proper nouns and quotes, which this check can't detect — `existence` has no
10-
# exceptions field. See issue #20.
6+
# The match is the word itself, not ': X', and `nonword` is off. Both are
7+
# required for a project Vocab to work: Vale compares accept.txt entries
8+
# against the matched text, and `nonword: true` opts out of that entirely.
9+
# So a proper noun after a colon can be exempted by adding it to accept.txt.
10+
# The guide's other exemption, notice labels, is handled by the lookbehinds;
11+
# headings are already excluded by `scope: sentence`. See issue #20.
1112
tokens:
12-
- '(?<!:[^ ]+?)(?<!Note)(?<!Caution)(?<!Warning)(?<!Success):\s[A-Z]'
13+
- '(?<!Note: )(?<!Caution: )(?<!Warning: )(?<!Success: )(?<=:\s)[A-Z]\w+'

testdata/Punctuation.ct

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ $ vale --output=line --sort --normalize --relative --no-global --no-exit .
33
test.md:3:5:Google.Periods:Don't use periods with acronyms or initialisms such as 'N.B.A.'.
44
test.md:5:18:Google.OptionalPlurals:Don't use plurals in parentheses such as in 'key(s)'.
55
test.md:5:21:Google.Parens:Use parentheses judiciously.
6-
test.md:7:5:Google.Colons:': C' should be in lowercase.
6+
test.md:7:7:Google.Colons:'Concise' should be in lowercase.
77
test.md:9:40:Google.OxfordComma:Use the Oxford comma in ', Rand and God.'.
88
test.md:11:46:Google.EmDash:Don't put a space before or after a dash.
99
test.md:13:24:Google.EmDash:Don't put a space before or after a dash.
@@ -23,4 +23,4 @@ test.md:41:17:Google.OxfordComma:Use the Oxford comma in ', green and orange.'.
2323
test.md:45:31:Google.OxfordComma:Use the Oxford comma in ', an external drive or OneDrive.'.
2424
test.md:51:6:Google.Parens:Use parentheses judiciously.
2525
test.md:51:21:Google.Parens:Use parentheses judiciously.
26-
test.md:57:18:Google.Colons:': A' should be in lowercase.
26+
test.md:57:20:Google.Colons:'Apples' should be in lowercase.

0 commit comments

Comments
 (0)