a11y-lint 0.7.0 → 0.7.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +14 -0
- data/lib/a11y/lint/erb_runner.rb +11 -4
- data/lib/a11y/lint/slim_runner.rb +14 -0
- data/lib/a11y/lint/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: fcce561f67949c3ba5eb95447325e06ce67c2e759733c0623168ce5948183222
|
|
4
|
+
data.tar.gz: 59a739dcb7b14d79d2b8c7a4bb135853c04f3f1e79558cf8ddc05c0435c52a18
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: d03e078e621d82b48f114f6f8a2ecfa7bf05f746892bf5640c6ee5e5817ac740ee086ddb6dab3a7c993436d653bbd38f15967696a58f41802d335a67a22ab2ea
|
|
7
|
+
data.tar.gz: 1a07a2c565896cde540e09adc8352602166ce7da1ecdcb555c52220a8fc764504abab43bf17ebefb0fe436ca4cff3835d9bae355fd620d08b3f64c6dcf83d291
|
data/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,20 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [Unreleased]
|
|
9
|
+
|
|
10
|
+
## [0.7.2] - 2026-04-13
|
|
11
|
+
|
|
12
|
+
### Fixed
|
|
13
|
+
|
|
14
|
+
- ERB runner: skip phantom elements created when Nokogiri interprets text-mentioned HTML tags as real elements
|
|
15
|
+
|
|
16
|
+
## [0.7.1] - 2026-04-13
|
|
17
|
+
|
|
18
|
+
### Fixed
|
|
19
|
+
|
|
20
|
+
- Slim runner: correct line numbers in templates with multiline backslash continuations
|
|
21
|
+
|
|
8
22
|
## [0.7.0] - 2026-04-13
|
|
9
23
|
|
|
10
24
|
### Added
|
data/lib/a11y/lint/erb_runner.rb
CHANGED
|
@@ -8,6 +8,10 @@ module A11y
|
|
|
8
8
|
class ErbRunner
|
|
9
9
|
ERB_TAG = /<%.*?%>/m
|
|
10
10
|
ERB_OUTPUT_TAG = /<%=\s*(.*?)\s*-?%>/m
|
|
11
|
+
VOID_ELEMENTS = %w[
|
|
12
|
+
area base br col embed hr img input
|
|
13
|
+
link meta param source track wbr
|
|
14
|
+
].freeze
|
|
11
15
|
|
|
12
16
|
def initialize(rules)
|
|
13
17
|
@rules = rules
|
|
@@ -33,15 +37,18 @@ module A11y
|
|
|
33
37
|
|
|
34
38
|
doc.traverse do |nokogiri_node|
|
|
35
39
|
next unless nokogiri_node.element?
|
|
40
|
+
next unless source_confirmed_element?(html, nokogiri_node.name)
|
|
36
41
|
|
|
37
|
-
|
|
38
|
-
nokogiri_node: nokogiri_node,
|
|
39
|
-
line: nokogiri_node.line
|
|
42
|
+
check_node(
|
|
43
|
+
ErbNode.new(nokogiri_node: nokogiri_node, line: nokogiri_node.line)
|
|
40
44
|
)
|
|
41
|
-
check_node(node)
|
|
42
45
|
end
|
|
43
46
|
end
|
|
44
47
|
|
|
48
|
+
def source_confirmed_element?(html, tag_name)
|
|
49
|
+
VOID_ELEMENTS.include?(tag_name) || html.include?("</#{tag_name}>")
|
|
50
|
+
end
|
|
51
|
+
|
|
45
52
|
def check_erb_output_tags(source)
|
|
46
53
|
source.scan(ERB_OUTPUT_TAG) do
|
|
47
54
|
match = Regexp.last_match
|
|
@@ -27,6 +27,7 @@ module A11y
|
|
|
27
27
|
@line += 1 if sexp[0] == :newline
|
|
28
28
|
new_node = Node.new(sexp, line: @line)
|
|
29
29
|
check_node(new_node) if html_tag?(sexp) || slim_output?(sexp)
|
|
30
|
+
@line += continuation_newlines(sexp)
|
|
30
31
|
sexp.each { |child| walk(child) }
|
|
31
32
|
end
|
|
32
33
|
|
|
@@ -38,6 +39,19 @@ module A11y
|
|
|
38
39
|
sexp[0] == :slim && sexp[1] == :output
|
|
39
40
|
end
|
|
40
41
|
|
|
42
|
+
# Counts extra source lines consumed by backslash-continued
|
|
43
|
+
# multiline expressions in :output and :control nodes.
|
|
44
|
+
# Slim collapses these into one AST node whose ruby_code
|
|
45
|
+
# string retains the original newlines.
|
|
46
|
+
def continuation_newlines(sexp)
|
|
47
|
+
code = case sexp
|
|
48
|
+
in [:slim, :output, _, String => c, *] then c
|
|
49
|
+
in [:slim, :control, String => c, *] then c
|
|
50
|
+
else return 0
|
|
51
|
+
end
|
|
52
|
+
code.count("\n")
|
|
53
|
+
end
|
|
54
|
+
|
|
41
55
|
def node?(sexp)
|
|
42
56
|
sexp.is_a?(Array) && !sexp.empty? && sexp[0].is_a?(Symbol)
|
|
43
57
|
end
|
data/lib/a11y/lint/version.rb
CHANGED