onehtml
HTML and CSS for .NET, in pure C#. Parse HTML the way a browser does, edit it without disturbing a byte the edit didn’t touch, and check pages for accessibility without a browser.
A quick look
Parse, query and edit. An edit changes only the bytes it touches, the result is re-parsed and verified, and the old snapshot stays valid.
How editing worksusing RecursiveAI.OneHtml; using RecursiveAI.OneHtml.Editing; Document doc = Document.Parse("<p>Hello <a href=/x>world</a>"); Node link = doc.Root.QuerySelector("a[href]"); EditResult edit = doc.Apply(new[] { Edit.SetAttribute(link, "title", "A link") }); byte[] output = edit.Document!.ToLosslessBytes();
What it does
Parses like a browser
The WHATWG parser: encoding sniffing, the tokenizer and every insertion mode. It passes the html5lib tokenizer and tree-construction tests.
Edits that leave the rest alone
Lossless editing of HTML, inline styles and stylesheets. Untouched bytes stay identical, and every result is re-parsed and verified.
The accessibility tree Chromium exposes
WAI-ARIA 1.2, HTML-AAM and AccName 1.2, with Chromium’s choices written down. A reading view and navigation lists show what a screen-reader user meets.
Accessibility checks without a browser
One rule catalogue covering the WCAG success criteria, suggested edits where exactly one fix exists, and axe-compatible and SARIF 2.1.0 output.
2.74× AngleSharp’s parsing speed
Parsing a 100-page sample of a crawled corpus from bytes, end to end, takes 125.0 ms per sweep, against 341.7 ms for AngleSharp 1.8.6 and 292.8 ms for HtmlAgilityPack 1.13.1. Measured with BenchmarkDotNet on .NET 10.
The method and harnessThe packages
- RecursiveAI.OneHtml
The HTML parser, the DOM as immutable snapshots with a source map, Selectors Level 4, a CSS parser, the cascade for every known property, and lossless editing of HTML and CSS.
- .Accessibility
RecursiveAI.OneHtml.builds the accessibility tree, recomputes it after edits, and adds a reading view, navigation lists and tree diffs.Accessibility - .Validation
RecursiveAI.OneHtml.checks pages against WCAG 2.0, 2.1 and 2.2 AA profiles and every W3C-approved ACT rule, with native JSON, axe-compatible JSON and SARIF output.Accessibility. Validation - Conformance
All 37 approved ACT rules implemented with 0 failing cases. A round trip with no edits is byte-identical on 18,330 of 18,330 corpus pages and stylesheets.
- Safe by design
Every input is treated as hostile. The libraries never read files or the network, and scripts are inert text.
- Version
1.0.0. All three packages share one version.
- .NET
.NET 10. NativeAOT and trimming are supported, with no
unsafecode. MIT or Apache-2.0.