gbu-accessibility-package 3.0.0 → 3.1.0
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 +124 -0
- package/README-vi.md +500 -0
- package/README.md +193 -106
- package/package.json +19 -5
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
## [3.0.0] - 2024-07-25
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
- **Form Labels**: Automatic fixing of missing form labels with intelligent aria-label generation
|
|
12
|
+
- **Button Names**: Fix empty buttons and input buttons without names
|
|
13
|
+
- **Link Names**: Fix empty links and detect generic link text
|
|
14
|
+
- **Landmarks**: Add missing main and navigation landmarks
|
|
15
|
+
- **Heading Analysis**: Analyze heading structure with suggestions (no auto-fix for safety)
|
|
16
|
+
- **Individual Fix Modes**: New CLI options for targeted fixes:
|
|
17
|
+
- `--forms-only` - Fix form labels + cleanup
|
|
18
|
+
- `--buttons-only` - Fix button names + cleanup
|
|
19
|
+
- `--links-only` - Fix link names + cleanup
|
|
20
|
+
- `--landmarks-only` - Fix landmarks + cleanup
|
|
21
|
+
- `--headings-only` - Analyze heading structure only
|
|
22
|
+
- **Comprehensive Mode**: Now includes 9 steps of accessibility fixes
|
|
23
|
+
- **Language Support**: Japanese labels for form inputs and buttons
|
|
24
|
+
- **axe DevTools Coverage**: Addresses major axe accessibility issues
|
|
25
|
+
- **Advanced Demo**: New `advanced-test.html` showcasing all features
|
|
26
|
+
|
|
27
|
+
### Changed
|
|
28
|
+
- **BREAKING**: Comprehensive fixes now default mode (was basic fixes)
|
|
29
|
+
- **All individual modes** now include cleanup step for consistency
|
|
30
|
+
- **Enhanced CLI**: Better help messages and examples
|
|
31
|
+
- **Improved Reporting**: More detailed issue analysis and suggestions
|
|
32
|
+
|
|
33
|
+
### Enhanced
|
|
34
|
+
- **Alt Text Generation**: Now also adds matching aria-label attributes
|
|
35
|
+
- **Role Attributes**: Enhanced picture/img handling
|
|
36
|
+
- **Context Analysis**: Improved smart text generation
|
|
37
|
+
- **Error Handling**: Better error messages and recovery
|
|
38
|
+
|
|
39
|
+
## [2.1.0] - 2024-07-24
|
|
40
|
+
|
|
41
|
+
### Added
|
|
42
|
+
- **Backup Management**: Improved backup options with `--backup` and `--no-backup`
|
|
43
|
+
- **Consistent Messaging**: Unified completion messages across all modes
|
|
44
|
+
- **Cleanup Scripts**: npm script for removing backup files
|
|
45
|
+
|
|
46
|
+
### Changed
|
|
47
|
+
- **Default Behavior**: Comprehensive fixes as default mode
|
|
48
|
+
- **Backup Notifications**: Clear messaging about backup status
|
|
49
|
+
|
|
50
|
+
## [2.0.0] - 2024-07-24
|
|
51
|
+
|
|
52
|
+
### Added
|
|
53
|
+
- **Comprehensive Mode**: All fixes including cleanup as default
|
|
54
|
+
- **Basic Mode**: `--basic` flag for fixes without cleanup
|
|
55
|
+
|
|
56
|
+
### Changed
|
|
57
|
+
- **BREAKING**: Default mode now runs comprehensive fixes
|
|
58
|
+
- **CLI Behavior**: Simplified command structure
|
|
59
|
+
|
|
60
|
+
## [1.6.0] - 2024-07-24
|
|
61
|
+
|
|
62
|
+
### Added
|
|
63
|
+
- **Backup Options**: Explicit `--backup` and `--no-backup` flags
|
|
64
|
+
- **Helper Functions**: Consistent completion messaging
|
|
65
|
+
- **Safety Features**: Enhanced backup management
|
|
66
|
+
|
|
67
|
+
## [1.5.0] - 2024-07-24
|
|
68
|
+
|
|
69
|
+
### Added
|
|
70
|
+
- **Aria Label Support**: Automatic aria-label generation matching alt text
|
|
71
|
+
- **Picture Handling**: Move role from `<picture>` to `<img>` elements
|
|
72
|
+
- **Enhanced Reporting**: Comprehensive issue analysis
|
|
73
|
+
|
|
74
|
+
## [1.4.0] - 2024-07-24
|
|
75
|
+
|
|
76
|
+
### Added
|
|
77
|
+
- **Individual Fix Options**: Separate modes for different fix types
|
|
78
|
+
- **Enhanced CLI**: More granular control over fixes
|
|
79
|
+
|
|
80
|
+
## [1.3.0] - 2024-07-24
|
|
81
|
+
|
|
82
|
+
### Added
|
|
83
|
+
- **Individual Fix Modes**: `--alt-only`, `--lang-only`, `--role-only`
|
|
84
|
+
- **Enhanced Documentation**: Updated README with new features
|
|
85
|
+
|
|
86
|
+
## [1.2.0] - 2024-07-24
|
|
87
|
+
|
|
88
|
+
### Added
|
|
89
|
+
- **Role Attributes**: Comprehensive role attribute management
|
|
90
|
+
- **Duplicate Cleanup**: Remove duplicate role attributes
|
|
91
|
+
- **Context-Aware Alt Text**: Intelligent alt text generation
|
|
92
|
+
|
|
93
|
+
## [1.1.0] - 2024-07-24
|
|
94
|
+
|
|
95
|
+
### Added
|
|
96
|
+
- **HTML Lang Attributes**: Automatic language attribute fixes
|
|
97
|
+
- **Backup System**: Automatic backup file creation
|
|
98
|
+
|
|
99
|
+
## [1.0.0] - 2024-07-24
|
|
100
|
+
|
|
101
|
+
### Added
|
|
102
|
+
- **Initial Release**: Basic alt attribute fixes
|
|
103
|
+
- **CLI Interface**: Command-line tool
|
|
104
|
+
- **Dry Run Mode**: Preview changes before applying
|
|
105
|
+
- **Batch Processing**: Process multiple files and directories
|
|
106
|
+
|
|
107
|
+
---
|
|
108
|
+
|
|
109
|
+
## Migration Guides
|
|
110
|
+
|
|
111
|
+
### Upgrading to 3.0.0
|
|
112
|
+
- **No breaking changes for most users** - you get better default behavior
|
|
113
|
+
- **New features available** - try `--forms-only`, `--buttons-only`, etc.
|
|
114
|
+
- **Comprehensive mode is now default** - includes all fixes + cleanup
|
|
115
|
+
- **Heading analysis is safe** - only provides suggestions, no auto-fixes
|
|
116
|
+
|
|
117
|
+
### Upgrading to 2.0.0
|
|
118
|
+
- **Default behavior changed** - now runs comprehensive fixes by default
|
|
119
|
+
- **Use `--basic` flag** if you want the old default behavior
|
|
120
|
+
- **All modes now include cleanup** for better consistency
|
|
121
|
+
|
|
122
|
+
---
|
|
123
|
+
|
|
124
|
+
For more details about any release, see the [GitHub Releases](https://github.com/dangpv94/gbu-accessibility-tool/releases) page.
|
package/README-vi.md
ADDED
|
@@ -0,0 +1,500 @@
|
|
|
1
|
+
# GBU Accessibility Package
|
|
2
|
+
|
|
3
|
+
🚀 **Công cụ tự động sửa lỗi accessibility cho file HTML** - Cải thiện khả năng tiếp cận thông minh, nhận biết ngữ cảnh mà không cần cấu hình.
|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/gbu-accessibility-package)
|
|
6
|
+
[](https://opensource.org/licenses/MIT)
|
|
7
|
+
[](https://nodejs.org/)
|
|
8
|
+
|
|
9
|
+
## ✨ Tính năng
|
|
10
|
+
|
|
11
|
+
- 🖼️ **Tạo Alt Text thông minh** - Tự động tạo alt attributes dựa trên ngữ cảnh
|
|
12
|
+
- 🏷️ **Hỗ trợ Aria Label** - Tự động thêm aria-label khớp với alt text
|
|
13
|
+
- 🌐 **HTML Lang Attributes** - Tự động sửa thuộc tính ngôn ngữ
|
|
14
|
+
- 🎭 **Role Attributes** - Quản lý role attributes tuân thủ WCAG
|
|
15
|
+
- 📋 **Form Labels** - Sửa lỗi label thiếu cho form inputs
|
|
16
|
+
- 🔘 **Button Names** - Sửa button rỗng và input button thiếu tên
|
|
17
|
+
- 🔗 **Link Names** - Sửa link rỗng và text link chung chung
|
|
18
|
+
- 🏛️ **Landmarks** - Thêm main và navigation landmarks
|
|
19
|
+
- 📑 **Phân tích Headings** - Phân tích cấu trúc heading với đề xuất
|
|
20
|
+
- 🧹 **Dọn dẹp trùng lặp** - Xóa role attributes trùng lặp
|
|
21
|
+
- 📁 **Xử lý hàng loạt** - Xử lý toàn bộ thư mục đệ quy
|
|
22
|
+
- 💾 **Backup tự động** - Sửa đổi an toàn với file backup
|
|
23
|
+
- 🔍 **Chế độ xem trước** - Xem trước thay đổi trước khi áp dụng
|
|
24
|
+
- 📊 **Báo cáo chi tiết** - Tóm tắt sửa chữa toàn diện
|
|
25
|
+
|
|
26
|
+
## 🚀 Bắt đầu nhanh
|
|
27
|
+
|
|
28
|
+
### Cài đặt
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
# Cài đặt toàn cục (khuyến nghị)
|
|
32
|
+
npm install -g gbu-accessibility-package
|
|
33
|
+
|
|
34
|
+
# Cài đặt cục bộ
|
|
35
|
+
npm install gbu-accessibility-package
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
### Sử dụng cơ bản
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
# Sửa toàn diện (mặc định)
|
|
42
|
+
gbu-a11y
|
|
43
|
+
|
|
44
|
+
# Xem trước thay đổi
|
|
45
|
+
gbu-a11y --dry-run
|
|
46
|
+
|
|
47
|
+
# Sửa thư mục cụ thể
|
|
48
|
+
gbu-a11y ./src
|
|
49
|
+
|
|
50
|
+
# Sửa file cụ thể
|
|
51
|
+
gbu-a11y index.html
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
## 📖 Hướng dẫn chi tiết
|
|
55
|
+
|
|
56
|
+
### Tùy chọn dòng lệnh
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
gbu-a11y [options] [directory/file]
|
|
60
|
+
|
|
61
|
+
Tùy chọn:
|
|
62
|
+
-d, --directory <path> Thư mục đích (mặc định: thư mục hiện tại)
|
|
63
|
+
-l, --language <lang> Ngôn ngữ cho thuộc tính lang (mặc định: ja)
|
|
64
|
+
--backup Tạo file backup (mặc định: bật)
|
|
65
|
+
--no-backup Không tạo file backup
|
|
66
|
+
--dry-run Xem trước thay đổi mà không áp dụng
|
|
67
|
+
--comprehensive, --all Chạy sửa toàn diện (giống mặc định)
|
|
68
|
+
--cleanup-only Chỉ dọn dẹp role attributes trùng lặp
|
|
69
|
+
--alt-only Sửa alt attributes + dọn dẹp
|
|
70
|
+
--lang-only Sửa HTML lang attributes + dọn dẹp
|
|
71
|
+
--role-only Sửa role attributes + dọn dẹp
|
|
72
|
+
--forms-only Sửa form labels + dọn dẹp
|
|
73
|
+
--buttons-only Sửa button names + dọn dẹp
|
|
74
|
+
--links-only Sửa link names + dọn dẹp
|
|
75
|
+
--landmarks-only Sửa landmarks + dọn dẹp
|
|
76
|
+
--headings-only Phân tích cấu trúc heading (không tự động sửa)
|
|
77
|
+
-h, --help Hiển thị thông báo trợ giúp
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
### Ví dụ
|
|
81
|
+
|
|
82
|
+
```bash
|
|
83
|
+
# Sửa toàn diện (mặc định - bao gồm dọn dẹp)
|
|
84
|
+
gbu-a11y
|
|
85
|
+
|
|
86
|
+
# Xem trước tất cả thay đổi
|
|
87
|
+
gbu-a11y --dry-run
|
|
88
|
+
|
|
89
|
+
# Sửa với ngôn ngữ tiếng Anh
|
|
90
|
+
gbu-a11y -l en ./public
|
|
91
|
+
|
|
92
|
+
# Các loại sửa riêng lẻ (tất cả đều bao gồm dọn dẹp)
|
|
93
|
+
gbu-a11y --alt-only # Sửa alt attributes + dọn dẹp
|
|
94
|
+
gbu-a11y --forms-only # Sửa form labels + dọn dẹp
|
|
95
|
+
gbu-a11y --buttons-only # Sửa button names + dọn dẹp
|
|
96
|
+
gbu-a11y --links-only # Sửa link names + dọn dẹp
|
|
97
|
+
gbu-a11y --landmarks-only # Sửa landmarks + dọn dẹp
|
|
98
|
+
gbu-a11y --headings-only # Phân tích heading structure
|
|
99
|
+
gbu-a11y --cleanup-only # Chỉ dọn dẹp trùng lặp
|
|
100
|
+
|
|
101
|
+
# Kết hợp với các tùy chọn khác
|
|
102
|
+
gbu-a11y --alt-only --dry-run ./src # Xem trước sửa alt
|
|
103
|
+
gbu-a11y --forms-only -l en ./public # Sửa form với tiếng Anh
|
|
104
|
+
|
|
105
|
+
# Tùy chọn backup
|
|
106
|
+
gbu-a11y --backup ./dist # Bật backup rõ ràng (mặc định)
|
|
107
|
+
gbu-a11y --no-backup ./dist # Tắt backup để xử lý nhanh hơn
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
## 🔧 Sử dụng lập trình
|
|
111
|
+
|
|
112
|
+
```javascript
|
|
113
|
+
const AccessibilityFixer = require('gbu-accessibility-package');
|
|
114
|
+
|
|
115
|
+
const fixer = new AccessibilityFixer({
|
|
116
|
+
language: 'vi',
|
|
117
|
+
backupFiles: true,
|
|
118
|
+
dryRun: false
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
// Sửa tất cả vấn đề accessibility
|
|
122
|
+
async function fixAccessibility() {
|
|
123
|
+
try {
|
|
124
|
+
const results = await fixer.fixAllAccessibilityIssues('./src');
|
|
125
|
+
console.log('File đã sửa:', results);
|
|
126
|
+
} catch (error) {
|
|
127
|
+
console.error('Lỗi:', error);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
fixAccessibility();
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
## 🎯 Chế độ sửa
|
|
135
|
+
|
|
136
|
+
### Chế độ toàn diện (Mặc định)
|
|
137
|
+
Chạy tất cả các bước sửa bao gồm dọn dẹp:
|
|
138
|
+
|
|
139
|
+
1. **HTML lang attributes** - Thêm thuộc tính ngôn ngữ
|
|
140
|
+
2. **Alt attributes** - Tạo alt text thông minh + aria-label
|
|
141
|
+
3. **Role attributes** - Thêm role phù hợp + xử lý picture/img
|
|
142
|
+
4. **Form labels** - Sửa input thiếu label
|
|
143
|
+
5. **Button names** - Sửa button rỗng
|
|
144
|
+
6. **Link names** - Sửa link rỗng và generic text
|
|
145
|
+
7. **Landmarks** - Thêm main và navigation landmarks
|
|
146
|
+
8. **Heading analysis** - Phân tích cấu trúc (chỉ đề xuất)
|
|
147
|
+
9. **Cleanup** - Dọn dẹp role attributes trùng lặp
|
|
148
|
+
|
|
149
|
+
### Chế độ riêng lẻ
|
|
150
|
+
Mỗi chế độ riêng lẻ đều bao gồm bước dọn dẹp:
|
|
151
|
+
|
|
152
|
+
- `--alt-only` - Chỉ sửa alt attributes + dọn dẹp
|
|
153
|
+
- `--forms-only` - Chỉ sửa form labels + dọn dẹp
|
|
154
|
+
- `--buttons-only` - Chỉ sửa button names + dọn dẹp
|
|
155
|
+
- `--links-only` - Chỉ sửa link names + dọn dẹp
|
|
156
|
+
- `--landmarks-only` - Chỉ sửa landmarks + dọn dẹp
|
|
157
|
+
- `--headings-only` - Chỉ phân tích headings (không dọn dẹp)
|
|
158
|
+
|
|
159
|
+
## 🔧 Những gì được sửa
|
|
160
|
+
|
|
161
|
+
### 1. Alt Attributes
|
|
162
|
+
- **Alt attributes thiếu** → Thêm alt text theo ngữ cảnh
|
|
163
|
+
- **Alt attributes rỗng** → Tạo mô tả có ý nghĩa
|
|
164
|
+
- **Tạo theo ngữ cảnh** → Sử dụng text xung quanh, tiêu đề, chú thích
|
|
165
|
+
|
|
166
|
+
```html
|
|
167
|
+
<!-- Trước -->
|
|
168
|
+
<img src="logo.png">
|
|
169
|
+
<img src="chart.jpg" alt="">
|
|
170
|
+
|
|
171
|
+
<!-- Sau -->
|
|
172
|
+
<img src="logo.png" alt="ロゴ" role="img" aria-label="ロゴ">
|
|
173
|
+
<img src="chart.jpg" alt="グラフ" role="img" aria-label="グラフ">
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
### 2. HTML Lang Attributes
|
|
177
|
+
- **Lang attributes thiếu** → Thêm ngôn ngữ được chỉ định
|
|
178
|
+
- **Lang attributes rỗng** → Đặt mã ngôn ngữ phù hợp
|
|
179
|
+
|
|
180
|
+
```html
|
|
181
|
+
<!-- Trước -->
|
|
182
|
+
<html>
|
|
183
|
+
<html lang="">
|
|
184
|
+
|
|
185
|
+
<!-- Sau -->
|
|
186
|
+
<html lang="ja">
|
|
187
|
+
<html lang="ja">
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
### 3. Role Attributes & Aria Labels
|
|
191
|
+
- **Images** → `role="img"` + `aria-label` (khớp với alt text)
|
|
192
|
+
- **Picture elements** → Di chuyển `role="img"` từ `<picture>` vào `<img>` bên trong
|
|
193
|
+
- **Links** → `role="link"`
|
|
194
|
+
- **Clickable elements** → `role="button"`
|
|
195
|
+
- **Navigation lists** → `role="menubar"`
|
|
196
|
+
- **Menu items** → `role="menuitem"`
|
|
197
|
+
|
|
198
|
+
```html
|
|
199
|
+
<!-- Trước -->
|
|
200
|
+
<img src="icon.png" alt="Icon">
|
|
201
|
+
<picture role="img">
|
|
202
|
+
<img src="photo.jpg" alt="Photo">
|
|
203
|
+
</picture>
|
|
204
|
+
<a href="/home">Home</a>
|
|
205
|
+
<div class="btn-click">Click me</div>
|
|
206
|
+
|
|
207
|
+
<!-- Sau -->
|
|
208
|
+
<img src="icon.png" alt="Icon" role="img" aria-label="Icon">
|
|
209
|
+
<picture>
|
|
210
|
+
<img src="photo.jpg" alt="Photo" role="img" aria-label="Photo">
|
|
211
|
+
</picture>
|
|
212
|
+
<a href="/home" role="link">Home</a>
|
|
213
|
+
<div class="btn-click" role="button">Click me</div>
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
### 4. Form Labels
|
|
217
|
+
- **Input thiếu label** → Thêm `aria-label` phù hợp
|
|
218
|
+
- **Hỗ trợ nhiều loại input** → text, email, password, tel, etc.
|
|
219
|
+
|
|
220
|
+
```html
|
|
221
|
+
<!-- Trước -->
|
|
222
|
+
<input type="text" placeholder="Name">
|
|
223
|
+
<input type="email">
|
|
224
|
+
<input type="password">
|
|
225
|
+
|
|
226
|
+
<!-- Sau -->
|
|
227
|
+
<input type="text" placeholder="Name" aria-label="テキスト入力">
|
|
228
|
+
<input type="email" aria-label="メールアドレス">
|
|
229
|
+
<input type="password" aria-label="パスワード">
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
### 5. Button Names
|
|
233
|
+
- **Button rỗng** → Thêm text và aria-label
|
|
234
|
+
- **Input button thiếu value** → Thêm value phù hợp
|
|
235
|
+
|
|
236
|
+
```html
|
|
237
|
+
<!-- Trước -->
|
|
238
|
+
<button></button>
|
|
239
|
+
<input type="submit">
|
|
240
|
+
<input type="button">
|
|
241
|
+
|
|
242
|
+
<!-- Sau -->
|
|
243
|
+
<button aria-label="ボタン">ボタン</button>
|
|
244
|
+
<input type="submit" value="送信">
|
|
245
|
+
<input type="button" value="ボタン">
|
|
246
|
+
```
|
|
247
|
+
|
|
248
|
+
### 6. Link Names
|
|
249
|
+
- **Link rỗng** → Thêm aria-label
|
|
250
|
+
- **Generic text** → Phát hiện "Click here", "Read more"
|
|
251
|
+
- **Image links** → Xử lý link chỉ chứa hình ảnh
|
|
252
|
+
|
|
253
|
+
```html
|
|
254
|
+
<!-- Trước -->
|
|
255
|
+
<a href="/home"></a>
|
|
256
|
+
<a href="/more">Click here</a>
|
|
257
|
+
<a href="/image"><img src="icon.png"></a>
|
|
258
|
+
|
|
259
|
+
<!-- Sau -->
|
|
260
|
+
<a href="/home" aria-label="リンク">リンク</a>
|
|
261
|
+
<a href="/more">Click here</a> <!-- Được phát hiện nhưng không tự động sửa -->
|
|
262
|
+
<a href="/image" aria-label="画像リンク"><img src="icon.png"></a>
|
|
263
|
+
```
|
|
264
|
+
|
|
265
|
+
### 7. Landmarks
|
|
266
|
+
- **Main landmark thiếu** → Thêm `role="main"`
|
|
267
|
+
- **Navigation landmark thiếu** → Thêm `role="navigation"`
|
|
268
|
+
|
|
269
|
+
```html
|
|
270
|
+
<!-- Trước -->
|
|
271
|
+
<div class="content">
|
|
272
|
+
<p>Main content</p>
|
|
273
|
+
</div>
|
|
274
|
+
<ul class="navigation">
|
|
275
|
+
<li><a href="/home">Home</a></li>
|
|
276
|
+
</ul>
|
|
277
|
+
|
|
278
|
+
<!-- Sau -->
|
|
279
|
+
<div class="content" role="main">
|
|
280
|
+
<p>Main content</p>
|
|
281
|
+
</div>
|
|
282
|
+
<ul class="navigation" role="navigation">
|
|
283
|
+
<li><a href="/home">Home</a></li>
|
|
284
|
+
</ul>
|
|
285
|
+
```
|
|
286
|
+
|
|
287
|
+
### 8. Heading Analysis
|
|
288
|
+
- **Multiple h1** → Phát hiện và đề xuất
|
|
289
|
+
- **Heading level skip** → Phát hiện nhảy cấp (h1 → h3)
|
|
290
|
+
- **Empty headings** → Phát hiện heading rỗng
|
|
291
|
+
- **Chỉ phân tích, không tự động sửa** → An toàn cho cấu trúc nội dung
|
|
292
|
+
|
|
293
|
+
### 9. Aria Label Enhancement
|
|
294
|
+
- **Tự động aria-label** → Thêm `aria-label` khớp với `alt` text cho images
|
|
295
|
+
- **Bảo tồn hiện có** → Không ghi đè `aria-label` đã có
|
|
296
|
+
- **Phát hiện thông minh** → Chỉ thêm khi `alt` text tồn tại và không rỗng
|
|
297
|
+
|
|
298
|
+
### 10. Dọn dẹp trùng lặp
|
|
299
|
+
- **Xóa role attributes trùng lặp** → Giữ lại occurrence đầu tiên
|
|
300
|
+
- **Xử lý mixed quotes** → role="button" role='button'
|
|
301
|
+
|
|
302
|
+
```html
|
|
303
|
+
<!-- Trước -->
|
|
304
|
+
<img src="test.jpg" role="img" role="img" alt="Test">
|
|
305
|
+
|
|
306
|
+
<!-- Sau -->
|
|
307
|
+
<img src="test.jpg" role="img" alt="Test">
|
|
308
|
+
```
|
|
309
|
+
|
|
310
|
+
## 🌟 Tạo Alt Text thông minh
|
|
311
|
+
|
|
312
|
+
Package sử dụng phân tích ngữ cảnh thông minh để tạo alt text có ý nghĩa:
|
|
313
|
+
|
|
314
|
+
### Nguồn ngữ cảnh
|
|
315
|
+
1. **Title attributes**
|
|
316
|
+
2. **Aria-label attributes**
|
|
317
|
+
3. **Definition terms (dt elements)**
|
|
318
|
+
4. **Parent link text**
|
|
319
|
+
5. **Nearby headings**
|
|
320
|
+
6. **Figure captions**
|
|
321
|
+
7. **Surrounding text content**
|
|
322
|
+
|
|
323
|
+
### Mẫu dự phòng
|
|
324
|
+
- `logo.png` → "ロゴ" (Logo)
|
|
325
|
+
- `icon.svg` → "アイコン" (Icon)
|
|
326
|
+
- `banner.jpg` → "バナー" (Banner)
|
|
327
|
+
- `chart.png` → "グラフ" (Chart)
|
|
328
|
+
- Hình ảnh chung → "画像" (Image)
|
|
329
|
+
|
|
330
|
+
## 📊 Ví dụ đầu ra
|
|
331
|
+
|
|
332
|
+
### Chế độ toàn diện
|
|
333
|
+
```
|
|
334
|
+
🚀 Starting Accessibility Fixer...
|
|
335
|
+
🎯 Running comprehensive accessibility fixes...
|
|
336
|
+
|
|
337
|
+
📝 Step 1: HTML lang attributes...
|
|
338
|
+
✅ Fixed lang attributes in 5 files
|
|
339
|
+
|
|
340
|
+
🖼️ Step 2: Alt attributes...
|
|
341
|
+
✅ Fixed alt attributes in 12 files (34 issues)
|
|
342
|
+
|
|
343
|
+
🎭 Step 3: Role attributes...
|
|
344
|
+
✅ Fixed role attributes in 8 files (67 issues)
|
|
345
|
+
|
|
346
|
+
📋 Step 4: Form labels...
|
|
347
|
+
✅ Fixed form labels in 6 files (15 issues)
|
|
348
|
+
|
|
349
|
+
🔘 Step 5: Button names...
|
|
350
|
+
✅ Fixed button names in 4 files (8 issues)
|
|
351
|
+
|
|
352
|
+
🔗 Step 6: Link names...
|
|
353
|
+
✅ Fixed link names in 7 files (12 issues)
|
|
354
|
+
|
|
355
|
+
🏛️ Step 7: Landmarks...
|
|
356
|
+
✅ Fixed landmarks in 3 files (5 issues)
|
|
357
|
+
|
|
358
|
+
📑 Step 8: Heading analysis...
|
|
359
|
+
✅ Analyzed headings in 10 files (18 suggestions)
|
|
360
|
+
|
|
361
|
+
🧹 Step 9: Cleanup duplicate roles...
|
|
362
|
+
✅ Cleaned duplicate roles in 2 files
|
|
363
|
+
|
|
364
|
+
🎉 All accessibility fixes completed!
|
|
365
|
+
📊 Final Summary:
|
|
366
|
+
Total files scanned: 25
|
|
367
|
+
Files fixed: 20
|
|
368
|
+
Total issues resolved: 164
|
|
369
|
+
```
|
|
370
|
+
|
|
371
|
+
### Chế độ riêng lẻ
|
|
372
|
+
```
|
|
373
|
+
🚀 Starting Accessibility Fixer...
|
|
374
|
+
📋 Running form label fixes + cleanup...
|
|
375
|
+
|
|
376
|
+
📁 contact.html:
|
|
377
|
+
📋 Missing label/id: Input 1 (type: text) needs an id and label, or aria-label
|
|
378
|
+
📋 Missing label: Input 2 (type: email) needs a label or aria-label
|
|
379
|
+
📋 Added aria-label="テキスト入力" to text input
|
|
380
|
+
📋 Added aria-label="メールアドレス" to email input
|
|
381
|
+
|
|
382
|
+
✅ Fixed form labels in 1 files (2 issues)
|
|
383
|
+
|
|
384
|
+
🧹 Running cleanup for duplicate role attributes...
|
|
385
|
+
✅ Cleaned duplicate roles in 0 files
|
|
386
|
+
|
|
387
|
+
🎉 Form label fixes + cleanup completed successfully!
|
|
388
|
+
📁 Backup files created with .backup extension
|
|
389
|
+
💡 Use --no-backup to disable backups in future runs
|
|
390
|
+
```
|
|
391
|
+
|
|
392
|
+
## 🔒 Tính năng an toàn
|
|
393
|
+
|
|
394
|
+
### Tùy chọn Backup
|
|
395
|
+
- **Hành vi mặc định**: Tự động tạo file `.backup` để an toàn
|
|
396
|
+
- **Tắt backup**: Sử dụng `--no-backup` để xử lý nhanh hơn
|
|
397
|
+
- **Bật rõ ràng**: Sử dụng `--backup` để rõ ràng về việc tạo backup
|
|
398
|
+
|
|
399
|
+
```bash
|
|
400
|
+
# Chế độ an toàn (mặc định) - tạo backup
|
|
401
|
+
gbu-a11y --comprehensive
|
|
402
|
+
|
|
403
|
+
# Chế độ nhanh - không backup
|
|
404
|
+
gbu-a11y --no-backup --comprehensive
|
|
405
|
+
|
|
406
|
+
# Chế độ backup rõ ràng
|
|
407
|
+
gbu-a11y --backup --comprehensive
|
|
408
|
+
```
|
|
409
|
+
|
|
410
|
+
### Các tính năng an toàn khác
|
|
411
|
+
- **Chế độ xem trước** để xem trước an toàn với `--dry-run`
|
|
412
|
+
- **Không phá hoại** - chỉ thêm attributes thiếu
|
|
413
|
+
- **Ngăn chặn trùng lặp** - không thêm attributes đã có
|
|
414
|
+
- **Xử lý lỗi** - tiếp tục xử lý khi có lỗi file riêng lẻ
|
|
415
|
+
|
|
416
|
+
## 🛠️ Cấu hình
|
|
417
|
+
|
|
418
|
+
### Package.json Scripts
|
|
419
|
+
```json
|
|
420
|
+
{
|
|
421
|
+
"scripts": {
|
|
422
|
+
"a11y:fix": "gbu-a11y",
|
|
423
|
+
"a11y:check": "gbu-a11y --dry-run",
|
|
424
|
+
"a11y:comprehensive": "gbu-a11y --comprehensive",
|
|
425
|
+
"a11y:forms": "gbu-a11y --forms-only",
|
|
426
|
+
"a11y:buttons": "gbu-a11y --buttons-only",
|
|
427
|
+
"a11y:links": "gbu-a11y --links-only",
|
|
428
|
+
"a11y:landmarks": "gbu-a11y --landmarks-only",
|
|
429
|
+
"a11y:headings": "gbu-a11y --headings-only",
|
|
430
|
+
"a11y:cleanup": "gbu-a11y --cleanup-only",
|
|
431
|
+
"cleanup-backups": "find . -name '*.backup' -type f -delete"
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
```
|
|
435
|
+
|
|
436
|
+
### Tích hợp CI/CD
|
|
437
|
+
```yaml
|
|
438
|
+
# Ví dụ GitHub Actions
|
|
439
|
+
- name: Check Accessibility
|
|
440
|
+
run: npx gbu-accessibility-package --dry-run
|
|
441
|
+
|
|
442
|
+
- name: Fix Accessibility Issues
|
|
443
|
+
run: npx gbu-accessibility-package --comprehensive
|
|
444
|
+
```
|
|
445
|
+
|
|
446
|
+
## 🤝 Đóng góp
|
|
447
|
+
|
|
448
|
+
1. Fork repository
|
|
449
|
+
2. Tạo feature branch (`git checkout -b feature/amazing-feature`)
|
|
450
|
+
3. Commit thay đổi (`git commit -m 'Add amazing feature'`)
|
|
451
|
+
4. Push lên branch (`git push origin feature/amazing-feature`)
|
|
452
|
+
5. Mở Pull Request
|
|
453
|
+
|
|
454
|
+
## 📝 Giấy phép
|
|
455
|
+
|
|
456
|
+
Dự án này được cấp phép theo Giấy phép MIT - xem file [LICENSE](LICENSE) để biết chi tiết.
|
|
457
|
+
|
|
458
|
+
## 🆘 Hỗ trợ
|
|
459
|
+
|
|
460
|
+
- 📧 **Issues**: [GitHub Issues](https://github.com/dangpv94/gbu-accessibility-tool/issues)
|
|
461
|
+
- 📖 **Tài liệu**: [GitHub Wiki](https://github.com/dangpv94/gbu-accessibility-tool/wiki)
|
|
462
|
+
- 💬 **Thảo luận**: [GitHub Discussions](https://github.com/dangpv94/gbu-accessibility-tool/discussions)
|
|
463
|
+
|
|
464
|
+
## 🏆 Tại sao chọn GBU Accessibility Package?
|
|
465
|
+
|
|
466
|
+
- ✅ **Không cần cấu hình** - Hoạt động ngay lập tức
|
|
467
|
+
- ✅ **Thông minh & nhận biết ngữ cảnh** - Không chỉ sửa chung chung
|
|
468
|
+
- ✅ **An toàn & đáng tin cậy** - Backup tự động và xem trước
|
|
469
|
+
- ✅ **Toàn diện** - Bao gồm tất cả vấn đề accessibility chính
|
|
470
|
+
- ✅ **Nhanh & hiệu quả** - Xử lý hàng loạt với báo cáo chi tiết
|
|
471
|
+
- ✅ **Tuân thủ WCAG** - Theo tiêu chuẩn accessibility
|
|
472
|
+
- ✅ **Hỗ trợ axe DevTools** - Sửa các lỗi phổ biến từ axe
|
|
473
|
+
- ✅ **Phân tích heading an toàn** - Đề xuất thay vì tự động sửa
|
|
474
|
+
- ✅ **Hỗ trợ đa ngôn ngữ** - Tiếng Nhật, tiếng Anh và có thể mở rộng
|
|
475
|
+
|
|
476
|
+
## 📋 Danh sách kiểm tra Accessibility
|
|
477
|
+
|
|
478
|
+
Package này giải quyết các vấn đề accessibility phổ biến từ axe DevTools:
|
|
479
|
+
|
|
480
|
+
### ✅ Đã hỗ trợ
|
|
481
|
+
- `image-alt` - Images must have alternate text
|
|
482
|
+
- `html-has-lang` - HTML element must have lang attribute
|
|
483
|
+
- `label` - Form elements must have labels (cơ bản)
|
|
484
|
+
- `button-name` - Buttons must have discernible text
|
|
485
|
+
- `link-name` - Links must have discernible text (cơ bản)
|
|
486
|
+
- `landmark-one-main` - Document should have one main landmark
|
|
487
|
+
- `region` - Page content should be contained by landmarks
|
|
488
|
+
- `heading-order` - Heading levels analysis (chỉ phân tích)
|
|
489
|
+
- Duplicate role attributes cleanup
|
|
490
|
+
|
|
491
|
+
### 🔄 Đang phát triển
|
|
492
|
+
- `color-contrast` - Color contrast checking
|
|
493
|
+
- `focus-order-semantics` - Focus order validation
|
|
494
|
+
- `aria-*` attributes validation
|
|
495
|
+
- Table accessibility features
|
|
496
|
+
- List structure validation
|
|
497
|
+
|
|
498
|
+
---
|
|
499
|
+
|
|
500
|
+
Được tạo với ❤️ bởi GBU Team
|
package/README.md
CHANGED
|
@@ -12,6 +12,11 @@
|
|
|
12
12
|
- 🏷️ **Aria Label Support** - Automatic aria-label matching alt text
|
|
13
13
|
- 🌐 **HTML Lang Attributes** - Automatic language attribute fixes
|
|
14
14
|
- 🎭 **Role Attributes** - WCAG-compliant role attribute management
|
|
15
|
+
- 📋 **Form Labels** - Fix missing labels with intelligent aria-label generation
|
|
16
|
+
- 🔘 **Button Names** - Fix empty buttons and input buttons without names
|
|
17
|
+
- 🔗 **Link Names** - Fix empty links and detect generic link text
|
|
18
|
+
- 🏛️ **Landmarks** - Add missing main and navigation landmarks
|
|
19
|
+
- 📑 **Heading Analysis** - Analyze heading structure with suggestions (no auto-fix)
|
|
15
20
|
- 🧹 **Duplicate Cleanup** - Remove duplicate role attributes
|
|
16
21
|
- 📁 **Batch Processing** - Process entire directories recursively
|
|
17
22
|
- 💾 **Automatic Backups** - Safe modifications with backup files
|
|
@@ -64,16 +69,21 @@ Options:
|
|
|
64
69
|
--alt-only Fix alt attributes + cleanup
|
|
65
70
|
--lang-only Fix HTML lang attributes + cleanup
|
|
66
71
|
--role-only Fix role attributes + cleanup
|
|
72
|
+
--forms-only Fix form labels + cleanup
|
|
73
|
+
--buttons-only Fix button names + cleanup
|
|
74
|
+
--links-only Fix link names + cleanup
|
|
75
|
+
--landmarks-only Fix landmarks + cleanup
|
|
76
|
+
--headings-only Analyze heading structure (no auto-fix)
|
|
67
77
|
-h, --help Show help message
|
|
68
78
|
```
|
|
69
79
|
|
|
70
80
|
### Examples
|
|
71
81
|
|
|
72
82
|
```bash
|
|
73
|
-
#
|
|
83
|
+
# Comprehensive fixes (default - includes cleanup)
|
|
74
84
|
gbu-a11y
|
|
75
85
|
|
|
76
|
-
# Preview all changes
|
|
86
|
+
# Preview all changes
|
|
77
87
|
gbu-a11y --dry-run
|
|
78
88
|
|
|
79
89
|
# Fix with English language
|
|
@@ -81,13 +91,16 @@ gbu-a11y -l en ./public
|
|
|
81
91
|
|
|
82
92
|
# Individual fix types (all include cleanup)
|
|
83
93
|
gbu-a11y --alt-only # Fix alt attributes + cleanup
|
|
84
|
-
gbu-a11y --
|
|
85
|
-
gbu-a11y --
|
|
94
|
+
gbu-a11y --forms-only # Fix form labels + cleanup
|
|
95
|
+
gbu-a11y --buttons-only # Fix button names + cleanup
|
|
96
|
+
gbu-a11y --links-only # Fix link names + cleanup
|
|
97
|
+
gbu-a11y --landmarks-only # Fix landmarks + cleanup
|
|
98
|
+
gbu-a11y --headings-only # Analyze heading structure
|
|
86
99
|
gbu-a11y --cleanup-only # Only cleanup duplicates
|
|
87
100
|
|
|
88
101
|
# Combine with other options
|
|
89
102
|
gbu-a11y --alt-only --dry-run ./src # Preview alt fixes + cleanup
|
|
90
|
-
gbu-a11y --
|
|
103
|
+
gbu-a11y --forms-only -l en ./public # Form fixes + cleanup with English lang
|
|
91
104
|
|
|
92
105
|
# Backup options
|
|
93
106
|
gbu-a11y --backup ./dist # Explicitly enable backups (default)
|
|
@@ -97,21 +110,21 @@ gbu-a11y --no-backup ./dist # Disable backups for faster processing
|
|
|
97
110
|
## 🔧 Programmatic Usage
|
|
98
111
|
|
|
99
112
|
```javascript
|
|
100
|
-
const AccessibilityFixer = require(
|
|
113
|
+
const AccessibilityFixer = require('gbu-accessibility-package');
|
|
101
114
|
|
|
102
115
|
const fixer = new AccessibilityFixer({
|
|
103
|
-
language:
|
|
116
|
+
language: 'en',
|
|
104
117
|
backupFiles: true,
|
|
105
|
-
dryRun: false
|
|
118
|
+
dryRun: false
|
|
106
119
|
});
|
|
107
120
|
|
|
108
121
|
// Fix all accessibility issues
|
|
109
122
|
async function fixAccessibility() {
|
|
110
123
|
try {
|
|
111
|
-
const results = await fixer.fixAllAccessibilityIssues(
|
|
112
|
-
console.log(
|
|
124
|
+
const results = await fixer.fixAllAccessibilityIssues('./src');
|
|
125
|
+
console.log('Fixed files:', results);
|
|
113
126
|
} catch (error) {
|
|
114
|
-
console.error(
|
|
127
|
+
console.error('Error:', error);
|
|
115
128
|
}
|
|
116
129
|
}
|
|
117
130
|
|
|
@@ -120,75 +133,63 @@ fixAccessibility();
|
|
|
120
133
|
|
|
121
134
|
## 🎯 Fix Modes
|
|
122
135
|
|
|
123
|
-
###
|
|
124
|
-
|
|
125
|
-
You can now fix specific accessibility issues individually:
|
|
126
|
-
|
|
127
|
-
- `--alt-only` - Only fix alt attributes for images
|
|
128
|
-
- `--lang-only` - Only fix HTML lang attributes
|
|
129
|
-
- `--role-only` - Only fix role attributes
|
|
130
|
-
- `--cleanup-only` - Only cleanup duplicate role attributes
|
|
131
|
-
|
|
132
|
-
### Combined Modes
|
|
133
|
-
|
|
134
|
-
- **Standard mode** (default) - Fixes alt, lang, and role attributes
|
|
135
|
-
- `--comprehensive` - All fixes including duplicate cleanup
|
|
136
|
-
|
|
137
|
-
```bash
|
|
138
|
-
# Fix only missing alt attributes
|
|
139
|
-
gbu-a11y --alt-only
|
|
140
|
-
|
|
141
|
-
# Fix only HTML lang attributes
|
|
142
|
-
gbu-a11y --lang-only
|
|
136
|
+
### Comprehensive Mode (Default)
|
|
137
|
+
Runs all fixes including cleanup:
|
|
143
138
|
|
|
144
|
-
|
|
145
|
-
|
|
139
|
+
1. **HTML lang attributes** - Adds missing language attributes
|
|
140
|
+
2. **Alt attributes** - Generates contextual alt text + aria-label
|
|
141
|
+
3. **Role attributes** - Adds appropriate ARIA roles + picture handling
|
|
142
|
+
4. **Form labels** - Fixes missing input labels
|
|
143
|
+
5. **Button names** - Fixes empty buttons
|
|
144
|
+
6. **Link names** - Fixes empty links and detects generic text
|
|
145
|
+
7. **Landmarks** - Adds main and navigation landmarks
|
|
146
|
+
8. **Heading analysis** - Analyzes structure (suggestions only)
|
|
147
|
+
9. **Cleanup** - Removes duplicate role attributes
|
|
146
148
|
|
|
147
|
-
|
|
148
|
-
|
|
149
|
+
### Individual Fix Options
|
|
150
|
+
Each individual mode includes cleanup step:
|
|
149
151
|
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
152
|
+
- `--alt-only` - Alt attributes + cleanup
|
|
153
|
+
- `--forms-only` - Form labels + cleanup
|
|
154
|
+
- `--buttons-only` - Button names + cleanup
|
|
155
|
+
- `--links-only` - Link names + cleanup
|
|
156
|
+
- `--landmarks-only` - Landmarks + cleanup
|
|
157
|
+
- `--headings-only` - Heading analysis only (no cleanup)
|
|
153
158
|
|
|
154
159
|
## 🔧 What Gets Fixed
|
|
155
160
|
|
|
156
|
-
### 1. Alt Attributes
|
|
157
|
-
|
|
161
|
+
### 1. Alt Attributes & Aria Labels
|
|
158
162
|
- **Missing alt attributes** → Adds contextual alt text
|
|
159
163
|
- **Empty alt attributes** → Generates meaningful descriptions
|
|
164
|
+
- **Automatic aria-label** → Adds aria-label matching alt text
|
|
160
165
|
- **Context-aware generation** → Uses surrounding text, headings, captions
|
|
161
166
|
|
|
162
167
|
```html
|
|
163
168
|
<!-- Before -->
|
|
164
|
-
<img src="logo.png"
|
|
165
|
-
<img src="chart.jpg" alt=""
|
|
169
|
+
<img src="logo.png">
|
|
170
|
+
<img src="chart.jpg" alt="">
|
|
166
171
|
|
|
167
172
|
<!-- After -->
|
|
168
|
-
<img src="logo.png" alt="ロゴ"
|
|
169
|
-
<img src="chart.jpg" alt="グラフ"
|
|
173
|
+
<img src="logo.png" alt="ロゴ" role="img" aria-label="ロゴ">
|
|
174
|
+
<img src="chart.jpg" alt="グラフ" role="img" aria-label="グラフ">
|
|
170
175
|
```
|
|
171
176
|
|
|
172
177
|
### 2. HTML Lang Attributes
|
|
173
|
-
|
|
174
178
|
- **Missing lang attributes** → Adds specified language
|
|
175
179
|
- **Empty lang attributes** → Sets proper language code
|
|
176
180
|
|
|
177
181
|
```html
|
|
178
182
|
<!-- Before -->
|
|
179
183
|
<html>
|
|
180
|
-
|
|
181
|
-
<!-- After -->
|
|
182
|
-
<html lang="ja">
|
|
183
|
-
<html lang="ja"></html>
|
|
184
|
-
</html>
|
|
185
|
-
</html>
|
|
186
|
-
</html>
|
|
187
|
-
```
|
|
184
|
+
<html lang="">
|
|
188
185
|
|
|
189
|
-
|
|
186
|
+
<!-- After -->
|
|
187
|
+
<html lang="ja">
|
|
188
|
+
<html lang="ja">
|
|
189
|
+
```
|
|
190
190
|
|
|
191
|
-
|
|
191
|
+
### 3. Role Attributes
|
|
192
|
+
- **Images** → `role="img"`
|
|
192
193
|
- **Picture elements** → Moves `role="img"` from `<picture>` to `<img>` inside
|
|
193
194
|
- **Links** → `role="link"`
|
|
194
195
|
- **Clickable elements** → `role="button"`
|
|
@@ -197,48 +198,109 @@ gbu-a11y --comprehensive
|
|
|
197
198
|
|
|
198
199
|
```html
|
|
199
200
|
<!-- Before -->
|
|
200
|
-
<img src="icon.png" alt="Icon"
|
|
201
|
+
<img src="icon.png" alt="Icon">
|
|
201
202
|
<picture role="img">
|
|
202
|
-
<img src="photo.jpg" alt="Photo"
|
|
203
|
+
<img src="photo.jpg" alt="Photo">
|
|
203
204
|
</picture>
|
|
204
205
|
<a href="/home">Home</a>
|
|
205
206
|
<div class="btn-click">Click me</div>
|
|
206
207
|
|
|
207
208
|
<!-- After -->
|
|
208
|
-
<img src="icon.png" alt="Icon" role="img" aria-label="Icon"
|
|
209
|
+
<img src="icon.png" alt="Icon" role="img" aria-label="Icon">
|
|
209
210
|
<picture>
|
|
210
|
-
<img src="photo.jpg" alt="Photo" role="img" aria-label="Photo"
|
|
211
|
+
<img src="photo.jpg" alt="Photo" role="img" aria-label="Photo">
|
|
211
212
|
</picture>
|
|
212
213
|
<a href="/home" role="link">Home</a>
|
|
213
214
|
<div class="btn-click" role="button">Click me</div>
|
|
214
215
|
```
|
|
215
216
|
|
|
216
|
-
### 4.
|
|
217
|
+
### 4. Form Labels
|
|
218
|
+
- **Input elements without labels** → Adds appropriate `aria-label`
|
|
219
|
+
- **Supports multiple input types** → text, email, password, tel, etc.
|
|
217
220
|
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
+
```html
|
|
222
|
+
<!-- Before -->
|
|
223
|
+
<input type="text" placeholder="Name">
|
|
224
|
+
<input type="email">
|
|
225
|
+
<input type="password">
|
|
226
|
+
|
|
227
|
+
<!-- After -->
|
|
228
|
+
<input type="text" placeholder="Name" aria-label="テキスト入力">
|
|
229
|
+
<input type="email" aria-label="メールアドレス">
|
|
230
|
+
<input type="password" aria-label="パスワード">
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
### 5. Button Names
|
|
234
|
+
- **Empty buttons** → Adds text content and aria-label
|
|
235
|
+
- **Input buttons without value** → Adds appropriate value
|
|
221
236
|
|
|
222
237
|
```html
|
|
223
238
|
<!-- Before -->
|
|
224
|
-
<
|
|
239
|
+
<button></button>
|
|
240
|
+
<input type="submit">
|
|
241
|
+
<input type="button">
|
|
225
242
|
|
|
226
243
|
<!-- After -->
|
|
227
|
-
<
|
|
244
|
+
<button aria-label="ボタン">ボタン</button>
|
|
245
|
+
<input type="submit" value="送信">
|
|
246
|
+
<input type="button" value="ボタン">
|
|
228
247
|
```
|
|
229
248
|
|
|
230
|
-
###
|
|
249
|
+
### 6. Link Names
|
|
250
|
+
- **Empty links** → Adds aria-label
|
|
251
|
+
- **Generic text detection** → Identifies "Click here", "Read more"
|
|
252
|
+
- **Image-only links** → Handles links containing only images
|
|
231
253
|
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
254
|
+
```html
|
|
255
|
+
<!-- Before -->
|
|
256
|
+
<a href="/home"></a>
|
|
257
|
+
<a href="/more">Click here</a>
|
|
258
|
+
<a href="/image"><img src="icon.png"></a>
|
|
259
|
+
|
|
260
|
+
<!-- After -->
|
|
261
|
+
<a href="/home" aria-label="リンク">リンク</a>
|
|
262
|
+
<a href="/more">Click here</a> <!-- Detected but not auto-fixed -->
|
|
263
|
+
<a href="/image" aria-label="画像リンク"><img src="icon.png"></a>
|
|
264
|
+
```
|
|
265
|
+
|
|
266
|
+
### 7. Landmarks
|
|
267
|
+
- **Missing main landmark** → Adds `role="main"`
|
|
268
|
+
- **Missing navigation landmark** → Adds `role="navigation"`
|
|
235
269
|
|
|
236
270
|
```html
|
|
237
271
|
<!-- Before -->
|
|
238
|
-
<
|
|
272
|
+
<div class="content">
|
|
273
|
+
<p>Main content</p>
|
|
274
|
+
</div>
|
|
275
|
+
<ul class="navigation">
|
|
276
|
+
<li><a href="/home">Home</a></li>
|
|
277
|
+
</ul>
|
|
239
278
|
|
|
240
279
|
<!-- After -->
|
|
241
|
-
<
|
|
280
|
+
<div class="content" role="main">
|
|
281
|
+
<p>Main content</p>
|
|
282
|
+
</div>
|
|
283
|
+
<ul class="navigation" role="navigation">
|
|
284
|
+
<li><a href="/home">Home</a></li>
|
|
285
|
+
</ul>
|
|
286
|
+
```
|
|
287
|
+
|
|
288
|
+
### 8. Heading Analysis
|
|
289
|
+
- **Multiple h1 detection** → Identifies and suggests fixes
|
|
290
|
+
- **Heading level skipping** → Detects jumps (h1 → h3)
|
|
291
|
+
- **Empty headings** → Identifies headings without content
|
|
292
|
+
- **Analysis only** → Provides suggestions, no auto-fix for content safety
|
|
293
|
+
|
|
294
|
+
### 9. Duplicate Cleanup
|
|
295
|
+
- **Removes duplicate role attributes** → Keeps first occurrence
|
|
296
|
+
- **Handles mixed quotes** → role="button" role='button'
|
|
297
|
+
|
|
298
|
+
```html
|
|
299
|
+
<!-- Before -->
|
|
300
|
+
<img src="test.jpg" role="img" role="img" alt="Test">
|
|
301
|
+
|
|
302
|
+
<!-- After -->
|
|
303
|
+
<img src="test.jpg" role="img" alt="Test">
|
|
242
304
|
```
|
|
243
305
|
|
|
244
306
|
## 🌟 Smart Alt Text Generation
|
|
@@ -246,9 +308,8 @@ gbu-a11y --comprehensive
|
|
|
246
308
|
The package uses intelligent context analysis to generate meaningful alt text:
|
|
247
309
|
|
|
248
310
|
### Context Sources
|
|
249
|
-
|
|
250
311
|
1. **Title attributes**
|
|
251
|
-
2. **Aria-label attributes**
|
|
312
|
+
2. **Aria-label attributes**
|
|
252
313
|
3. **Definition terms (dt elements)**
|
|
253
314
|
4. **Parent link text**
|
|
254
315
|
5. **Nearby headings**
|
|
@@ -256,7 +317,6 @@ The package uses intelligent context analysis to generate meaningful alt text:
|
|
|
256
317
|
7. **Surrounding text content**
|
|
257
318
|
|
|
258
319
|
### Fallback Patterns
|
|
259
|
-
|
|
260
320
|
- `logo.png` → "ロゴ" (Logo)
|
|
261
321
|
- `icon.svg` → "アイコン" (Icon)
|
|
262
322
|
- `banner.jpg` → "バナー" (Banner)
|
|
@@ -265,47 +325,48 @@ The package uses intelligent context analysis to generate meaningful alt text:
|
|
|
265
325
|
|
|
266
326
|
## 📊 Output Examples
|
|
267
327
|
|
|
268
|
-
###
|
|
269
|
-
|
|
328
|
+
### Comprehensive Mode
|
|
270
329
|
```
|
|
271
330
|
🚀 Starting Accessibility Fixer...
|
|
272
|
-
|
|
331
|
+
🎯 Running comprehensive accessibility fixes...
|
|
332
|
+
|
|
333
|
+
📝 Step 1: HTML lang attributes...
|
|
273
334
|
✅ Fixed lang attributes in 5 files
|
|
274
335
|
|
|
275
|
-
🖼️ Step 2:
|
|
336
|
+
🖼️ Step 2: Alt attributes...
|
|
276
337
|
✅ Fixed alt attributes in 12 files (34 issues)
|
|
277
338
|
|
|
278
|
-
🎭 Step 3:
|
|
339
|
+
🎭 Step 3: Role attributes...
|
|
279
340
|
✅ Fixed role attributes in 8 files (67 issues)
|
|
280
341
|
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
Files fixed: 15
|
|
284
|
-
Total issues resolved: 106
|
|
342
|
+
📋 Step 4: Form labels...
|
|
343
|
+
✅ Fixed form labels in 6 files (15 issues)
|
|
285
344
|
|
|
286
|
-
|
|
287
|
-
|
|
345
|
+
🔘 Step 5: Button names...
|
|
346
|
+
✅ Fixed button names in 4 files (8 issues)
|
|
288
347
|
|
|
289
|
-
|
|
348
|
+
🔗 Step 6: Link names...
|
|
349
|
+
✅ Fixed link names in 7 files (12 issues)
|
|
290
350
|
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
351
|
+
🏛️ Step 7: Landmarks...
|
|
352
|
+
✅ Fixed landmarks in 3 files (5 issues)
|
|
353
|
+
|
|
354
|
+
📑 Step 8: Heading analysis...
|
|
355
|
+
✅ Analyzed headings in 10 files (18 suggestions)
|
|
356
|
+
|
|
357
|
+
🧹 Step 9: Cleanup duplicate roles...
|
|
358
|
+
✅ Cleaned duplicate roles in 2 files
|
|
297
359
|
|
|
298
360
|
🎉 All accessibility fixes completed!
|
|
299
361
|
📊 Final Summary:
|
|
300
362
|
Total files scanned: 25
|
|
301
|
-
Files fixed:
|
|
302
|
-
Total issues resolved:
|
|
363
|
+
Files fixed: 20
|
|
364
|
+
Total issues resolved: 164
|
|
303
365
|
```
|
|
304
366
|
|
|
305
367
|
## 🔒 Safety Features
|
|
306
368
|
|
|
307
369
|
### Backup Options
|
|
308
|
-
|
|
309
370
|
- **Default behavior**: Creates `.backup` files automatically for safety
|
|
310
371
|
- **Disable backups**: Use `--no-backup` for faster processing
|
|
311
372
|
- **Explicit enable**: Use `--backup` to be explicit about backup creation
|
|
@@ -322,7 +383,6 @@ gbu-a11y --backup --comprehensive
|
|
|
322
383
|
```
|
|
323
384
|
|
|
324
385
|
### Other Safety Features
|
|
325
|
-
|
|
326
386
|
- **Dry run mode** for safe previewing with `--dry-run`
|
|
327
387
|
- **Non-destructive** - only adds missing attributes
|
|
328
388
|
- **Duplicate prevention** - won't add existing attributes
|
|
@@ -331,32 +391,55 @@ gbu-a11y --backup --comprehensive
|
|
|
331
391
|
## 🛠️ Configuration
|
|
332
392
|
|
|
333
393
|
### Package.json Scripts
|
|
334
|
-
|
|
335
394
|
```json
|
|
336
395
|
{
|
|
337
396
|
"scripts": {
|
|
338
397
|
"a11y:fix": "gbu-a11y",
|
|
339
398
|
"a11y:check": "gbu-a11y --dry-run",
|
|
340
399
|
"a11y:comprehensive": "gbu-a11y --comprehensive",
|
|
400
|
+
"a11y:forms": "gbu-a11y --forms-only",
|
|
401
|
+
"a11y:buttons": "gbu-a11y --buttons-only",
|
|
402
|
+
"a11y:links": "gbu-a11y --links-only",
|
|
403
|
+
"a11y:landmarks": "gbu-a11y --landmarks-only",
|
|
404
|
+
"a11y:headings": "gbu-a11y --headings-only",
|
|
341
405
|
"a11y:cleanup": "gbu-a11y --cleanup-only",
|
|
342
|
-
"
|
|
343
|
-
"a11y:lang": "gbu-a11y --lang-only",
|
|
344
|
-
"a11y:role": "gbu-a11y --role-only"
|
|
406
|
+
"cleanup-backups": "find . -name '*.backup' -type f -delete"
|
|
345
407
|
}
|
|
346
408
|
}
|
|
347
409
|
```
|
|
348
410
|
|
|
349
411
|
### CI/CD Integration
|
|
350
|
-
|
|
351
412
|
```yaml
|
|
352
413
|
# GitHub Actions example
|
|
353
414
|
- name: Check Accessibility
|
|
354
415
|
run: npx gbu-accessibility-package --dry-run
|
|
355
416
|
|
|
356
|
-
- name: Fix Accessibility Issues
|
|
417
|
+
- name: Fix Accessibility Issues
|
|
357
418
|
run: npx gbu-accessibility-package --comprehensive
|
|
358
419
|
```
|
|
359
420
|
|
|
421
|
+
## 📋 Accessibility Standards Coverage
|
|
422
|
+
|
|
423
|
+
This package addresses common issues found by axe DevTools:
|
|
424
|
+
|
|
425
|
+
### ✅ Supported
|
|
426
|
+
- `image-alt` - Images must have alternate text
|
|
427
|
+
- `html-has-lang` - HTML element must have lang attribute
|
|
428
|
+
- `label` - Form elements must have labels (basic support)
|
|
429
|
+
- `button-name` - Buttons must have discernible text
|
|
430
|
+
- `link-name` - Links must have discernible text (basic support)
|
|
431
|
+
- `landmark-one-main` - Document should have one main landmark
|
|
432
|
+
- `region` - Page content should be contained by landmarks
|
|
433
|
+
- `heading-order` - Heading levels analysis (suggestions only)
|
|
434
|
+
- Duplicate role attributes cleanup
|
|
435
|
+
|
|
436
|
+
### 🔄 Future Enhancements
|
|
437
|
+
- `color-contrast` - Color contrast checking
|
|
438
|
+
- `focus-order-semantics` - Focus order validation
|
|
439
|
+
- Advanced ARIA attributes validation
|
|
440
|
+
- Table accessibility features
|
|
441
|
+
- List structure validation
|
|
442
|
+
|
|
360
443
|
## 🤝 Contributing
|
|
361
444
|
|
|
362
445
|
1. Fork the repository
|
|
@@ -371,9 +454,9 @@ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file
|
|
|
371
454
|
|
|
372
455
|
## 🆘 Support
|
|
373
456
|
|
|
374
|
-
- 📧 **Issues**: [GitHub Issues](https://github.com/
|
|
375
|
-
- 📖 **Documentation**: [GitHub Wiki](https://github.com/
|
|
376
|
-
- 💬 **Discussions**: [GitHub Discussions](https://github.com/
|
|
457
|
+
- 📧 **Issues**: [GitHub Issues](https://github.com/dangpv94/gbu-accessibility-tool/issues)
|
|
458
|
+
- 📖 **Documentation**: [GitHub Wiki](https://github.com/dangpv94/gbu-accessibility-tool/wiki)
|
|
459
|
+
- 💬 **Discussions**: [GitHub Discussions](https://github.com/dangpv94/gbu-accessibility-tool/discussions)
|
|
377
460
|
|
|
378
461
|
## 🏆 Why Choose GBU Accessibility Package?
|
|
379
462
|
|
|
@@ -383,7 +466,11 @@ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file
|
|
|
383
466
|
- ✅ **Comprehensive** - Covers all major accessibility issues
|
|
384
467
|
- ✅ **Fast & Efficient** - Batch processing with detailed reports
|
|
385
468
|
- ✅ **WCAG Compliant** - Follows accessibility standards
|
|
469
|
+
- ✅ **axe DevTools Compatible** - Fixes common axe issues
|
|
470
|
+
- ✅ **Individual Control** - Fix specific issues or everything
|
|
471
|
+
- ✅ **Safe Heading Analysis** - Suggests instead of auto-fixing
|
|
472
|
+
- ✅ **Multi-language Support** - Japanese, English, and extensible
|
|
386
473
|
|
|
387
474
|
---
|
|
388
475
|
|
|
389
|
-
Made with ❤️ by the GBU Team
|
|
476
|
+
Made with ❤️ by the GBU Team
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "gbu-accessibility-package",
|
|
3
|
-
"version": "3.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "3.1.0",
|
|
4
|
+
"description": "Comprehensive accessibility fixes for HTML files. Smart context-aware alt text generation, form labels, button names, link names, landmarks, heading analysis, and WCAG-compliant role attributes. Covers major axe DevTools issues with individual fix modes.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"bin": {
|
|
7
7
|
"gbu-a11y": "./cli.js",
|
|
@@ -36,11 +36,22 @@
|
|
|
36
36
|
"role-attributes",
|
|
37
37
|
"lang-attributes",
|
|
38
38
|
"wcag",
|
|
39
|
-
"
|
|
39
|
+
"axe",
|
|
40
|
+
"form-labels",
|
|
41
|
+
"button-names",
|
|
42
|
+
"link-names",
|
|
43
|
+
"landmarks",
|
|
44
|
+
"heading-analysis",
|
|
45
|
+
"aria-label",
|
|
40
46
|
"context-aware",
|
|
41
47
|
"smart-alt-text",
|
|
42
48
|
"accessibility-fixer",
|
|
43
|
-
"html-accessibility"
|
|
49
|
+
"html-accessibility",
|
|
50
|
+
"gbu",
|
|
51
|
+
"comprehensive",
|
|
52
|
+
"individual-fixes",
|
|
53
|
+
"backup-safe",
|
|
54
|
+
"dry-run"
|
|
44
55
|
],
|
|
45
56
|
"author": "GBU Team",
|
|
46
57
|
"license": "MIT",
|
|
@@ -59,8 +70,11 @@
|
|
|
59
70
|
"example.js",
|
|
60
71
|
"demo/",
|
|
61
72
|
"README.md",
|
|
73
|
+
"README-vi.md",
|
|
74
|
+
"CHANGELOG.md",
|
|
62
75
|
"QUICK_START.md",
|
|
63
|
-
"PACKAGE_SUMMARY.md"
|
|
76
|
+
"PACKAGE_SUMMARY.md",
|
|
77
|
+
"LICENSE"
|
|
64
78
|
],
|
|
65
79
|
"dependencies": {
|
|
66
80
|
"chalk": "^4.1.2"
|