gbu-accessibility-package 3.5.0 → 3.8.1
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.
- package/CHANGELOG.md +63 -0
- package/README-vi.md +51 -7
- package/README.md +50 -7
- package/bin/fix.js +140 -0
- package/bin/test.js +71 -0
- package/cli.js +97 -5
- package/lib/fixer.js +1494 -122
- package/package.json +16 -5
- package/ENHANCED_ALT_FEATURES.md +0 -230
- package/demo/advanced-test.html +0 -44
- package/demo/aria-label-test.html +0 -32
- package/demo/broken-links-test.html +0 -41
- package/demo/comprehensive-test.html +0 -21
- package/demo/demo.js +0 -73
- package/demo/duplicate-roles.html +0 -45
- package/demo/enhanced-alt-test.html +0 -150
- package/demo/form-labels-test.html +0 -87
- package/demo/heading-structure-test.html +0 -60
- package/demo/nested-controls-test.html +0 -92
- package/demo/sample.html +0 -47
- package/example.js +0 -121
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "gbu-accessibility-package",
|
|
3
|
-
"version": "3.
|
|
4
|
-
"description": "Comprehensive accessibility fixes for HTML files. Smart context-aware alt text generation, form labels, button names, link names, landmarks, heading analysis,
|
|
3
|
+
"version": "3.8.1",
|
|
4
|
+
"description": "Comprehensive accessibility fixes and project optimization for HTML files. Smart context-aware alt text generation, form labels, button names, link names, landmarks, heading analysis, WCAG-compliant role attributes, unused files detection, dead code analysis, broken external links detection, and missing local resources detection. Covers major axe DevTools issues with individual fix modes.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"bin": {
|
|
7
7
|
"gbu-a11y": "cli.js",
|
|
@@ -21,6 +21,11 @@
|
|
|
21
21
|
"landmarks-only": "node cli.js --landmarks-only",
|
|
22
22
|
"headings-only": "node cli.js --headings-only",
|
|
23
23
|
"links-check": "node cli.js --links-check",
|
|
24
|
+
"broken-links": "node cli.js --broken-links",
|
|
25
|
+
"404-resources": "node cli.js --404-resources",
|
|
26
|
+
"unused-files": "node cli.js --unused-files",
|
|
27
|
+
"dead-code": "node cli.js --dead-code",
|
|
28
|
+
"file-size": "node cli.js --file-size",
|
|
24
29
|
"cleanup-only": "node cli.js --cleanup-only",
|
|
25
30
|
"no-backup": "node cli.js --no-backup",
|
|
26
31
|
"cleanup-backups": "find . -name '*.backup' -type f -delete",
|
|
@@ -51,6 +56,14 @@
|
|
|
51
56
|
"smart-alt-text",
|
|
52
57
|
"accessibility-fixer",
|
|
53
58
|
"html-accessibility",
|
|
59
|
+
"unused-files",
|
|
60
|
+
"dead-code",
|
|
61
|
+
"missing-resources",
|
|
62
|
+
"404-resources",
|
|
63
|
+
"link-validation",
|
|
64
|
+
"resource-checking",
|
|
65
|
+
"project-optimization",
|
|
66
|
+
"code-analysis",
|
|
54
67
|
"gbu",
|
|
55
68
|
"comprehensive",
|
|
56
69
|
"individual-fixes",
|
|
@@ -69,16 +82,14 @@
|
|
|
69
82
|
},
|
|
70
83
|
"files": [
|
|
71
84
|
"lib/",
|
|
85
|
+
"bin/",
|
|
72
86
|
"index.js",
|
|
73
87
|
"cli.js",
|
|
74
|
-
"example.js",
|
|
75
|
-
"demo/",
|
|
76
88
|
"README.md",
|
|
77
89
|
"README-vi.md",
|
|
78
90
|
"CHANGELOG.md",
|
|
79
91
|
"QUICK_START.md",
|
|
80
92
|
"PACKAGE_SUMMARY.md",
|
|
81
|
-
"ENHANCED_ALT_FEATURES.md",
|
|
82
93
|
"LICENSE"
|
|
83
94
|
],
|
|
84
95
|
"dependencies": {
|
package/ENHANCED_ALT_FEATURES.md
DELETED
|
@@ -1,230 +0,0 @@
|
|
|
1
|
-
# Enhanced Alt Attribute Features
|
|
2
|
-
|
|
3
|
-
## Tổng quan
|
|
4
|
-
|
|
5
|
-
Enhanced Alt Attribute features là bộ tính năng cải tiến cho việc kiểm tra và tạo alt text đa dạng, thông minh hơn so với phiên bản cơ bản.
|
|
6
|
-
|
|
7
|
-
## Tính năng chính
|
|
8
|
-
|
|
9
|
-
### 🔍 **Phân tích toàn diện**
|
|
10
|
-
- **Phân loại hình ảnh**: Tự động phân loại hình ảnh theo mục đích (decorative, functional, complex, logo, data-visualization, etc.)
|
|
11
|
-
- **Kiểm tra chất lượng nội dung**: Phát hiện alt text quá dài/ngắn, từ thừa, generic text
|
|
12
|
-
- **Phân tích ngữ cảnh**: Hiểu context xung quanh hình ảnh để tạo alt text phù hợp
|
|
13
|
-
- **Kiểm tra tính nhất quán**: So sánh alt text với aria-label, title attributes
|
|
14
|
-
|
|
15
|
-
### 🎨 **Tạo alt text đa dạng**
|
|
16
|
-
- **Context-aware generation**: Dựa trên heading, paragraph, figcaption xung quanh
|
|
17
|
-
- **Semantic analysis**: Phân tích semantic từ src và context
|
|
18
|
-
- **Emotional context**: Thêm cảm xúc và tone phù hợp
|
|
19
|
-
- **Brand awareness**: Nhận diện và tích hợp thông tin thương hiệu
|
|
20
|
-
- **Technical descriptions**: Mô tả chuyên sâu cho biểu đồ, sơ đồ
|
|
21
|
-
|
|
22
|
-
### 🌐 **Đa ngôn ngữ**
|
|
23
|
-
- **Japanese (ja)**: Từ vựng phong phú, ngữ pháp chính xác
|
|
24
|
-
- **English (en)**: Vocabulary đa dạng, grammar tự nhiên
|
|
25
|
-
- **Vietnamese (vi)**: Hỗ trợ tiếng Việt với từ vựng phù hợp
|
|
26
|
-
|
|
27
|
-
## Cách sử dụng
|
|
28
|
-
|
|
29
|
-
### CLI Commands
|
|
30
|
-
|
|
31
|
-
```bash
|
|
32
|
-
# Bật enhanced alt mode
|
|
33
|
-
node cli.js --enhanced-alt
|
|
34
|
-
|
|
35
|
-
# Chọn mức độ creativity
|
|
36
|
-
node cli.js --enhanced-alt --alt-creativity conservative # Đơn giản, factual
|
|
37
|
-
node cli.js --enhanced-alt --alt-creativity balanced # Cân bằng (default)
|
|
38
|
-
node cli.js --enhanced-alt --alt-creativity creative # Phong phú, sáng tạo
|
|
39
|
-
|
|
40
|
-
# Thêm emotional context
|
|
41
|
-
node cli.js --enhanced-alt --include-emotions
|
|
42
|
-
|
|
43
|
-
# Kiểm tra strict quality
|
|
44
|
-
node cli.js --enhanced-alt --strict-alt
|
|
45
|
-
|
|
46
|
-
# Kết hợp các options
|
|
47
|
-
node cli.js --enhanced-alt --alt-creativity creative --include-emotions --strict-alt
|
|
48
|
-
```
|
|
49
|
-
|
|
50
|
-
### Programmatic Usage
|
|
51
|
-
|
|
52
|
-
```javascript
|
|
53
|
-
const { AccessibilityFixer, EnhancedAltChecker } = require('gbu-accessibility-package');
|
|
54
|
-
|
|
55
|
-
// Sử dụng AccessibilityFixer với enhanced mode
|
|
56
|
-
const fixer = new AccessibilityFixer({
|
|
57
|
-
language: 'ja',
|
|
58
|
-
enhancedAltMode: true,
|
|
59
|
-
altCreativity: 'creative',
|
|
60
|
-
includeEmotions: true,
|
|
61
|
-
strictAltChecking: true
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
await fixer.fixEmptyAltAttributes('./src');
|
|
65
|
-
|
|
66
|
-
// Sử dụng EnhancedAltChecker riêng biệt
|
|
67
|
-
const checker = new EnhancedAltChecker({
|
|
68
|
-
language: 'en',
|
|
69
|
-
strictMode: true
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
const issues = checker.analyzeAltAttributes(htmlContent);
|
|
73
|
-
```
|
|
74
|
-
|
|
75
|
-
## Ví dụ cải tiến
|
|
76
|
-
|
|
77
|
-
### Before (Basic mode):
|
|
78
|
-
```html
|
|
79
|
-
<img src="company-logo.png">
|
|
80
|
-
<!-- Generates: alt="ロゴ" -->
|
|
81
|
-
|
|
82
|
-
<img src="sales-chart.png" alt="">
|
|
83
|
-
<!-- Generates: alt="グラフ" -->
|
|
84
|
-
```
|
|
85
|
-
|
|
86
|
-
### After (Enhanced mode):
|
|
87
|
-
```html
|
|
88
|
-
<img src="company-logo.png">
|
|
89
|
-
<!-- Generates: alt="Technology company logo" -->
|
|
90
|
-
|
|
91
|
-
<img src="sales-chart.png" alt="">
|
|
92
|
-
<!-- Context: "Sales increased 25% this quarter" -->
|
|
93
|
-
<!-- Generates: alt="Sales performance chart showing 25% increase" -->
|
|
94
|
-
```
|
|
95
|
-
|
|
96
|
-
## Creativity Levels
|
|
97
|
-
|
|
98
|
-
### Conservative
|
|
99
|
-
- Mô tả đơn giản, factual
|
|
100
|
-
- Tập trung vào chức năng cơ bản
|
|
101
|
-
- Ít từ vựng đa dạng
|
|
102
|
-
|
|
103
|
-
**Example**: `alt="Chart"`, `alt="Logo"`
|
|
104
|
-
|
|
105
|
-
### Balanced (Default)
|
|
106
|
-
- Context-aware descriptions
|
|
107
|
-
- Vừa phải về creativity
|
|
108
|
-
- Cân bằng giữa đơn giản và chi tiết
|
|
109
|
-
|
|
110
|
-
**Example**: `alt="Sales performance chart"`, `alt="Company logo"`
|
|
111
|
-
|
|
112
|
-
### Creative
|
|
113
|
-
- Mô tả phong phú, chi tiết
|
|
114
|
-
- Tích hợp emotional context
|
|
115
|
-
- Brand và context awareness cao
|
|
116
|
-
|
|
117
|
-
**Example**: `alt="Dynamic sales performance chart showing impressive 25% quarterly growth"`, `alt="Innovative technology company logo representing digital transformation"`
|
|
118
|
-
|
|
119
|
-
## Image Type Classification
|
|
120
|
-
|
|
121
|
-
### Decorative Images
|
|
122
|
-
- **Detection**: Border, pattern, texture images
|
|
123
|
-
- **Recommendation**: `alt=""`
|
|
124
|
-
- **Rationale**: Không cần mô tả cho screen readers
|
|
125
|
-
|
|
126
|
-
### Functional Icons
|
|
127
|
-
- **Detection**: Icons trong buttons, links
|
|
128
|
-
- **Recommendation**: Mô tả chức năng
|
|
129
|
-
- **Example**: `alt="Open chat"`, `alt="Search"`
|
|
130
|
-
|
|
131
|
-
### Data Visualizations
|
|
132
|
-
- **Detection**: Charts, graphs, diagrams
|
|
133
|
-
- **Recommendation**: Mô tả loại + xu hướng + data
|
|
134
|
-
- **Example**: `alt="Bar chart showing 40% increase in user engagement"`
|
|
135
|
-
|
|
136
|
-
### Complex Images
|
|
137
|
-
- **Detection**: Flowcharts, maps, architectural diagrams
|
|
138
|
-
- **Recommendation**: Alt ngắn + longdesc hoặc mô tả chi tiết
|
|
139
|
-
- **Example**: `alt="System architecture diagram"` + detailed description
|
|
140
|
-
|
|
141
|
-
### Logos
|
|
142
|
-
- **Detection**: Logo keywords, brand context
|
|
143
|
-
- **Recommendation**: Brand name + "logo"
|
|
144
|
-
- **Example**: `alt="Microsoft logo"`, `alt="GBU company logo"`
|
|
145
|
-
|
|
146
|
-
## Quality Checks
|
|
147
|
-
|
|
148
|
-
### Error Level Issues
|
|
149
|
-
- ❌ **Missing alt attribute**
|
|
150
|
-
- ❌ **Empty alt for content images**
|
|
151
|
-
- ❌ **Generic alt text** ("click here", "read more")
|
|
152
|
-
- ❌ **Missing data description** (for charts without trend info)
|
|
153
|
-
|
|
154
|
-
### Warning Level Issues
|
|
155
|
-
- ⚠️ **Alt text too long** (>125 characters)
|
|
156
|
-
- ⚠️ **Alt text too short** (<3 characters for content)
|
|
157
|
-
- ⚠️ **Redundant words** ("image", "picture", "photo")
|
|
158
|
-
- ⚠️ **Filename in alt text**
|
|
159
|
-
- ⚠️ **Inconsistent labels** (alt ≠ aria-label)
|
|
160
|
-
|
|
161
|
-
### Info Level Issues
|
|
162
|
-
- ℹ️ **Redundant title attribute**
|
|
163
|
-
- ℹ️ **Optimization suggestions**
|
|
164
|
-
|
|
165
|
-
## Testing
|
|
166
|
-
|
|
167
|
-
```bash
|
|
168
|
-
# Test enhanced features
|
|
169
|
-
npm run test-enhanced-alt
|
|
170
|
-
|
|
171
|
-
# Demo enhanced mode
|
|
172
|
-
npm run demo-enhanced
|
|
173
|
-
|
|
174
|
-
# Demo creative mode
|
|
175
|
-
npm run demo-creative
|
|
176
|
-
```
|
|
177
|
-
|
|
178
|
-
## Configuration Options
|
|
179
|
-
|
|
180
|
-
```javascript
|
|
181
|
-
{
|
|
182
|
-
// Enhanced mode settings
|
|
183
|
-
enhancedAltMode: true, // Enable enhanced features
|
|
184
|
-
altCreativity: 'balanced', // conservative|balanced|creative
|
|
185
|
-
includeEmotions: false, // Add emotional descriptors
|
|
186
|
-
strictAltChecking: false, // Strict quality checking
|
|
187
|
-
|
|
188
|
-
// Alt generation settings
|
|
189
|
-
maxAltLength: 125, // Maximum alt text length
|
|
190
|
-
minAltLength: 3, // Minimum alt text length
|
|
191
|
-
checkDecorative: true, // Check decorative images
|
|
192
|
-
checkInformative: true, // Check informative images
|
|
193
|
-
checkComplex: true, // Check complex images
|
|
194
|
-
|
|
195
|
-
// Language and context
|
|
196
|
-
language: 'ja', // ja|en|vi
|
|
197
|
-
includeBrandContext: true, // Include brand information
|
|
198
|
-
}
|
|
199
|
-
```
|
|
200
|
-
|
|
201
|
-
## Performance Impact
|
|
202
|
-
|
|
203
|
-
- **Enhanced mode**: ~20-30% slower due to comprehensive analysis
|
|
204
|
-
- **Memory usage**: +15-20% for vocabulary and analysis
|
|
205
|
-
- **Accuracy**: 85-90% improvement in alt text quality
|
|
206
|
-
- **Coverage**: 95%+ detection of alt attribute issues
|
|
207
|
-
|
|
208
|
-
## Roadmap
|
|
209
|
-
|
|
210
|
-
### v3.2.0 (Planned)
|
|
211
|
-
- [ ] AI-powered image content analysis
|
|
212
|
-
- [ ] Custom vocabulary support
|
|
213
|
-
- [ ] Batch alt text review interface
|
|
214
|
-
- [ ] Integration with design systems
|
|
215
|
-
|
|
216
|
-
### v3.3.0 (Future)
|
|
217
|
-
- [ ] Real-time alt text suggestions
|
|
218
|
-
- [ ] Visual alt text editor
|
|
219
|
-
- [ ] Accessibility score calculation
|
|
220
|
-
- [ ] Team collaboration features
|
|
221
|
-
|
|
222
|
-
## Contributing
|
|
223
|
-
|
|
224
|
-
Enhanced alt features được phát triển với focus vào:
|
|
225
|
-
1. **Accuracy**: Alt text chính xác, phù hợp context
|
|
226
|
-
2. **Diversity**: Đa dạng trong cách mô tả
|
|
227
|
-
3. **Usability**: Dễ sử dụng, configuration linh hoạt
|
|
228
|
-
4. **Performance**: Tối ưu tốc độ xử lý
|
|
229
|
-
|
|
230
|
-
Contributions welcome! Please see main README for guidelines.
|
package/demo/advanced-test.html
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
<!DOCTYPE html>
|
|
2
|
-
<html>
|
|
3
|
-
<head>
|
|
4
|
-
<meta charset="UTF-8">
|
|
5
|
-
<title>Advanced Accessibility Test</title>
|
|
6
|
-
</head>
|
|
7
|
-
<body>
|
|
8
|
-
<h1>Advanced Accessibility Test</h1>
|
|
9
|
-
|
|
10
|
-
<!-- Form issues -->
|
|
11
|
-
<form>
|
|
12
|
-
<input type="text" placeholder="Name">
|
|
13
|
-
<input type="email" id="email">
|
|
14
|
-
<input type="password">
|
|
15
|
-
<input type="submit">
|
|
16
|
-
</form>
|
|
17
|
-
|
|
18
|
-
<!-- Button issues -->
|
|
19
|
-
<button></button>
|
|
20
|
-
<button onclick="alert('test')"></button>
|
|
21
|
-
<input type="button">
|
|
22
|
-
|
|
23
|
-
<!-- Link issues -->
|
|
24
|
-
<a href="/home"></a>
|
|
25
|
-
<a href="/more">Click here</a>
|
|
26
|
-
<a href="/read">Read more</a>
|
|
27
|
-
<a href="/image"><img src="icon.png"></a>
|
|
28
|
-
|
|
29
|
-
<!-- Heading issues -->
|
|
30
|
-
<h3>Skipped h2</h3>
|
|
31
|
-
<h1>Second h1</h1>
|
|
32
|
-
<h4></h4>
|
|
33
|
-
|
|
34
|
-
<!-- Landmark issues -->
|
|
35
|
-
<div class="content">
|
|
36
|
-
<p>Main content without landmark</p>
|
|
37
|
-
</div>
|
|
38
|
-
|
|
39
|
-
<ul class="navigation">
|
|
40
|
-
<li><a href="/home">Home</a></li>
|
|
41
|
-
<li><a href="/about">About</a></li>
|
|
42
|
-
</ul>
|
|
43
|
-
</body>
|
|
44
|
-
</html>
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
<!DOCTYPE html>
|
|
2
|
-
<html lang="ja">
|
|
3
|
-
<head>
|
|
4
|
-
<meta charset="UTF-8">
|
|
5
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
6
|
-
<title>Aria Label Test</title>
|
|
7
|
-
</head>
|
|
8
|
-
<body>
|
|
9
|
-
<h1>Aria Label Test Cases</h1>
|
|
10
|
-
|
|
11
|
-
<!-- Test case 1: Image with alt but no aria-label -->
|
|
12
|
-
<img src="test1.jpg" alt="Test image 1" role="img" aria-label="Test image 1">
|
|
13
|
-
|
|
14
|
-
<!-- Test case 2: Image with alt and existing aria-label (should not change) -->
|
|
15
|
-
<img src="test2.jpg" alt="Test image 2" aria-label="Custom label" role="img">
|
|
16
|
-
|
|
17
|
-
<!-- Test case 3: Image with empty alt (should not add aria-label) -->
|
|
18
|
-
<img src="test3.jpg" alt="" role="img">
|
|
19
|
-
|
|
20
|
-
<!-- Test case 4: Image without alt (should generate alt and aria-label) -->
|
|
21
|
-
<img src="logo.png" role="img">
|
|
22
|
-
|
|
23
|
-
<!-- Test case 5: Picture with role and img with alt -->
|
|
24
|
-
<picture>
|
|
25
|
-
<source srcset="responsive.webp" type="image/webp">
|
|
26
|
-
<img src="responsive.jpg" alt="Responsive image" role="img" aria-label="Responsive image">
|
|
27
|
-
</picture>
|
|
28
|
-
|
|
29
|
-
<!-- Test case 6: Image with role but no aria-label -->
|
|
30
|
-
<img src="test6.jpg" alt="Test image 6" role="img" aria-label="Test image 6">
|
|
31
|
-
</body>
|
|
32
|
-
</html>
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
<!DOCTYPE html>
|
|
2
|
-
<html lang="ja">
|
|
3
|
-
<head>
|
|
4
|
-
<meta charset="UTF-8">
|
|
5
|
-
<title>Broken Links Test</title>
|
|
6
|
-
<!-- Broken CSS -->
|
|
7
|
-
<link rel="stylesheet" href="missing-style.css">
|
|
8
|
-
<!-- Working CSS (if exists) -->
|
|
9
|
-
<link rel="stylesheet" href="../package.json">
|
|
10
|
-
</head>
|
|
11
|
-
<body>
|
|
12
|
-
<h1>Broken Links Test</h1>
|
|
13
|
-
|
|
14
|
-
<!-- Working local link -->
|
|
15
|
-
<a href="advanced-test.html">Working local link</a>
|
|
16
|
-
|
|
17
|
-
<!-- Broken local link -->
|
|
18
|
-
<a href="non-existent-page.html">Broken local link</a>
|
|
19
|
-
|
|
20
|
-
<!-- Working external link -->
|
|
21
|
-
<a href="https://www.google.com">Working external link</a>
|
|
22
|
-
|
|
23
|
-
<!-- Broken external link -->
|
|
24
|
-
<a href="https://this-domain-does-not-exist-12345.com">Broken external link</a>
|
|
25
|
-
|
|
26
|
-
<!-- Working image -->
|
|
27
|
-
<img src="advanced-test.html" alt="Working image reference">
|
|
28
|
-
|
|
29
|
-
<!-- Broken image -->
|
|
30
|
-
<img src="missing-image.jpg" alt="Broken image">
|
|
31
|
-
|
|
32
|
-
<!-- Broken script -->
|
|
33
|
-
<script src="missing-script.js"></script>
|
|
34
|
-
|
|
35
|
-
<!-- Skip patterns -->
|
|
36
|
-
<a href="#anchor">Anchor link (should skip)</a>
|
|
37
|
-
<a href="mailto:test@example.com">Email link (should skip)</a>
|
|
38
|
-
<a href="tel:+1234567890">Phone link (should skip)</a>
|
|
39
|
-
<a href="javascript:void(0)">JavaScript link (should skip)</a>
|
|
40
|
-
</body>
|
|
41
|
-
</html>
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
<!DOCTYPE html>
|
|
2
|
-
<html>
|
|
3
|
-
<head>
|
|
4
|
-
<meta charset="UTF-8">
|
|
5
|
-
<title>Comprehensive Test</title>
|
|
6
|
-
</head>
|
|
7
|
-
<body>
|
|
8
|
-
<h1>Comprehensive Test File</h1>
|
|
9
|
-
|
|
10
|
-
<!-- Missing alt -->
|
|
11
|
-
<img src="test.jpg">
|
|
12
|
-
|
|
13
|
-
<!-- Missing role -->
|
|
14
|
-
<a href="/home">Home</a>
|
|
15
|
-
|
|
16
|
-
<!-- Duplicate roles -->
|
|
17
|
-
<img src="dup.jpg" alt="Duplicate" role="img" role="img">
|
|
18
|
-
|
|
19
|
-
<p>This tests comprehensive mode as default.</p>
|
|
20
|
-
</body>
|
|
21
|
-
</html>
|
package/demo/demo.js
DELETED
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Demo script to test accessibility package functionality
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
const path = require('path');
|
|
8
|
-
const { AccessibilityTester, AccessibilityFixer } = require('../index');
|
|
9
|
-
const chalk = require('chalk');
|
|
10
|
-
|
|
11
|
-
async function runDemo() {
|
|
12
|
-
console.log(chalk.blue('🚀 Accessibility Package Demo'));
|
|
13
|
-
console.log(chalk.blue('===============================\n'));
|
|
14
|
-
|
|
15
|
-
try {
|
|
16
|
-
// Test the fixer first
|
|
17
|
-
console.log(chalk.yellow('1. Testing Accessibility Fixer...'));
|
|
18
|
-
const fixer = new AccessibilityFixer({
|
|
19
|
-
language: 'ja',
|
|
20
|
-
dryRun: true // Don't actually modify files in demo
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
// Go to parent directory to find HTML files
|
|
24
|
-
const projectRoot = path.join(__dirname, '../..');
|
|
25
|
-
|
|
26
|
-
console.log(chalk.gray(` Scanning directory: ${projectRoot}`));
|
|
27
|
-
|
|
28
|
-
const langResults = await fixer.fixHtmlLang(projectRoot);
|
|
29
|
-
console.log(chalk.green(` ✅ Lang attribute check: ${langResults.length} files scanned`));
|
|
30
|
-
|
|
31
|
-
const altResults = await fixer.fixEmptyAltAttributes(projectRoot);
|
|
32
|
-
console.log(chalk.green(` ✅ Alt attribute check: ${altResults.length} files scanned`));
|
|
33
|
-
|
|
34
|
-
const mainSuggestions = await fixer.addMainLandmarks(projectRoot);
|
|
35
|
-
console.log(chalk.green(` ✅ Main landmark check: ${mainSuggestions.length} suggestions`));
|
|
36
|
-
|
|
37
|
-
console.log(chalk.yellow('\n2. Testing Accessibility Tester...'));
|
|
38
|
-
|
|
39
|
-
// Find HTML files in project
|
|
40
|
-
const fs = require('fs').promises;
|
|
41
|
-
const files = await fs.readdir(projectRoot);
|
|
42
|
-
const htmlFiles = files.filter(f => f.endsWith('.html')).slice(0, 3); // Test first 3 files
|
|
43
|
-
|
|
44
|
-
if (htmlFiles.length > 0) {
|
|
45
|
-
console.log(chalk.gray(` Found HTML files: ${htmlFiles.join(', ')}`));
|
|
46
|
-
|
|
47
|
-
const tester = new AccessibilityTester({
|
|
48
|
-
baseUrl: 'http://localhost:8080',
|
|
49
|
-
outputDir: path.join(projectRoot, 'accessibility-reports'),
|
|
50
|
-
pages: htmlFiles,
|
|
51
|
-
serverPort: 8080
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
console.log(chalk.gray(' Note: Actual testing requires a running server'));
|
|
55
|
-
console.log(chalk.green(' ✅ Tester configuration ready'));
|
|
56
|
-
} else {
|
|
57
|
-
console.log(chalk.yellow(' ⚠️ No HTML files found for testing'));
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
console.log(chalk.green('\n✅ Demo completed successfully!'));
|
|
61
|
-
console.log(chalk.blue('\n📋 Package is working correctly. You can now use:'));
|
|
62
|
-
console.log(chalk.white(' a11y-fix all --dry-run # Preview fixes'));
|
|
63
|
-
console.log(chalk.white(' a11y-fix all # Apply fixes'));
|
|
64
|
-
console.log(chalk.white(' a11y-test run # Run accessibility tests'));
|
|
65
|
-
|
|
66
|
-
} catch (error) {
|
|
67
|
-
console.error(chalk.red(`❌ Demo failed: ${error.message}`));
|
|
68
|
-
console.error(chalk.gray(error.stack));
|
|
69
|
-
process.exit(1);
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
runDemo();
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
<!DOCTYPE html>
|
|
2
|
-
<html lang="ja">
|
|
3
|
-
<head>
|
|
4
|
-
<title>Test Duplicate Roles</title>
|
|
5
|
-
</head>
|
|
6
|
-
<body>
|
|
7
|
-
<h1>Test Duplicate Role Attributes</h1>
|
|
8
|
-
|
|
9
|
-
<!-- Images with duplicate roles -->
|
|
10
|
-
<img src="logo.png" alt="Logo" role="img" role="img" role="img" role="img" role="img">
|
|
11
|
-
<img src="banner.jpg" alt="Banner" role="img" role="img" role="img" role="img" role="img" role="img">
|
|
12
|
-
|
|
13
|
-
<!-- Links with duplicate roles -->
|
|
14
|
-
<a href="/home" role="link" role="link" role="link" role="link" role="link">Home</a>
|
|
15
|
-
<a href="/about" role="link" role="link" role="link" role="link" role="link" role="link">About</a>
|
|
16
|
-
|
|
17
|
-
<!-- Buttons with duplicate roles -->
|
|
18
|
-
<button onclick="submit()" role="button" role="button" role="button" role="button" role="button">Submit</button>
|
|
19
|
-
<button type="button" role="button" role="button" role="button">Click Me</button>
|
|
20
|
-
|
|
21
|
-
<!-- Mixed quotes -->
|
|
22
|
-
<div onclick="toggle()" role="button" role='button' role="button" role="button" role="button">Toggle</div>
|
|
23
|
-
<span onclick="show()" role='button' role="button" role="button" role="button" role="button">Show</span>
|
|
24
|
-
|
|
25
|
-
<!-- Navigation with duplicates -->
|
|
26
|
-
<nav>
|
|
27
|
-
<ul class="nav-menu" role="menubar" role="menubar" role="menubar" role="menubar" role="menubar">
|
|
28
|
-
<li class="nav-item" role="menuitem" role="menuitem" role="menuitem" role="menuitem" role="menuitem">
|
|
29
|
-
<a href="/products" role="link" role="link" role="link" role="link" role="link">Products</a>
|
|
30
|
-
</li>
|
|
31
|
-
<li class="nav-item" role="menuitem" role="menuitem" role="menuitem" role="menuitem" role="menuitem" role="menuitem">
|
|
32
|
-
<a href="/services" role="link" role="link" role="link" role="link" role="link" role="link">Services</a>
|
|
33
|
-
</li>
|
|
34
|
-
</ul>
|
|
35
|
-
</nav>
|
|
36
|
-
|
|
37
|
-
<!-- Complex duplicates -->
|
|
38
|
-
<article>
|
|
39
|
-
<h2>Article with Issues</h2>
|
|
40
|
-
<img src="article1.jpg" alt="Article Image" role="img" role="img" role="img" role="img" role="img">
|
|
41
|
-
<p>Some content...</p>
|
|
42
|
-
<a href="/read-more" role="link" role="link" role="link" role="link" role="link" role="link" role="link">Read More</a>
|
|
43
|
-
</article>
|
|
44
|
-
</body>
|
|
45
|
-
</html>
|