Package detail

gbu-accessibility-package

dangpv941.3kMIT3.5.0

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.

accessibility, a11y, html, automation

readme

GBU Accessibility Package

🚀 Automated accessibility fixes for HTML files - Smart, context-aware accessibility improvements with zero configuration.

npm version License: MIT Node.js Version

✨ Features

🎯 Core Accessibility Fixes

  • 🖼️ Smart Alt Text Generation - Context-aware alt attributes for images
  • 🏷️ Aria Label Support - Automatic aria-label matching alt text
  • 🌐 HTML Lang Attributes - Automatic language attribute fixes
  • 🎭 Role Attributes - WCAG-compliant role attribute management
  • 📋 Form Labels - Fix missing labels with intelligent aria-label generation
  • 🔘 Button Names - Fix empty buttons and input buttons without names
  • 🔗 Link Names - Fix empty links and detect generic link text
  • 🏛️ Landmarks - Add missing main and navigation landmarks
  • 📑 Heading Analysis & Auto-Fix - Analyze heading structure with optional auto-fix using --auto-fix-headings
  • 🎯 Nested Controls Detection - Detect and fix nested interactive controls
  • 🔍 Broken Links Detection - Detect broken links and 404 resources
  • 🧹 Duplicate Cleanup - Remove duplicate role attributes

🚀 Enhanced Alt Attribute Features (Integrated!)

  • 🔍 Comprehensive Analysis - Image type classification and quality checking built-in
  • 🎨 Diverse Alt Generation - Multiple strategies for creative alt text integrated in core
  • 🌐 Multi-language Support - Japanese, English, Vietnamese vocabulary built-in
  • 🎭 Creativity Levels - Conservative, Balanced, Creative modes
  • 🧠 Context Awareness - Brand, emotional, and technical context integration
  • 📊 Data Visualization - Specialized descriptions for charts and graphs
  • 🧹 Clean Architecture - All enhanced features integrated in a single file

🛠️ Utility Features

  • 📁 Batch Processing - Process entire directories recursively
  • 💾 Optional Backups - Create backup files when needed with --backup flag
  • 🔍 Dry Run Mode - Preview changes before applying
  • 📊 Detailed Reports - Comprehensive fix summaries
  • Individual Fix Modes - Target specific accessibility issues

🚀 Quick Start

Installation

# Global installation (recommended)
npm install -g gbu-accessibility-package

# Local installation
npm install gbu-accessibility-package

Uninstall and Reinstall

# Uninstall global package
npm uninstall -g gbu-accessibility-package

# Uninstall local package
npm uninstall gbu-accessibility-package

# Clear npm cache (recommended when having issues)
npm cache clean --force

# Reinstall latest version
npm install -g gbu-accessibility-package@latest

# Check installed version
npm list -g gbu-accessibility-package
gbu-a11y --version

# Install specific version
npm install -g gbu-accessibility-package@3.2.1

Installation Troubleshooting

# If permission errors (macOS/Linux)
sudo npm install -g gbu-accessibility-package

# If cache issues
npm cache clean --force
npm install -g gbu-accessibility-package --force

# Verify installation
which gbu-a11y
gbu-a11y --help

# Update to latest version
npm update -g gbu-accessibility-package

Basic Usage

# Comprehensive fixes (default mode)
gbu-a11y

# Preview changes (dry run)
gbu-a11y --dry-run

# Fix specific directory
gbu-a11y ./src

# Fix specific file
gbu-a11y index.html

Enhanced Alt Attribute Mode

# Enable enhanced alt attribute analysis
gbu-a11y --enhanced-alt

# Creative alt text generation with emotions
gbu-a11y --enhanced-alt --alt-creativity creative --include-emotions

# Strict quality checking
gbu-a11y --enhanced-alt --strict-alt

# English with creative mode
gbu-a11y -l en --enhanced-alt --alt-creativity creative

📖 Detailed Usage

Command Line Options

gbu-a11y [options] [directory/file]

Basic Options:
  -d, --directory <path>    Target directory (default: current directory)
  -l, --language <lang>     Language for lang attribute (default: ja)
  --backup                 Create backup files
  --no-backup              Don't create backup files (default)
  --dry-run                Preview changes without applying

Fix Modes:
  --comprehensive, --all   Run comprehensive fixes (default)
  --alt-only               Fix alt attributes + cleanup
  --lang-only              Fix HTML lang attributes + cleanup
  --role-only              Fix role attributes + cleanup
  --forms-only             Fix form labels + cleanup
  --buttons-only           Fix button names + cleanup
  --links-only             Fix link names + cleanup
  --landmarks-only         Fix landmarks + cleanup
  --headings-only          Analyze heading structure with optional auto-fix
  --auto-fix-headings      Enable automatic heading structure fixes
  --links-check            Check for broken links and 404 resources
  --cleanup-only           Only cleanup duplicate role attributes

