Universe

Semantic accessibility preflight checks for Typst documents aligned with WCAG 2.2 and ISO 14289-1 (PDF/UA-1 / Matterhorn Protocol).

docbeacon inspects your document’s live introspection tree (heading, figure, link, and table elements) during compilation to surface common accessibility defects before final PDF export:

  • UA-HDG-SKIP / UA-HDG-START / UA-HDG-EMPTY: Skipped heading levels (e.g., = H1 jumping directly to === H3), documents starting deeper than level 1, or empty headings (Matterhorn 14-003, 14-007).
  • UA-FIG-ALT: Figures missing an alt description for screen readers (WCAG 1.1.1 / Matterhorn 13-004).
  • UA-LNK-EMPTY / UA-LNK-VAGUE / UA-LNK-RAWURL: Empty links, ambiguous labels such as "click here" or "read more", and raw HTTP(S) URLs used as anchor text (WCAG 2.4.4).
  • UA-TBL-HDR: Data tables missing table.header(...) declarations (Matterhorn 15-005).

Quick Start

Wrap your draft document with the preflight show rule to render a scorecard at the top or bottom of your document:

#import "@preview/docbeacon:0.1.0": preflight

#show: preflight.with(
  enabled: true,
  placement: "bottom",
  strict: false,
)

= Annual Report

== Executive Summary

#figure(
  rect(width: 8cm, height: 2cm),
  alt: "Quarterly revenue bar chart comparing Q1 through Q4.",
  caption: [Quarterly revenue overview.],
)

See examples/basic.typ for a complete runnable document.

CI / Strict Mode

Set strict: true (for example via sys.inputs) to fail typst compile whenever an error-severity accessibility violation (UA-HDG-SKIP, UA-HDG-EMPTY, UA-FIG-ALT, UA-LNK-EMPTY) is detected:

#import "@preview/docbeacon:0.1.0": preflight

#let ci = sys.inputs.at("strict-a11y", default: "false") == "true"
#show: preflight.with(enabled: not ci, strict: ci)

Then run:

typst compile --input strict-a11y=true main.typ

API Reference

preflight(body, enabled: true, placement: "bottom", strict: false, show-when-clean: true, ..options)

Show-rule helper that renders an audit-banner ("top" or "bottom") and optionally aborts compilation when strict: true and error-level findings exist. Disable it cleanly for production builds with enabled: false.

audit-banner(title: "Document Accessibility Preflight", show-when-clean: true, ..options)

Standalone block displaying a color-coded PASS / WARN / FAIL scorecard and an itemized table of rule IDs, page numbers, severities, and remediation hints.

collect-findings(..options)

Context function returning an array of dictionaries (rule, severity, page, element, message) for custom reporting:

  • check-headings (bool, default true)
  • require-h1-start (bool, default true)
  • check-figures (bool, default true)
  • check-links (bool, default true)
  • check-tables (bool, default true)
  • vague-link-labels (array of str, default ("click here", "here", "read more", "more", "link", "url", "website"))

License

Released under the MIT License.