15 HTML utilities
Relatude.CMS.Utils has a forward-only HTML scanner and a rewriter built on it. Neither builds a
DOM or allocates per token, so both are cheap enough to run on every response.
- Reading — HtmlReader is a ref struct over a ReadOnlySpan<char>. Each call to Read() moves to the next token, which has: a Kind: Text, StartTag, EndTag, Comment, Doctype, CData or ProcessingInstruction; its Name, its source text…
- Rewriting — HtmlRewriter.Rewrite copies HTML through and splices in only what a handler changes. A handler can rewrite attribute values, insert markup before a tag, and replace text.