gbu-accessibility-package 1.6.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 +201 -115
- package/cli.js +174 -77
- package/demo/advanced-test.html +44 -0
- package/demo/advanced-test.html.backup +44 -0
- package/demo/comprehensive-test.html +21 -0
- package/demo/comprehensive-test.html.backup +21 -0
- package/lib/fixer.js +678 -3
- package/package.json +24 -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
|