html_generator::accessibility

Function validate_wcag

source
pub fn validate_wcag(html: &str) -> Result<()>
Expand description

Validate HTML against WCAG (Web Content Accessibility Guidelines).

This function performs various checks to validate the HTML content against WCAG standards, such as ensuring all images have alt text, proper heading structure, and more.

§Arguments

  • html - A string slice that holds the HTML content.

§Returns

  • Result<()> - An empty result if validation passes, otherwise an error.

§Errors

This function will return an error if:

  • The input HTML is larger than MAX_HTML_SIZE.
  • The HTML fails to meet WCAG guidelines.

§Examples

use html_generator::accessibility::validate_wcag;

let html = r#"<img src="image.jpg" alt="A descriptive alt text"><h1>Title</h1><h2>Subtitle</h2>"#;
let result = validate_wcag(html);
assert!(result.is_ok());