#[macro_use]
extern crate lazy_static;
mod engine;
mod i18n;
mod utils;
pub use crate::engine::audit::auditor::Auditor;
pub use crate::engine::issue::Issue;
pub use accessibility_scraper::ElementRef;
#[derive(Default)]
pub struct AuditConfig {
pub html: &'static str,
pub css: &'static str,
pub bounding_box: bool,
pub locale: &'static str,
}
impl AuditConfig {
pub fn new(
html: &'static str,
css: &'static str,
bounding_box: bool,
locale: &'static str,
) -> Self {
AuditConfig {
html,
css,
bounding_box,
locale,
}
}
pub fn basic(html: &'static str) -> Self {
AuditConfig {
html,
..Default::default()
}
}
}
pub fn audit(config: &AuditConfig) -> Vec<Issue> {
let document = accessibility_scraper::Html::parse_document(config.html);
let mut nth_index_cache = selectors::NthIndexCache::from(Default::default());
let auditor = Auditor::new(
&document,
&config.css,
engine::styles::css_cache::build_matching_context(&mut nth_index_cache),
config.bounding_box,
);
engine::audit::wcag::WCAG3AA::audit(&auditor)
}