Skip to content

Commit

Permalink
fix: ensure hypenated exceptions are respected
Browse files Browse the repository at this point in the history
  • Loading branch information
jdkato committed Jul 24, 2023
1 parent e42027e commit d95f702
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 1 deletion.
3 changes: 2 additions & 1 deletion internal/check/variables.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ func sentence(s string, indicators []string, except *regexp2.Regexp, threshold f
if i-1 >= 0 {
prev = tokens[i-1]
}
t := w

if strings.Contains(w, "-") {
// NOTE: This is necessary for words like `Top-level`.
Expand All @@ -100,7 +101,7 @@ func sentence(s string, indicators []string, except *regexp2.Regexp, threshold f
w = strings.Split(w, "’")[0]
}

if w == strings.ToUpper(w) || hasAnySuffix(prev, indicators) || isMatch(except, w) {
if w == strings.ToUpper(w) || hasAnySuffix(prev, indicators) || isMatch(except, t) {
count++
} else if i == 0 && w != strings.Title(strings.ToLower(w)) {
return false
Expand Down
3 changes: 3 additions & 0 deletions testdata/fixtures/checks/Capitalization/.vale.ini
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,6 @@ demo.Cap = YES

[test2.md]
demo.CustomCap = YES

[test3.md]
demo.SentenceCaseAny = YES
7 changes: 7 additions & 0 deletions testdata/fixtures/checks/Capitalization/test3.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Test

Try the High-Def Render Pipeline.

Try the H-Def Render Pipeline.

Try the High Definition Render Pipeline.
1 change: 1 addition & 0 deletions testdata/fixtures/comments/_vale
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ vale.Spelling = NO
demo.CheckLinks = NO
demo.Spellcheck = NO
demo.ZeroOccurrence = NO
demo.SentenceCaseAny = NO
1 change: 1 addition & 0 deletions testdata/fixtures/styles/demo/_vale
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ demo.Cap = NO
demo.ZeroOccurrence = NO
demo.CustomCap = NO
demo.MinCount = NO
demo.SentenceCaseAny = NO

Limit.Rule = YES

Expand Down
3 changes: 3 additions & 0 deletions testdata/styles/Vocab/Cap/accept.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
congressman
hubba
very
High-Def Render Pipeline
H-Def Render Pipeline
High Definition Render Pipeline
6 changes: 6 additions & 0 deletions testdata/styles/demo/SentenceCaseAny.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
extends: capitalization
message: "'%s' should be sentence-cased"
level: warning
match: $sentence
indicators:
- ":"

0 comments on commit d95f702

Please sign in to comment.