Enhanced Alt Options:
  --enhanced-alt           Use enhanced alt attribute analysis and generation
  --alt-creativity <mode>  Alt text creativity: conservative, balanced, creative
  --include-emotions       Include emotional descriptors in alt text
  --strict-alt             Enable strict alt attribute quality checking

Help:
  -h, --help               Show help message

Examples

# Basic comprehensive fixes
gbu-a11y

# Preview all changes
gbu-a11y --dry-run

# Fix with English language
gbu-a11y -l en ./public

# Individual fix types
gbu-a11y --alt-only          # Fix alt attributes + cleanup
gbu-a11y --forms-only        # Fix form labels + cleanup
gbu-a11y --buttons-only      # Fix button names + cleanup
gbu-a11y --headings-only     # Analyze heading structure
gbu-a11y --headings-only --auto-fix-headings  # Auto-fix heading structure
gbu-a11y --links-check       # Check broken links + cleanup

# Enhanced alt attribute features
gbu-a11y --enhanced-alt                                    # Basic enhanced mode
gbu-a11y --enhanced-alt --alt-creativity creative          # Creative descriptions
gbu-a11y --enhanced-alt --include-emotions                 # Include emotional context
gbu-a11y --enhanced-alt --strict-alt                       # Strict quality checking
gbu-a11y -l en --enhanced-alt --alt-creativity creative    # English creative mode

# Combine with other options
gbu-a11y --enhanced-alt --backup ./src                     # Enhanced mode with backups
gbu-a11y --enhanced-alt --dry-run                          # Preview enhanced fixes

🎨 Enhanced Alt Attribute Features

Creativity Levels

Conservative

  • Simple, factual descriptions
  • Focus on basic functionality
  • Minimal vocabulary variation

Example: alt="Chart", alt="Logo"

Balanced (Default)

  • Context-aware descriptions
  • Moderate creativity
  • Balance between simple and detailed

Example: alt="Sales performance chart", alt="Company logo"

Creative

  • Rich, detailed descriptions
  • Emotional context integration
  • High brand and context awareness

Example: alt="Dynamic sales performance chart showing impressive 25% quarterly growth", alt="Innovative technology company logo representing digital transformation"

Image Type Classification

  • Decorative Images: Automatically detected and marked with alt=""
  • Functional Icons: Described by their action (e.g., "Open chat", "Search")
  • Data Visualizations: Include chart type, trends, and key data points
  • Complex Images: Short alt + recommendation for detailed description
  • Logos: Include brand name and "logo" keyword
  • Content Images: Context-aware descriptions based on surrounding content

Quality Checks

  • Error Level: Missing alt, empty alt for content, generic text
  • ⚠️ Warning Level: Too long/short, redundant words, filename in alt
  • ℹ️ Info Level: Optimization suggestions, consistency checks

📋 Programmatic Usage

Basic Usage

const { AccessibilityFixer } = require('gbu-accessibility-package');

const fixer = new AccessibilityFixer({
  language: 'ja',
  backupFiles: true,
  dryRun: false
});

// Fix all accessibility issues
fixer.fixAllAccessibilityIssues('./src').then(results => {
  console.log('Accessibility fixes completed:', results);
});

// Fix specific issues
await fixer.fixEmptyAltAttributes('./src');
await fixer.fixFormLabels('./src');
await fixer.fixButtonNames('./src');

Enhanced Alt Attribute Mode (Integrated)

const { AccessibilityFixer } = require('gbu-accessibility-package');

// Use AccessibilityFixer with enhanced mode (integrated)
const fixer = new AccessibilityFixer({
  language: 'en',
  enhancedAltMode: true,
  altCreativity: 'creative',
  includeEmotions: true,
  strictAltChecking: true
});

await fixer.fixEmptyAltAttributes('./src');

// All enhanced features are now integrated in AccessibilityFixer
// No need to import separate classes
const results = await fixer.fixAllAccessibilityIssues('./src');
console.log('Accessibility fixes completed with enhanced features:', results);

🎯 What Gets Fixed

Alt Attributes (Enhanced Mode)

  • Missing alt attributes → Context-aware alt text generation
  • Empty alt attributes → Smart content-based descriptions
  • Generic alt text → Specific, meaningful descriptions
  • Too long alt text → Optimized length with key information
  • Redundant words → Clean, concise descriptions
  • Data visualizations → Chart type + trends + key data

Form Accessibility

  • Missing form labels → Intelligent aria-label generation
  • Unlabeled inputs → Context-based label suggestions
  • Form structure → Proper label associations

Interactive Elements

  • Empty buttons → Action-based button names
  • Generic link text → Descriptive link purposes
  • Missing button names → Function-based descriptions

