Skip to content

Commit

Permalink
tweaks for script rules regex
Browse files Browse the repository at this point in the history
  • Loading branch information
aireilly committed Apr 27, 2023
1 parent bfe7ca8 commit 0a719ea
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 15 deletions.
4 changes: 2 additions & 2 deletions .vale/styles/AsciiDoc/MatchingDotCallouts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ script: |
num_codeblock_callouts := 0
num_callouts := 0
codeblock_callout_regex := ".+<(\\.)>"
codeblock_callout_regex := ".*<(\\.)>"
callout_regex := "^<(\\.)>"
for line in text.split(scope, "\n") {
Expand All @@ -37,4 +37,4 @@ script: |
num_codeblock_callouts = 0
}
}
}
}
4 changes: 2 additions & 2 deletions .vale/styles/AsciiDoc/MatchingNumberedCallouts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ script: |
num_codeblock_callouts := 0
num_callouts := 0
codeblock_callout_regex := ".+( <\\d+>)+"
codeblock_callout_regex := ".*( <\\d+>)+"
callout_regex := "^<(\\d+)>"
for line in text.split(scope, "\n") {
Expand All @@ -37,4 +37,4 @@ script: |
num_codeblock_callouts = 0
}
}
}
}
10 changes: 5 additions & 5 deletions .vale/styles/AsciiDoc/SequentialNumberedCallouts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ script: |
matches := []
prev_num := 0
numbered_callout_regex := "<(\\d+)>"
listingblock_delim_regex := "^-{4,}$"
numbered_callout_regex := ".*<(\\d+)>"
listingblock_delim_regex := "^-{3,}$"
for line in text.split(scope, "\n") {
//reset count if we hit a listing block delimiter
//reset count if we hit a listing block delimiter
if text.re_match(listingblock_delim_regex, line) {
prev_num = 0
}
Expand All @@ -30,9 +30,9 @@ script: |
//start counting
if num != prev_num+1 {
start := text.index(scope, line)
matches = append(matches, {begin: start, end: start + len(line)})
matches = append(matches, {begin: start, end: start + len(line)})
}
prev_num = num
}
}
}
}
4 changes: 2 additions & 2 deletions .vale/styles/AsciiDoc/ValidAdmonitionBlocks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ script: |
if text.re_match(admon_delim_regex, line) {
count += 1
start := text.index(scope, line)
matches = append(matches, {begin: start, end: start + len(line)})
matches = append(matches, {begin: start, end: start + len(line)})
} else if count > 1 {
count = 0 // admonition block is closed, reset the count
matches = []
}
}
}
6 changes: 3 additions & 3 deletions .vale/styles/AsciiDoc/ValidCodeBlocks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ scope: raw
script: |
text := import("text")
matches := []
listingblock_delim_regex := "^-{4,}$"
listingblock_delim_regex := "^-{3,}$"
count := 0
for line in text.split(scope, "\n") {
if text.re_match(listingblock_delim_regex, line) {
count += 1
start := text.index(scope, line)
matches = append(matches, {begin: start, end: start + len(line)})
matches = append(matches, {begin: start, end: start + len(line)})
} else if count > 1 {
count = 0 // listing block is closed, reset the count
matches = []
}
}
}
2 changes: 1 addition & 1 deletion .vale/styles/AsciiDoc/ValidConditions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ link: https://docs.asciidoctor.org/asciidoc/latest/directives/ifdef-ifndef/
scope: raw
script: |
text := import("text")
matches := []
if_regex := "^(ifdef::.+\\[\\]|ifndef::.+\\[\\]|ifeval::.*)"
Expand Down

0 comments on commit 0a719ea

Please sign in to comment.