Skip to content

Commit f40b36a

Browse files
committed
Added rule for Lists
1 parent f6406f8 commit f40b36a

File tree

4 files changed

+37
-0
lines changed

4 files changed

+37
-0
lines changed

.vale/fixtures/RedHat/Lists/.vale.ini

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
; Vale configuration file to test the `Lists` rule
2+
StylesPath = ../../../styles
3+
MinAlertLevel = suggestion
4+
[*.adoc]
5+
RedHat.Lists = YES
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Remove the cover:
2+
3+
- Loosen the captive screws on the side of the cover.
4+
- Slide the cover toward the back of the computer until the cover clicks
5+
- Lift the cover straight up
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Remove the cover:
2+
3+
* Loosen the captive screws on the side of the cover.
4+
* Slide the cover toward the back of the computer until the cover clicks.
5+
* Lift the cover straight up.

.vale/styles/RedHat/Lists.yml

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
---
2+
extends: script
3+
message: "Write lists so that all or none of the items start with complete sentences. If list items comprise only complete sentences, include a period after each sentence. Except in definition lists, do not include any end punctuation if list items comprise only sentence fragments."
4+
scope: raw
5+
script: |
6+
text := import("text")
7+
matches := []
8+
pattern := "[.*-]\\s+(.*)"
9+
is_complete_sentence := func(s string) bool {
10+
return text.has_prefix(s, text.to_upper(text.slice(s, 0, 1))) && text.has_suffix(s, ".")
11+
}
12+
for line in text.split(document, "\n") {
13+
match := text.re_find(pattern, line)
14+
if match != undefined {
15+
item := match[1]
16+
if is_complete_sentence(item) {
17+
} else {
18+
start := text.index(scope, line)
19+
matches = append(matches, {begin: start, end: start + len(line)})
20+
}
21+
}
22+
}

0 commit comments

Comments
 (0)