parserino ~master
Super-fast html5 parser
To use this package, run the following command in your project's root directory:
Manual usage
Put the following dependency into your project's dependences section:
parserino
- HTML5 parser based on 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
how it works
<sub>Check also the examples folder</sub>
import parserino;
void main()
{
// Parserino will fix your html5
Document doc = "<html>my html";
assert(doc.toString() == "<html><head></head><body>my html</body></html>");
// Set a title for your page
doc.title = "Hello world";
assert(doc.toString() == "<html><head><title>Hello world</title></head><body>my html</body></html>");
// Append a html fragment
doc.body.appendChild(`
<a href="/first.html">first</a>
<div>
<a id="tochange" href="/second.html">second</a>
</div>
`.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 <a> inside a <div>
.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!");
}
- Registered by Andrea Fontana
- ~master released a year ago
- trikko/parserino
- MIT
- Copyright © 2022, Andrea Fontana
- Authors:
- Dependencies:
- none
- Versions:
-
0.2.5 2023-Oct-19 0.2.4 2023-Oct-18 0.2.3 2023-May-16 0.2.2 2022-Oct-21 0.2.1 2022-Oct-19 - Download Stats:
-
-
0 downloads today
-
6 downloads this week
-
9 downloads this month
-
1395 downloads total
-
- Score:
- 1.7
- Short URL:
- parserino.dub.pm