Fast & forgiving HTML/XML/RSS parser
npm install @joplin/fork-htmlparser2*
Fork of htmlparser2@4.1.0 for Joplin.
Patch:
``diff
diff --git a/node_modules/htmlparser2/lib/Parser.js b/node_modules/htmlparser2/lib/Parser.js
index 44b4371..bcd7cc2 100644
--- a/node_modules/htmlparser2/lib/Parser.js
+++ b/node_modules/htmlparser2/lib/Parser.js
@@ -212,6 +212,13 @@ var Parser = /* @class / (function (_super) {
this._tagname = "";
};
Parser.prototype.onclosetag = function (name) {
+ // When this is true, the onclosetag event will always be emitted
+ // for closing tags (eg
To fix an HTML parsing issue (tags were allowed to start with non-alphanumeric characters), this upstream commit has also been applied.
*
htmlparser2




A forgiving HTML/XML/RSS parser.
The parser can handle streams and provides a callback interface.
Installation
npm install htmlparser2
A live demo of htmlparser2 is available here.
Usage
`javascript
const htmlparser2 = require("htmlparser2");
const parser = new htmlparser2.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?!");
}
}
},
{ decodeEntities: true }
);
parser.write(
"Xyz