RecursiveAI.OneHtml
1.1.0
dotnet add package RecursiveAI.OneHtml --version 1.1.0
NuGet\Install-Package RecursiveAI.OneHtml -Version 1.1.0
<PackageReference Include="RecursiveAI.OneHtml" Version="1.1.0" />
<PackageVersion Include="RecursiveAI.OneHtml" Version="1.1.0" />
<PackageReference Include="RecursiveAI.OneHtml" />
paket add RecursiveAI.OneHtml --version 1.1.0
#r "nuget: RecursiveAI.OneHtml, 1.1.0"
#:package RecursiveAI.OneHtml@1.1.0
#addin nuget:?package=RecursiveAI.OneHtml&version=1.1.0
#tool nuget:?package=RecursiveAI.OneHtml&version=1.1.0
RecursiveAI.OneHtml
Parse HTML exactly as a browser does, query it, compute styles, and edit HTML and CSS without disturbing a byte the edit didn't touch. Pure C# on the .NET base class library, safe code only, NativeAOT- and trim-compatible, net10.0.
- Encoding and parser. The WHATWG Encoding Standard (BOM, transport
Content-Type,<meta>prescan) and the HTML tokenizer and tree construction, including the adoption agency algorithm, foster parenting,<template>, foreign content and fragment parsing. Parse errors are recorded as the spec says, never thrown. - DOM as snapshots. A
Documentis an immutable arena;Nodeis areadonly structhandle. Every node knows its byte range in the original, and parser-inserted nodes are marked. - Selectors Level 4 compiled for repeated use, and locators that are checked to match exactly their target.
- CSS. CSS Syntax parsing with source maps, a property table generated from the CSS specifications, and a cascade for every known property (layers,
!important,var(), shorthands, media and supports conditions) under aStyleContextthat holds the viewport, media features and one focus or hover state. - Lossless editing.
doc.Apply(edits)splices bytes only where an edit landed, re-parses the output and compares it with the expected tree, and returns a new snapshot plus a change set. Edits can be saved as versioned JSON and replayed on another copy of the page; a replay that cannot find exactly one matching target reportsstaleorambiguousand never guesses.
using 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();
Styles under a context:
using RecursiveAI.OneHtml.Css;
Document doc = Document.Parse("<style>a { color: red } a:focus { color: blue }</style><a href=/x>x</a>");
Node link = doc.Root.QuerySelector("a");
DocumentStyles styles = DocumentStyles.Create(doc);
string normal = styles.GetStyle(link).GetPropertyValue("color");
string focused = styles.WithContext(StyleContext.Default.WithFocus(link)).GetStyle(link).GetPropertyValue("color");
The library never reads files or the network, runs no script and does no layout. Linked stylesheets are supplied by the caller. Hostile-input limits (depth, attribute count, input size, stylesheet and selector complexity) are checked before the work they guard.
More
- Family overview, conformance numbers and benchmarks: README.
- Behaviour documents: docs/.
- Third-party material and licences: THIRD-PARTY-NOTICES.md.
Licensed under either of MIT or Apache-2.0 at your option. Copyright Recursive AI, LLC.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- No dependencies.
NuGet packages (1)
Showing the top 1 NuGet packages that depend on RecursiveAI.OneHtml:
| Package | Downloads |
|---|---|
|
RecursiveAI.OneHtml.Accessibility
The accessibility tree for OneHtml documents, computed without a browser from WAI-ARIA 1.2, HTML-AAM and AccName 1.2 with Chromium choices documented: roles, names, states, relations, reading view, navigation lists, diffs and incremental updates. |
GitHub repositories
This package is not used by any popular GitHub repositories.