// src/examples/accessibility_example.rs #![allow(missing_docs)] use html_generator::{ accessibility::AccessibilityError, accessibility::{add_aria_attributes, validate_wcag}, }; /// Entry point for the html-generator accessibility handling examples. /// /// This function runs various examples demonstrating error creation, conversion, /// and handling for different scenarios in the html-generator library. /// /// # Errors /// /// Returns an error if any of the example functions fail. fn main() -> Result<(), Box> { println!("\n๐Ÿงช html-generator Accessibility Examples\n"); aria_attribute_error_example()?; wcag_validation_error_example()?; html_processing_error_example()?; html_too_large_error_example()?; malformed_html_error_example()?; println!("\n๐ŸŽ‰ All accessibility examples completed successfully!"); Ok(()) } /// Demonstrates handling of invalid ARIA attribute errors. fn aria_attribute_error_example() -> Result<(), AccessibilityError> { println!("๐Ÿฆ€ Invalid ARIA Attribute Example"); println!("---------------------------------------------"); let invalid_html = r#"
Content
"#; let result = add_aria_attributes(invalid_html); match result { Ok(_) => { println!( " โŒ Unexpected success in adding ARIA attributes" ) } Err(e) => { println!( " โœ… Successfully caught Invalid ARIA Attribute Error: {}", e ); } } Ok(()) } /// Demonstrates handling of WCAG validation errors. fn wcag_validation_error_example() -> Result<(), AccessibilityError> { println!("\n๐Ÿฆ€ WCAG Validation Error Example"); println!("---------------------------------------------"); let invalid_html = r#""#; // Missing alt text match validate_wcag(invalid_html) { Ok(_) => { println!( " โŒ Unexpected success in passing WCAG validation" ) } Err(e) => { println!( " โœ… Successfully caught WCAG Validation Error: {}", e ); } } Ok(()) } /// Demonstrates handling of HTML processing errors. fn html_processing_error_example() -> Result<(), AccessibilityError> { println!("\n๐Ÿฆ€ HTML Processing Error Example"); println!("---------------------------------------------"); let malformed_html = "