Document Structure

  • Missing lang attributes → Automatic language detection
  • Missing landmarks → Main and navigation landmarks
  • Heading structure → Analysis and auto-fix with --auto-fix-headings
    • Fix multiple h1 elements
    • Fix heading level skipping (h2 → h4)
    • Add text to empty headings
    • Fix duplicate headings
  • Nested interactive controls → Detect and fix nested controls
  • Role attributes → WCAG-compliant role assignments

Link Validation

  • Broken links → Detect HTTP 404, 500, timeout errors
  • Missing resources → Check for missing local files
  • Invalid URLs → Detect malformed URL formats
  • Slow links → Warn about timeouts and slow responses

🔧 Package Management

Check package information

# Check current version
gbu-a11y --version
npm list -g gbu-accessibility-package

# View package info
npm info gbu-accessibility-package

# Verify installation
which gbu-a11y
npm list -g | grep gbu-accessibility-package

Update package

# Check for new versions
npm outdated -g gbu-accessibility-package

# Update to latest version
npm update -g gbu-accessibility-package

# Or reinstall latest version
npm uninstall -g gbu-accessibility-package
npm install -g gbu-accessibility-package@latest

Cache management

# Verify cache
npm cache verify

# Clean cache (when having issues)
npm cache clean --force

# View cache location
npm config get cache

🧪 Testing and Demo

# Test the package
npm test

# Demo basic features
npm run demo

# Demo enhanced alt features
npm run demo-enhanced

# Demo creative alt generation
npm run demo-creative

# Test enhanced alt features
npm run test-enhanced-alt

📊 Performance

  • Basic Mode: Fast processing, suitable for large projects
  • Enhanced Mode: ~20-30% slower but 85-90% improvement in alt text quality
  • Memory Usage: +15-20% for enhanced vocabulary and analysis
  • Accuracy: 95%+ detection of accessibility issues

🌐 Language Support

  • Japanese (ja): Default language with rich vocabulary
  • English (en): Comprehensive English support
  • Vietnamese (vi): Vietnamese language support

Enhanced alt features include language-specific vocabulary and grammar rules for natural, contextually appropriate descriptions.

📚 Documentation

🤝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.

Development Setup

git clone https://github.com/dangpv94/gbu-accessibility-tool.git
cd gbu-accessibility-tool/accessibility-package
npm install
npm test

📄 License

This project is licensed under the MIT License - see the LICENSE file for details.

🙏 Acknowledgments

  • Built with accessibility best practices in mind
  • Follows WCAG guidelines
  • Inspired by the need for automated accessibility improvements
  • Community feedback and contributions

Made with ❤️ by the GBU Team

For more information, visit our GitHub repository.

changelog

Changelog

All notable changes to this project will be documented in this file.

The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.

[3.5.0] - 2025-01-08

Added

  • Enhanced Heading Structure Auto-Fix: Automatic fixing of heading hierarchy issues with --auto-fix-headings option
  • Improved Nested Controls Detection: Better detection and fixing of nested interactive controls
  • Advanced Test Cases: New comprehensive test files for heading structure and nested controls
  • Enhanced Alt Text Quality: Improved context-aware alt text generation with better vocabulary support

Enhanced

  • Heading Analysis: More comprehensive detection of heading issues including empty headings, level skipping, and duplicates
  • Interactive Controls: Better handling of complex nested control scenarios
  • Test Coverage: Expanded demo files for better testing and validation
  • Performance: Optimized processing for large files and complex HTML structures

Fixed

  • Heading Level Corrections: Automatic correction of improper heading hierarchies
  • Empty Heading Detection: Better identification and handling of empty headings
  • Control Nesting Issues: Improved resolution of nested interactive control conflicts

[3.2.0] - 2024-07-28

Added

  • Enhanced Alt Attribute Integration: Tích hợp hoàn toàn EnhancedAltChecker và EnhancedAltGenerator vào AccessibilityFixer
  • Broken Links Detection: Tính năng phát hiện liên kết bị hỏng và tài nguyên 404
  • Clean Architecture: Tất cả tính năng enhanced được tích hợp trong một file duy nhất
  • Improved Performance: Giảm overhead từ việc import nhiều module riêng biệt
  • Simplified API: Không cần import các class enhanced riêng biệt

Changed

  • BREAKING: EnhancedAltChecker và EnhancedAltGenerator không còn là class riêng biệt
  • Integrated Features: Tất cả tính năng enhanced alt đã được tích hợp vào AccessibilityFixer
  • Cleaner Codebase: Loại bỏ các file enhanced riêng lẻ để có kiến trúc gọn gàng hơn
  • Updated Documentation: README và README-vi được cập nhật để phản ánh kiến trúc mới

