mirror of
https://github.com/streetwriters/notesnook.git
synced 2025-12-23 06:59:31 +01:00
core: use upstream htmlparser2 instead of in-house
This is mostly because I am not 100% certain about how stable our own optimized version is. While it does perform a lot better, there is significant risk that things might break in production. To avoid that, I am replacing it with the upstream version which is much more heavily tested.
This commit is contained in:
@@ -17,7 +17,7 @@ You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { Parser, Attributes } from "htmlparser2";
|
||||
import { Parser } from "htmlparser2";
|
||||
|
||||
export class HTMLRewriter {
|
||||
/**
|
||||
@@ -73,7 +73,12 @@ export class HTMLRewriter {
|
||||
}
|
||||
|
||||
this.write(`<${name}`);
|
||||
if (attr) this.write(` ${attr}`);
|
||||
if (attr) {
|
||||
for (const key in attr) {
|
||||
if (!key) continue;
|
||||
this.write(` ${key}="${attr[key]}"`);
|
||||
}
|
||||
}
|
||||
this.currentTag = name;
|
||||
},
|
||||
onclosetag: (name, isImplied) => {
|
||||
@@ -111,8 +116,7 @@ export class HTMLRewriter {
|
||||
decodeEntities: false,
|
||||
lowerCaseAttributeNames: false,
|
||||
lowerCaseTags: false,
|
||||
recognizeCDATA: false,
|
||||
parseAttributes: false
|
||||
recognizeCDATA: false
|
||||
}
|
||||
);
|
||||
}
|
||||
@@ -171,8 +175,7 @@ export class HTMLParser {
|
||||
decodeEntities: false,
|
||||
lowerCaseAttributeNames: false,
|
||||
lowerCaseTags: false,
|
||||
recognizeCDATA: false,
|
||||
parseAttributes: false
|
||||
recognizeCDATA: false
|
||||
}
|
||||
);
|
||||
}
|
||||
@@ -182,5 +185,3 @@ export class HTMLParser {
|
||||
this.parser.reset();
|
||||
}
|
||||
}
|
||||
|
||||
export { Attributes };
|
||||
|
||||
Reference in New Issue
Block a user