html_generator::accessibility

Function add_aria_attributes

Source
pub fn add_aria_attributes(
    html: &str,
    config: Option<AccessibilityConfig>,
) -> Result<String>
Expand description

Add ARIA attributes to HTML for improved accessibility.

This function performs a comprehensive analysis of the HTML content and adds appropriate ARIA attributes to improve accessibility. It handles:

  • Button labeling
  • Navigation landmarks
  • Form controls
  • Input elements
  • Dynamic content

§Arguments

  • html - A string slice representing the HTML content
  • config - Optional configuration for the enhancement process

§Returns

  • Result<String> - The modified HTML with ARIA attributes included

§Errors

Returns an error if:

  • The input HTML is larger than MAX_HTML_SIZE
  • The HTML cannot be parsed
  • There’s an error adding ARIA attributes