Migration Guide

  • For most users: Không cần thay đổi gì - tất cả tính năng vẫn hoạt động như cũ
  • For programmatic usage: Chỉ cần import AccessibilityFixer, không cần import EnhancedAltChecker/Generator riêng
  • Enhanced features: Vẫn có sẵn thông qua các config options trong AccessibilityFixer

[3.1.0] - 2024-07-25

Changed

  • BREAKING: Default behavior now no backup files for faster processing
  • Backup is now optional: Use --backup flag when you need backup files
  • Performance improvement: Faster processing by default without backup creation
  • CLI help updated: Reflects new default behavior
  • Documentation updated: README and README-vi updated with new backup behavior

Migration Guide

  • No action needed for most users - you get faster processing by default
  • If you want backup files: Add --backup flag to your commands
  • Old behavior: gbu-a11y (created backups) → New behavior: gbu-a11y --backup
  • Scripts using --no-backup: Can remove the flag (now default behavior)

[3.0.0] - 2024-07-25

Added

  • Form Labels: Automatic fixing of missing form labels with intelligent aria-label generation
  • Button Names: Fix empty buttons and input buttons without names
  • Link Names: Fix empty links and detect generic link text
  • Landmarks: Add missing main and navigation landmarks
  • Heading Analysis: Analyze heading structure with suggestions (no auto-fix for safety)
  • Individual Fix Modes: New CLI options for targeted fixes:
    • --forms-only - Fix form labels + cleanup
    • --buttons-only - Fix button names + cleanup
    • --links-only - Fix link names + cleanup
    • --landmarks-only - Fix landmarks + cleanup
    • --headings-only - Analyze heading structure only
  • Comprehensive Mode: Now includes 9 steps of accessibility fixes
  • Language Support: Japanese labels for form inputs and buttons
  • axe DevTools Coverage: Addresses major axe accessibility issues
  • Advanced Demo: New advanced-test.html showcasing all features

Changed

  • BREAKING: Comprehensive fixes now default mode (was basic fixes)
  • All individual modes now include cleanup step for consistency
  • Enhanced CLI: Better help messages and examples
  • Improved Reporting: More detailed issue analysis and suggestions

Enhanced

  • Alt Text Generation: Now also adds matching aria-label attributes
  • Role Attributes: Enhanced picture/img handling
  • Context Analysis: Improved smart text generation
  • Error Handling: Better error messages and recovery

[2.1.0] - 2024-07-24

Added

  • Backup Management: Improved backup options with --backup and --no-backup
  • Consistent Messaging: Unified completion messages across all modes
  • Cleanup Scripts: npm script for removing backup files

Changed

  • Default Behavior: Comprehensive fixes as default mode
  • Backup Notifications: Clear messaging about backup status

[2.0.0] - 2024-07-24

Added

  • Comprehensive Mode: All fixes including cleanup as default
  • Basic Mode: --basic flag for fixes without cleanup

Changed

  • BREAKING: Default mode now runs comprehensive fixes
  • CLI Behavior: Simplified command structure

[1.6.0] - 2024-07-24

Added

  • Backup Options: Explicit --backup and --no-backup flags
  • Helper Functions: Consistent completion messaging
  • Safety Features: Enhanced backup management

[1.5.0] - 2024-07-24

Added

  • Aria Label Support: Automatic aria-label generation matching alt text
  • Picture Handling: Move role from <picture> to <img> elements
  • Enhanced Reporting: Comprehensive issue analysis

[1.4.0] - 2024-07-24

Added

  • Individual Fix Options: Separate modes for different fix types
  • Enhanced CLI: More granular control over fixes

[1.3.0] - 2024-07-24

Added

  • Individual Fix Modes: --alt-only, --lang-only, --role-only
  • Enhanced Documentation: Updated README with new features

[1.2.0] - 2024-07-24

Added

  • Role Attributes: Comprehensive role attribute management
  • Duplicate Cleanup: Remove duplicate role attributes
  • Context-Aware Alt Text: Intelligent alt text generation

[1.1.0] - 2024-07-24

Added

  • HTML Lang Attributes: Automatic language attribute fixes
  • Backup System: Automatic backup file creation

[1.0.0] - 2024-07-24

Added

  • Initial Release: Basic alt attribute fixes
  • CLI Interface: Command-line tool
  • Dry Run Mode: Preview changes before applying
  • Batch Processing: Process multiple files and directories

Migration Guides

Upgrading to 3.0.0

  • No breaking changes for most users - you get better default behavior
  • New features available - try --forms-only, --buttons-only, etc.
  • Comprehensive mode is now default - includes all fixes + cleanup
  • Heading analysis is safe - only provides suggestions, no auto-fixes

Upgrading to 2.0.0

  • Default behavior changed - now runs comprehensive fixes by default
  • Use --basic flag if you want the old default behavior
  • All modes now include cleanup for better consistency

For more details about any release, see the GitHub Releases page.