Skip to content

Commit 604b1fc

Browse files
Merge pull request #1128 from klgill/vale-test-run
committing vale files
2 parents b0f4ebc + 659e8b8 commit 604b1fc

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+2488
-4
lines changed

.vale.ini

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
StylesPath = .vale/styles
2+
MinAlertLevel = warning
3+
Packages = https://github.com/jhradilek/asciidoctor-dita-vale/releases/latest/download/AsciiDocDITA.zip
4+
5+
[*.adoc]
6+
BasedOnStyles = AsciiDocDITA
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
# Report that admonition titles are not supported.
2+
---
3+
extends: script
4+
message: "Admonition titles are not supported in DITA."
5+
level: warning
6+
link: https://github.com/jhradilek/asciidoctor-dita-vale/blob/main/README.md#warnings
7+
scope: raw
8+
script: |
9+
text := import("text")
10+
matches := []
11+
12+
r_comment_line := text.re_compile("^(//|//[^/].*)$")
13+
r_comment_block := text.re_compile("^/{4,}\\s*$")
14+
r_block_title := text.re_compile("^\\.{1,2}[^ \\t.].*$")
15+
r_admonition_para := text.re_compile("^(?:NOTE|TIP|IMPORTANT|WARNING|CAUTION):[ \\t]")
16+
r_admonition_block := text.re_compile("^\\[(?:NOTE|TIP|IMPORTANT|WARNING|CAUTION)\\][ \\t]*$")
17+
r_empty_line := text.re_compile("^[ \\t]*$")
18+
19+
document := text.split(text.trim_suffix(scope, "\n"), "\n")
20+
21+
in_comment_block := false
22+
expect_title := false
23+
expect_admonition := false
24+
start := 0
25+
end := 0
26+
27+
for line in document {
28+
start += end
29+
end = len(line) + 1
30+
31+
if r_comment_block.match(line) {
32+
delimiter := text.trim_space(line)
33+
if ! in_comment_block {
34+
in_comment_block = delimiter
35+
} else if in_comment_block == delimiter {
36+
in_comment_block = false
37+
}
38+
continue
39+
}
40+
if in_comment_block { continue }
41+
if r_comment_line.match(line) { continue }
42+
if r_empty_line.match(line) { continue }
43+
44+
if r_block_title.match(line) {
45+
if expect_title {
46+
matches = append(matches, {begin: start, end: start + end - 1})
47+
expect_title = false
48+
expect_admonition = false
49+
} else {
50+
expect_admonition = {begin: start, end: start + end - 1}
51+
}
52+
} else if r_admonition_block.match(line) {
53+
if expect_admonition {
54+
matches = append(matches, expect_admonition)
55+
expect_admonition = false
56+
expect_title = false
57+
} else {
58+
expect_title = true
59+
}
60+
} else if r_admonition_para.match(line) {
61+
if expect_admonition {
62+
matches = append(matches, expect_admonition)
63+
expect_admonition = false
64+
}
65+
expect_title = false
66+
} else {
67+
expect_title = false
68+
expect_admonition = false
69+
}
70+
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# Report custom attribute references.
2+
---
3+
extends: existence
4+
message: "%s"
5+
level: suggestion
6+
link: https://github.com/jhradilek/asciidoctor-dita-vale/blob/main/README.md#suggestions
7+
scope: raw
8+
nonword: true
9+
tokens:
10+
- '(?<!\$)\{([0-9A-Za-z_][0-9A-Za-z_-]*|set:.+?|counter2?:.+?)\}'
11+
exceptions:
12+
- blank
13+
- empty
14+
- sp
15+
- nbsp
16+
- zwsp
17+
- wj
18+
- apos
19+
- quot
20+
- lsquo
21+
- rsquo
22+
- ldquo
23+
- rdquo
24+
- deg
25+
- plus
26+
- brvbar
27+
- vbar
28+
- amp
29+
- lt
30+
- gt
31+
- startsb
32+
- endsb
33+
- caret
34+
- asterisk
35+
- tilde
36+
- backslash
37+
- backtick
38+
- two-colons
39+
- two-semicolons
40+
- cpp
41+
- pp
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# Report accidental author lines.
2+
---
3+
extends: script
4+
message: "Author lines are not supported for topics."
5+
level: warning
6+
link: https://github.com/jhradilek/asciidoctor-dita-vale/blob/main/README.md#warnings
7+
scope: raw
8+
script: |
9+
text := import("text")
10+
matches := []
11+
12+
r_comment_line := text.re_compile("^(//|//[^/].*)$")
13+
r_comment_block := text.re_compile("^/{4,}\\s*$")
14+
r_document_title := text.re_compile("^=[ \\t]+\\S.*$")
15+
r_attribute := text.re_compile("^:!?\\S[^:]*:")
16+
17+
document := text.split(text.trim_suffix(scope, "\n"), "\n")
18+
19+
in_comment_block := false
20+
need_empty_line := false
21+
start := 0
22+
end := 0
23+
24+
for line in document {
25+
start += end
26+
end = len(line) + 1
27+
28+
if r_comment_block.match(line) {
29+
delimiter := text.trim_space(line)
30+
if ! in_comment_block {
31+
in_comment_block = delimiter
32+
} else if in_comment_block == delimiter {
33+
in_comment_block = false
34+
}
35+
continue
36+
}
37+
if in_comment_block { continue }
38+
if r_comment_line.match(line) { continue }
39+
40+
if r_document_title.match(line) {
41+
if need_empty_line {
42+
matches = append(matches, {begin: start, end: start + end - 1})
43+
break
44+
}
45+
need_empty_line = true
46+
} else if need_empty_line {
47+
if r_attribute.match(line) {
48+
continue
49+
} else if text.trim_space(line) != "" {
50+
matches = append(matches, {begin: start, end: start + end - 1})
51+
}
52+
break
53+
}
54+
}
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
# Report unsupported block titles.
2+
---
3+
extends: script
4+
message: "Block titles can only be assigned to examples, figures, and tables in DITA."
5+
level: warning
6+
link: https://github.com/jhradilek/asciidoctor-dita-vale/blob/main/README.md#warnings
7+
scope: raw
8+
script: |
9+
text := import("text")
10+
matches := []
11+
12+
r_add_resources := text.re_compile("^\\.{1,2}Additional resources[ \\t]*$")
13+
r_attribute_list := text.re_compile("^\\[(?:|[\\w.#%{,\"'].*)\\][ \\t]*$")
14+
r_attribute := text.re_compile("^:!?\\S[^:]*:")
15+
r_block_title := text.re_compile("^\\.{1,2}[^ \\t.].*$")
16+
r_code_block := text.re_compile("^(?:\\.{4,}|-{4,})[ \\t]*$")
17+
r_comment_block := text.re_compile("^/{4,}\\s*$")
18+
r_comment_line := text.re_compile("^(//|//[^/].*)$")
19+
r_conditional := text.re_compile("^(?:ifn?def|ifeval|endif)::\\S*\\[.*\\][ \\t]*$")
20+
r_content_type := text.re_compile("^:_(?:mod-docs-content|content|module)-type:[ \\t]+(?i:procedure)")
21+
r_empty_line := text.re_compile("^[ \\t]*$")
22+
r_example_block := text.re_compile("^\\[example\\][ \\t]*$")
23+
r_example_delim := text.re_compile("^={4,}[ \\t]*$")
24+
r_image := text.re_compile("^image::(?:\\S|\\S.*\\S)\\[.*\\][ \\t]*$")
25+
r_supported_title := text.re_compile("^\\.{1,2}(?:Prerequisites?|Procedure|Verification|Results?|Troubleshooting|Troubleshooting steps?|Next steps?)[ \\t]*$")
26+
r_table_cell := text.re_compile("^\\.[^ \\t|]+\\|")
27+
r_table := text.re_compile("^\\|={3,}[ \\t]*$")
28+
29+
document := text.split(text.trim_suffix(scope, "\n"), "\n")
30+
31+
in_code_block := false
32+
in_comment_block := false
33+
is_procedure := false
34+
expect_block := false
35+
start := 0
36+
end := 0
37+
38+
for line in document {
39+
start += end
40+
end = len(line) + 1
41+
42+
if r_comment_block.match(line) {
43+
delimiter := text.trim_space(line)
44+
if ! in_comment_block {
45+
in_comment_block = delimiter
46+
} else if in_comment_block == delimiter {
47+
in_comment_block = false
48+
}
49+
continue
50+
}
51+
if in_comment_block { continue }
52+
if r_comment_line.match(line) { continue }
53+
54+
if r_code_block.match(line) {
55+
delimiter := text.trim_space(line)
56+
if ! in_code_block {
57+
in_code_block = delimiter
58+
} else if in_code_block == delimiter {
59+
in_code_block = false
60+
}
61+
continue
62+
}
63+
if in_code_block { continue }
64+
65+
if r_content_type.match(line) {
66+
is_procedure = true
67+
continue
68+
}
69+
70+
if r_attribute_list.match(line) && ! r_example_block.match(line) { continue }
71+
if r_attribute.match(line) { continue }
72+
if r_conditional.match(line) { continue }
73+
if r_empty_line.match(line) { continue }
74+
75+
if r_block_title.match(line) {
76+
if is_procedure && r_supported_title.match(line) { continue }
77+
if r_add_resources.match(line) { continue }
78+
if r_table_cell.match(line) { continue }
79+
80+
expect_block = {begin: start, end: start + end -1}
81+
continue
82+
}
83+
84+
if r_table.match(line) || r_image.match(line) ||
85+
r_example_block.match(line) || r_example_delim.match(line) {
86+
expect_block = false
87+
continue
88+
}
89+
90+
if expect_block {
91+
matches = append(matches, expect_block)
92+
expect_block = false
93+
}
94+
}
95+
96+
if expect_block {
97+
matches = append(matches, expect_block)
98+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Report unsupported callout lists.
2+
---
3+
extends: existence
4+
message: "Callouts are not supported in DITA."
5+
level: warning
6+
scope: raw
7+
nonword: true
8+
tokens:
9+
- '^<(?:1|\.)>[ \t]+.*$'
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Report conditional directives.
2+
---
3+
extends: existence
4+
message: "%s"
5+
level: suggestion
6+
link: https://github.com/jhradilek/asciidoctor-dita-vale/blob/main/README.md#suggestions
7+
scope: raw
8+
nonword: true
9+
tokens:
10+
- '^(?:ifn?def|ifeval)::\S*\[.*\][ \t]*$'
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Report a missing content type definition.
2+
---
3+
extends: occurrence
4+
message: "The '_mod-docs-content-type' attribute definition is missing."
5+
level: warning
6+
link: https://github.com/jhradilek/asciidoctor-dita-vale/blob/main/README.md#warnings
7+
scope: raw
8+
min: 1
9+
token: '(?:^|[\n\r]):_(?:mod-docs-content|content|module)-type:[ \t]+\S'
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Report that discrete headings are not supported.
2+
---
3+
extends: existence
4+
message: "Discrete headings are not supported in DITA."
5+
level: warning
6+
link: https://github.com/jhradilek/asciidoctor-dita-vale/blob/main/README.md#warnings
7+
scope: raw
8+
nonword: true
9+
tokens:
10+
- '^\[discrete\b[^\n\]]*?\]'
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
# Report unsupported character entity references.
2+
---
3+
extends: script
4+
message: "HTML character entity references are not supported in DITA."
5+
level: error
6+
link: https://github.com/jhradilek/asciidoctor-dita-vale/blob/main/README.md#errors
7+
scope: raw
8+
script: |
9+
text := import("text")
10+
matches := []
11+
12+
r_attribute_list := text.re_compile("^\\[(?:|[\\w.#%{,\"'].*)\\][ \\t]*$")
13+
r_block_title := text.re_compile("^\\.{1,2}[^ \\t.].*$")
14+
r_code_block := text.re_compile("^(?:\\.{4,}|-{4,})[ \\t]*$")
15+
r_comment_line := text.re_compile("^(//|//[^/].*)$")
16+
r_comment_block := text.re_compile("^/{4,}\\s*$")
17+
r_empty_line := text.re_compile("^[ \\t]*$")
18+
r_entity_reference := text.re_compile("&[a-zA-Z][a-zA-Z0-9]*;")
19+
r_list_continue := text.re_compile("^\\+[ \\t]*$")
20+
r_sub_disabled := text.re_compile("-replacements")
21+
r_sub_replacements := text.re_compile("subs=['\\x22](?:[^'\\x22]*,[ \\t]*|)\\+?(?:replacements|normal)(?:[ \\t]*,[^'\\x22]*|)['\\x22]")
22+
r_supported_entity := text.re_compile("&(?:amp|lt|gt|apos|quot);")
23+
24+
document := text.split(text.trim_suffix(scope, "\n"), "\n")
25+
26+
in_code_block := false
27+
in_comment_block := false
28+
replacements := false
29+
start := 0
30+
end := 0
31+
32+
for line in document {
33+
start += end
34+
end = len(line) + 1
35+
36+
if r_comment_block.match(line) {
37+
delimiter := text.trim_space(line)
38+
if ! in_comment_block {
39+
in_comment_block = delimiter
40+
} else if in_comment_block == delimiter {
41+
in_comment_block = false
42+
}
43+
continue
44+
}
45+
if in_comment_block { continue }
46+
if r_comment_line.match(line) { continue }
47+
48+
if r_code_block.match(line) {
49+
delimiter := text.trim_space(line)
50+
if ! in_code_block {
51+
in_code_block = delimiter
52+
} else if in_code_block == delimiter {
53+
in_code_block = false
54+
replacements = false
55+
}
56+
continue
57+
}
58+
if in_code_block && ! replacements { continue }
59+
60+
if r_block_title.match(line) { continue }
61+
if r_empty_line.match(line) { continue }
62+
if r_list_continue.match(line) { continue }
63+
64+
if r_attribute_list.match(line) {
65+
if r_sub_replacements.match(line) && ! r_sub_disabled.match(line) {
66+
replacements = true
67+
}
68+
continue
69+
}
70+
71+
if replacements && ! in_code_block {
72+
replacements = false
73+
}
74+
75+
for i, entry in r_entity_reference.find(line, -1) {
76+
if ! r_supported_entity.match(entry[0].text) {
77+
matches = append(matches, {begin: start + entry[0].begin, end: start + entry[0].end - 1})
78+
}
79+
}
80+
}

0 commit comments

Comments
 (0)