https://github.com/tbjgolden/deno-htmlparser2
Deno port of `htmlparser2`
https://github.com/tbjgolden/deno-htmlparser2
deno html html-parser htmlparser2 parser
Last synced: 8 months ago
JSON representation
Deno port of `htmlparser2`
- Host: GitHub
- URL: https://github.com/tbjgolden/deno-htmlparser2
- Owner: tbjgolden
- Created: 2020-07-02T17:13:06.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2021-06-29T22:57:19.000Z (almost 5 years ago)
- Last Synced: 2025-06-26T16:49:13.018Z (10 months ago)
- Topics: deno, html, html-parser, htmlparser2, parser
- Language: TypeScript
- Homepage:
- Size: 79.1 KB
- Stars: 4
- Watchers: 2
- Forks: 3
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# deno-htmlparser2
Deno port of HTML Parser 2 (and its dependencies).
```ts
// direct
import { Parser } from "https://rawcdn.githack.com/tbjgolden/deno-htmlparser2/451e3693f15dd2735283e65085edf3db94587d10/htmlparser2/index.ts";
const parser = new Parser(
{
onopentag(name, attribs) {
if (name === "script" && attribs.type === "text/javascript") {
console.log("JS! Hooray!");
}
},
ontext(text) {
console.log("-->", text);
},
onclosetag(tagname) {
if (tagname === "script") {
console.log("That's it?!");
}
},
onend() {
console.log("Done");
},
},
{ decodeEntities: true },
);
parser.write(
"Xyz var foo = '<<bar>>';</ script>",
);
parser.end();
```
logs
```
--> Xyz
JS! Hooray!
--> var foo = '
--> <
--> <bar>>';
That's it?!
Done
```
See htmlparser2 for documentation and for any issues that are present in both this port and the original project.