Skip to content

Commit 375ff32

Browse files
committed
fix: don't normalize multiple spaces
WIP
1 parent 3f71270 commit 375ff32

File tree

4 files changed

+6
-10
lines changed

4 files changed

+6
-10
lines changed

internal/check/substitution.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ func (s Substitution) Run(blk nlp.Block, _ *core.File, cfg *core.Config) ([]core
113113
return alerts, err
114114
}
115115

116-
observed := strings.TrimSpace(converted)
116+
observed := converted
117117
expected, msgErr := subMsg(s, (idx/2)-1, observed)
118118
if msgErr != nil {
119119
return alerts, msgErr

internal/core/util.go

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import (
1313
var defaultIgnoreDirectories = []string{
1414
"node_modules", ".git",
1515
}
16-
var spaces = regexp.MustCompile(" +")
1716
var reANSI = regexp.MustCompile("[\u001B\u009B][[\\]()#;?]*(?:(?:(?:[a-zA-Z\\d]*(?:;[a-zA-Z\\d]*)*)?\u0007)|(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PRZcf-ntqry=><~]))")
1817
var sanitizer = strings.NewReplacer(
1918
"&rsquo;", "'",
@@ -39,12 +38,9 @@ func StripANSI(s string) string {
3938
return reANSI.ReplaceAllString(s, "")
4039
}
4140

42-
// WhitespaceToSpace converts newlines and multiple spaces (e.g., " ") into a
43-
// single space.
41+
// WhitespaceToSpace converts newlines into a single space.
4442
func WhitespaceToSpace(msg string) string {
45-
msg = strings.ReplaceAll(msg, "\n", " ")
46-
msg = spaces.ReplaceAllString(msg, " ")
47-
return msg
43+
return strings.ReplaceAll(msg, "\n", " ")
4844
}
4945

5046
// ShouldIgnoreDirectory will check if directory should be ignored

testdata/features/checks.feature

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,11 +109,11 @@ Feature: Checks
109109
test.md:23:1:Bugs.TermCase:Use 'iOS' rather than IOS.
110110
test.md:25:1:Bugs.SameCase:Use 'MPL 2.0' instead of 'mpl 2.0'
111111
test.md:27:1:Bugs.SameCase:Use 'MPL 2.0' instead of 'MPL2.0'
112-
test.md:31:15:Bugs.EmptyReplace:Use instead of 'obvious'.
112+
test.md:31:15:Bugs.EmptyReplace:Use instead of 'obvious'.
113113
test2.md:3:1:demo.CapSub:Use 'Change to the `/etc` directory' instead of 'Change into the `/etc` directory'.
114114
test2.md:7:1:demo.CapSub:Use 'Change to the `/home/user` directory' instead of 'Change into the `/home/user` directory'.
115115
test2.md:9:1:demo.CapSub:Use 'Change to the `/etc/X11` directory' instead of 'Change into the `/etc/X11` directory'.
116-
test2.md:11:6:Bugs.WrongExp:Use 'versus' instead of 'vs'.
116+
test2.md:11:6:Bugs.WrongExp:Use 'versus' instead of 'vs '.
117117
"""
118118

119119
Scenario: Sequence

testdata/features/styles.feature

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ Feature: Styles
5656
test.mdx:1:3:demo.HeadingStartsWithCapital:'this is a heading' should be capitalized
5757
test.mdx:9:4:demo.ScopedHeading:'this is another heading!' should be in title case
5858
test.rst:1:22:demo.CommasPerSentence:More than 3 commas!
59-
test.rst:1:58:demo.Spacing:'. I' should have one space
59+
test.rst:1:58:demo.Spacing:'. I' should have one space
6060
test.rst:3:1:demo.SentenceLength:Sentences should be less than 25 words
6161
test.rst:5:28:demo.Ending-Preposition:Don't end a sentence with 'by.'
6262
test.rst:9:1:demo.ParagraphLength:Paragraphs should be less than 150 words

0 commit comments

Comments
 (0)