#tree #css-selectors #web #binding #style #elements

accessibility-tree

Accessibility tree binding CSS styles and vectors to elements. Used mainly for accessibility-rs crate.

12 releases

0.0.12 Mar 29, 2024
0.0.11 Mar 25, 2024
0.0.6 Feb 15, 2024
0.0.5 Oct 23, 2023

#24 in Accessibility

Download history 77/week @ 2024-02-07 224/week @ 2024-02-14 74/week @ 2024-02-21 87/week @ 2024-02-28 126/week @ 2024-03-06 44/week @ 2024-03-13 529/week @ 2024-03-20 273/week @ 2024-03-27 40/week @ 2024-04-03

842 downloads per month
Used in accessibility-rs

MIT/Apache

465KB
7.5K SLoC

accessibility-rs

The Rust web accessibility engine.

Usage

[dependencies]
accessibility-rs = "^0.0.59"
use accessibility_rs::{audit, AuditConfig};

fn main() {
  let html = r###"<html lang="en">
      <body>
          <a href="routes.html">
              <img src="topo.gif">
              Golf
          </a>
      </body>
  </html>"###;
  let css = "";
  // pass in raw html, optional css, bounding box clips, and locale for audit
  let audit = accessibility_rs::audit(&AuditConfig::new(&html, &css, false, "en"));
  println!("{:?}", audit);
}

With the Tokio runtime.

[dependencies]
accessibility-rs = { version = "^0.0.59", features = ["tokio"]}
use accessibility_rs::{audit, AuditConfig};
use tokio;

#[tokio::main]
async fn main() {
  let html = r###"<html lang="en">
      <body>
          <a href="routes.html">
              <img src="topo.gif">
              Golf
          </a>
      </body>
  </html>"###;
  let css = "";
  // pass in raw html, optional css, bounding box clips, and locale for audit
  let audit = accessibility_rs::audit(&AuditConfig::new(&html, &css, false, "en")).await;
  println!("{:?}", audit);
}

With the Spider full website crawling.

[dependencies]
accessibility-rs = { version = "^0.0.61", features = ["spider"]}
use accessibility_rs::{audit, AuditConfig};
use tokio;

#[tokio::main]
async fn main() {
  let audit = accessibility_rs::audit(&AuditConfig::new_website(&"https://choosealicense.com".into())).await;
  println!("{:?}", audit);
}

Documentation

Module documentation with examples.

Features

  1. Accurate web accessibility WCAG audits.
  2. Incredibly fast nanosecond audits.
  3. Ideal shapes for audits that scale.
  4. Shortest path CSS selectors for elements.
  5. i18n support for multiple languages.
  6. Re-creating layout tree to get element position coordinates.
  7. Crawling full websites lightning-fast using spider.

Benchmarks

audit-speed/core/audit: small html (4k iterations)
time: [55.689 µs 56.246 µs 57.110 µs]
audit-speed/core/audit: medium html (4k iterations)
time: [824.07 µs 830.30 µs 839.37 µs]
audit-speed/core/audit: large html (4k iterations)
time: [1.1206 ms 1.1260 ms 1.1321 ms]
audit-speed/core/audit: spider audit html (4k iterations)
time: [263.33 ms 266.55 ms 269.93 ms]

Examples

  1. Wasm example view kayle_innate.
  2. Example integrating with a headless browser.

Crate Features

  1. tokio: Enable tokio async runtime handling. Recommended for high freq server usage.
  2. rayon: Parallelism with rayon. (Expensive test future handling)
  3. rayon_wasm: Enable the wasm runtime for rayon.
  4. spider: Crawl entire websites using spider. Full website audits of 100-1,000 pages within milliseconds.

Contributing

To help improve the rules the following needs to be done:

  1. Add the rule to the tracking list - you can use the standards list and mappings here for help.
  2. Add the logic of handling the rule to wcag_rule_map and the techniques.
  3. Add unit test.

License

This project is licensed under either of

Dependencies

~6–14MB
~153K SLoC