Crate accessibility_rs

Source
Expand description

Audit html to see how it complies with WCAG standards.

accessibility-rs is a web accessibility engine that can replicate websites without a browser to get complex accessibility reports.

§How to use accessibility-rs

There are a couple of ways to use accessibility-rs:

  • Audit perform an audit against an html page.
    • audit is used to audit a web page for issues.

§Examples

A basic WCAG audit for a website:

use accessibility_rs::{audit, AuditConfig};

#[cfg(not(feature = "tokio"))]
fn main() {
    let config = AuditConfig::basic(r###"<html><body><h1>My Title</h1><input type="text" placeholder="Type me"></input><img src="tabby_cat.png"></img></body></html>"###);
    let audit = audit(config);
    println!("{:?}", audit);
}

#[cfg(all(feature = "tokio", not(feature = "spider")))]
#[tokio::main]
async fn main() {
    let config = AuditConfig::basic(r###"<html><body><h1>My Title</h1><input type="text" placeholder="Type me"></input><img src="tabby_cat.png"></img></body></html>"###);
    let audit = audit(config).await;
    println!("{:?}", audit);
}

#[cfg(feature = "spider")]
#[tokio::main]
async fn main() {
    let mut config = AuditConfig::default();
    config.url = "https://example.com".into();
    let audit = audit(config).await;
    println!("{:?}", audit);
}

Re-exports§

pub use crate::engine::audit::auditor::Auditor;
pub use crate::engine::issue::Issue;
pub use accessibility_scraper;
pub use accessibility_scraper::fast_html5ever;

Modules§

engine
the main engine for accessibility auditing.
i18n
locales for translations.

Structs§

AuditConfig
configs for the audit
ElementRef
Wrapper around a reference to an element node.
Html
An HTML tree.

Enums§

Conformance
support guidelines for auditing

Functions§

_rust_i18n_available_locales
_rust_i18n_lookup_fallback
Lookup fallback locales
_rust_i18n_translate
Get I18n text by locale and key
audit
audit a web page passing the html and css rules.