Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/trikko/parserino

A super-fast html5 parser and DOM editor, for D
https://github.com/trikko/parserino

dlang dlanguage dom html html5 parser

Last synced: about 1 month ago
JSON representation

A super-fast html5 parser and DOM editor, for D

Awesome Lists containing this project

README

        

# parserino [![Build & Test](https://github.com/trikko/parserino/actions/workflows/d.yml/badge.svg)](https://github.com/trikko/parserino/actions/workflows/d.yml)
* HTML5 parser based on [Lexbor](https://github.com/lexbor/lexbor)
* Super-fast parsing & dom editing
* Lazy ranges to browse dom faster.
* Every method is unit-tested on Linux, MacOS, Windows

# documentation
All docs are available [here](https://trikko.github.io/parserino/)

# how it works

Check also the [examples](https://github.com/trikko/parserino/tree/master/examples) folder

```d
import parserino;

void main()
{
// Parserino will fix your html5
Document doc = "my html";
assert(doc.toString() == "my html");

// Set a title for your page
doc.title = "Hello world";
assert(doc.toString() == "Hello worldmy html");

// Append a html fragment
doc.body.appendChild(`
first


second

`.asFragment // without .asFragment pure text is appended
);

// Create and fill an html element
auto newElement = doc.createElement("a");
newElement.setAttribute("href", "third.html");
newElement.innerText("third");
doc.body.appendChild(newElement);

// You can use selector to select an element
doc
.bySelector("div a") // Select all inside a


.frontOrThrow // Take the first element of the range or throw an exception
.innerText="changed!"; // Change the inner text

assert(doc.body.byId("tochange").innerText == "changed!");
}
```