auditmysite 1.3.1

Resource-efficient WCAG 2.1 Accessibility Checker in Rust
Documentation
use super::*;

pub(in crate::output::pdf) fn render_html_conform(
    mut builder: renderreport::engine::ReportBuilder,
    hc: &HtmlConformPresentation,
    is_first: bool,
    i18n: &I18n,
) -> renderreport::engine::ReportBuilder {
    let title = i18n.t("section-html-conform");
    // Deliberately not `first_sentence(&hc.interpretation)`: that generic,
    // score-band-derived text says "Kritisch/Critical" for a 0 score, which
    // is exactly the misleading framing this module needs to avoid (see the
    // ScoreCard comment below). Mirrors Dark Mode's bespoke takeaway (#577).
    let takeaway = if hc.checked {
        i18n.t("pdf-html-conform-takeaway")
    } else {
        i18n.t("pdf-html-conform-not-checked")
    };
    builder = super::module_chapter_opener(builder, &title, &takeaway, is_first);

    if !hc.checked {
        return builder.add_component(Label::new(i18n.t("pdf-html-conform-not-checked")));
    }

    // Score-neutral with a known false-positive gap (RDFa/Open-Graph
    // attribute unawareness in the vendored HTML5 schema, see
    // src/audit/normalized.rs) -- unlike every other module's ScoreCard,
    // this deliberately does NOT use `score_band_label`'s Excellent/Good/
    // …/Critical compliance language (a page with standard `og:` meta tags
    // would otherwise show a flat, unqualified "Critical" 0/100 for a false
    // positive). Mirrors the Dark Mode ScoreCard's precedent (#577) for a
    // score-neutral, non-compliance-language presentation.
    builder = builder
        .add_component(
            ScoreCard::new(super::module_score_caption(i18n), hc.score)
                .with_description(i18n.t("label-limited-reliability"))
                .with_thresholds(75, 40),
        )
        .add_component(
            Label::new(i18n.t("pdf-html-conform-heuristic-note"))
                .with_size("10.5pt")
                .with_color(crate::output::pdf::design::tokens::NEUTRAL),
        )
        .add_component(module_customer_context(
            i18n,
            "html_conform",
            hc.score,
            &hc.interpretation,
        ));

    builder = builder.add_component(
        MetricStrip::new(vec![
            MetricStripItem::new(
                i18n.t("pdf-html-conform-errors"),
                hc.error_count.to_string(),
            )
            .with_accent("#dc2626"),
            MetricStripItem::new(
                i18n.t("pdf-html-conform-warnings"),
                hc.warning_count.to_string(),
            )
            .with_accent("#d97706"),
            MetricStripItem::new(i18n.t("pdf-html-conform-info"), hc.info_count.to_string())
                .with_accent("#2563eb"),
        ])
        .compact(),
    );

    if hc.error_count == 0 {
        builder = builder.add_component(clean_section_note(i18n));
    }

    if !hc.findings.is_empty() {
        let mut table = AuditTable::new(vec![
            TableColumn::new(i18n.t("pdf-html-conform-rule")),
            TableColumn::new(i18n.t("pdf-html-conform-severity")),
            TableColumn::new(i18n.t("pdf-html-conform-message")),
            TableColumn::new(i18n.t("pdf-html-conform-location")),
        ])
        .with_title(&title);
        for (rule_id, severity, message, location) in &hc.findings {
            table = table.add_row(vec![
                rule_id.as_str(),
                severity.as_str(),
                message.as_str(),
                location.as_str(),
            ]);
        }
        builder = builder.add_component(table);
    }

    builder
}