# Parserino: Fast HTML5 Parser and DOM Manipulation for D
Parserino is a high-performance HTML5 parser and DOM manipulation library for the D programming language, written in pure D (no C dependencies; born as a D port of lexbor, from which the tree construction is derived). Names and behaviour follow the DOM, HTML and Selectors 4 standards.
## Core Concepts
- **Document**: The main entry point for parsing and managing HTML content.
- **Node**: Any node of the tree (element, text, comment, doctype, document, fragment).
- **Element**: A node that is an element; it adds attributes, `innerHTML`, `matches`, ... It converts implicitly to `Node`; `node.asElement` goes back (invalid if the node isn't an element).
- **Show**: Navigation methods take a template filter of node kinds (as DOM `whatToShow`): `children!(Show.All)`, `descendants!(Show.Comment)`, `firstChild!(Show.Text)`. The default is `Show.Element`, and then the result is an `Element`.
- **Lazy Ranges**: Search and navigation ranges (`byTagName`, `bySelector`, `children`, `descendants`, ...) are lazy bidirectional struct ranges (`retro` gives reverse document order).
- **Lazy Parsing**: `Document(html, Parsing.Lazy)` builds the tree only as far as the queries need (`doc.byClass("x").take(3)` stops early). Results are identical to a full parse.
- **Errors**: searches and navigation return an invalid node (`== null`) or an empty range when nothing is found; invalid operations throw `ParserinoException`.
- **Memory**: `Document` is reference counted; each `Node` keeps its document alive. Removed nodes stay valid. Getters return `string` copies; `...View` variants return slices of the document memory.
## Installation & Basic Usage
Add `parserino` to your `dub.json` or `dub.sdl`.
```d
import parserino;
void main() {
auto doc = Document("
Hello World!
");
assert(doc.body.firstChild.textContent == "Hello World!");
}
```
## API Reference
### Document
- `this(string html, Parsing parsing = Parsing.Eager, size_t chunkSize = DefaultChunkSize)`, `this(string html, ParseOptions options)`: Parse; `ParseOptions` has `parsing`, `chunkSize`, `scripting`.
- `this(Snapshot)`, `snapshot`: A compact copy of the tree; `Document(snap)` rebuilds a document without parsing.
- `ctDocument!html`: Parsed at compile time; each call returns a new document rebuilt from the stored tree.
- `dup`: A deep copy.
- `finishParsing()`, `isParsing`, `bytesParsed`: Control and inspect lazy parsing.
- `documentElement`, `head`, `body` (the `