|
@@ -50,6 +50,7 @@ this.serializer = this.serializer || (() => {
|
|
|
{ tagName: "td", accept: next => !next || ["TD", "TH"].includes(next.tagName) },
|
|
{ tagName: "td", accept: next => !next || ["TD", "TH"].includes(next.tagName) },
|
|
|
{ tagName: "th", accept: next => !next || ["TD", "TH"].includes(next.tagName) }
|
|
{ tagName: "th", accept: next => !next || ["TD", "TH"].includes(next.tagName) }
|
|
|
];
|
|
];
|
|
|
|
|
+ const TEXT_NODE_TAGS = ["style", "script", "xmp", "iframe", "noembed", "noframes", "plaintext", "noscript"];
|
|
|
|
|
|
|
|
return {
|
|
return {
|
|
|
process(doc, compressHTML) {
|
|
process(doc, compressHTML) {
|
|
@@ -91,7 +92,7 @@ this.serializer = this.serializer || (() => {
|
|
|
if (parentNode && parentNode.nodeType == Node.ELEMENT_NODE) {
|
|
if (parentNode && parentNode.nodeType == Node.ELEMENT_NODE) {
|
|
|
parentTagName = parentNode.tagName.toLowerCase();
|
|
parentTagName = parentNode.tagName.toLowerCase();
|
|
|
}
|
|
}
|
|
|
- if (!parentTagName || ["style", "script", "xmp", "iframe", "noembed", "noframes", "plaintext", "noscript"].includes(parentTagName)) {
|
|
|
|
|
|
|
+ if (!parentTagName || TEXT_NODE_TAGS.includes(parentTagName)) {
|
|
|
return textNode.textContent;
|
|
return textNode.textContent;
|
|
|
} else {
|
|
} else {
|
|
|
return textNode.textContent.replace(/&/g, "&").replace(/\u00a0/g, " ").replace(/</g, "<").replace(/</g, ">");
|
|
return textNode.textContent.replace(/&/g, "&").replace(/\u00a0/g, " ").replace(/</g, "<").replace(/</g, ">");
|