Module accessibility

Source
Expand description

Accessibility-related functionality for HTML processing.

This module provides comprehensive tools for improving HTML accessibility through:

  • Automated ARIA attribute management
  • WCAG 2.1 compliance validation
  • Accessibility issue detection and correction

§WCAG Compliance

This module implements checks for WCAG 2.1 compliance across three levels:

  • Level A (minimum level of conformance)
  • Level AA (addresses major accessibility barriers)
  • Level AAA (highest level of accessibility conformance)

For detailed information about WCAG guidelines, see: https://www.w3.org/WAI/WCAG21/quickref/

§Limitations

While this module provides automated checks, some accessibility aspects require manual review, including:

  • Semantic correctness of ARIA labels
  • Meaningful alternative text for images
  • Logical heading structure
  • Color contrast ratios

§Examples

use html_generator::accessibility::{add_aria_attributes, validate_wcag, WcagLevel};

use html_generator::accessibility::AccessibilityConfig;
fn main() -> Result<(), Box<dyn std::error::Error>> {
    let html = r#"<button>Click me</button>"#;

    // Add ARIA attributes automatically
    let enhanced_html = add_aria_attributes(html, None)?;

    // Validate against WCAG AA level
    let config = AccessibilityConfig::default();
    validate_wcag(&enhanced_html, &config, None)?;

    Ok(())
}

Modules§

constants
Constants used throughout the accessibility module
utils
Utility functions for accessibility checks

Structs§

AccessibilityConfig
Color contrast requirements for different WCAG levels
AccessibilityReport
A comprehensive accessibility check result
Issue
Structure representing an accessibility issue found in the HTML

Enums§

Error
Enum to represent possible accessibility-related errors.
IssueType
Types of accessibility issues that can be detected
WcagLevel
WCAG Conformance Levels

Functions§

add_aria_attributes
Add ARIA attributes to HTML for improved accessibility.
validate_wcag
Validate HTML against WCAG guidelines with detailed reporting.

Type Aliases§

Result
Result type alias for accessibility operations.