html-conform
A pure Rust library for HTML5 specification conformance checking — comparable in precision and output to the Nu Html Checker (vnu), but without a JVM, subprocesses, or HTTP network requests. Embeddable directly into any Rust application, CLI, or web service.
🎯 Conformance Profile & Metrics
html-conform is validated continuously against the official W3C/vnu differential test suite (4,655 test fixtures vendored from validator/validator@388cb36).
- Precision Floor: 0 False Positives (
BASELINE_FALSE_POSITIVE = 0) — zero false alarms across all 4,655 test cases. - Accuracy: 98.8 % overall accuracy across the entire corpus (3,691 True Positives, 909 True Negatives).
- Residual False Negatives: 55 / 4,655 — 43 need real tree-construction-error tracking during parsing (a separate
html5-parserchange, not expressible by inspecting the finished tree), 5 need a full 2D table grid model withcolspan/rowspanoverlap detection (not reasonably expressible in the Schematron/XPath 1.0 layer), and 7 are smaller individually-researched gaps (an ARIA tab/tabpanel heuristic,dlduplicate-term edge cases, ruby markup advisories, inline CSS property validation). None of these are false alarms — each is a documented, deliberate limitation, not a silent gap.
🔍 Validation Layers
html-conform combines five independent finding sources into a single, unified CheckReport:
- HTML5 Tree Construction (
parser.html5) — Spec-compliant, error-tolerant tree parsing viahtml5-parser. Emits tokenizer & DOCTYPE parse findings with line, column, and byte offset locations. - Grammar & Content Model (
schema.html5) — Validation against the full vendored W3C RELAX NG schema (relax-ng), including SVG 1.1 and MathML 3 subtrees. - Custom Datatype Micro-Syntaxes (
w:*) — Full spec-compliant datatype validation for 50 custom W3C attribute microsyntaxes (w:image-candidate-stringsforsrcset,w:content-security-policy,w:media-query,w:datetime,w:iri-ref, BCP 47 language tags, etc.). - Schematron Co-Constraints (
rules/*.sch) — High-precision assertion rules viaschematron-engineandxpath-eval(ARIA 1.2 constraints, structural HTML restrictions, heading hierarchy, link/script attribute combinations). - Script & CSP Validation (
scripts.import-map,scripts.speculation-rules,csp.meta-enforcement) — Dedicated JSON validation for<script type="importmap">/<script type="speculationrules">contents, and Content Security Policy (<meta http-equiv="Content-Security-Policy">) enforcement against inline scripts/styles viacsp-parse.
🚀 Usage
Add html-conform to your Cargo.toml:
[]
= "0.1.0"
Basic Check
use check;
Fine-Grained Options
use ;
let options = CheckOptions ;
let report = check_with_options.unwrap;
🏗️ Architecture
HTML Source String / Document
│
▼
┌─────────────────────┐
│ 1. html5-parser │ WHATWG Tree Construction
└─────────────────────┘
│
┌──────────────────┼──────────────────┐
▼ ▼ ▼
┌──────────────────┐ ┌───────────────┐ ┌──────────────────┐
│ 2. relax-ng │ │ 3. Schematron │ │ 4. JSON / CSP │
│ (Schema & │ │ (Co-Con- │ │ (Import-Maps, │
│ Datatypes) │ │ straints) │ │ Speculation, │
└──────────────────┘ └───────────────┘ │ CSP) │
│ │ └──────────────────┘
└──────────────────┼──────────────────┘
│
▼
┌───────────────────────┐
│ CheckReport │
│ Vec<Finding> │
└───────────────────────┘
🔄 Maintenance & Refinement Loops
html-conform enforces quality through two structured maintenance loops:
- Loop A (Schema Sync): Mechanical updates when W3C RELAX NG schemas or vnu upstream specifications update (
xtask/vendor-corpus.sh). - Loop B (Assertion Refinement Loop): Iterative refinement of Schematron rules and datatype checkers against the 4,655-fixture differential test suite, strictly maintaining the 0 False Positive floor.
📜 License & Attributions
- Code: MIT License — see
LICENSEorLICENSES/MIT.txt. This is a REUSE-compliant project. - Third-Party & Vendored Assets: the RELAX NG schema and test corpus (
schema/,tests/corpus/) are vendored fromvalidator/validatorunder the MIT License, not authored by this project — seeTHIRD-PARTY-NOTICES.md.