guidelinescraper 1.0.10 → 1.0.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/purge-html.mjs +16 -4
package/package.json
CHANGED
package/purge-html.mjs
CHANGED
|
@@ -92,12 +92,24 @@ export function purge(html) {
|
|
|
92
92
|
}
|
|
93
93
|
}
|
|
94
94
|
|
|
95
|
-
// Remove
|
|
96
|
-
const
|
|
95
|
+
// Remove Frontify UI noise from text nodes
|
|
96
|
+
const NOISE_PATTERNS = [
|
|
97
|
+
/^(Copy|Download)\s+(markdown|code|link|text)$/i,
|
|
98
|
+
/Lorem ipsum dolor sit amet[\s\S]{0,300}commodo consequat\./,
|
|
99
|
+
/Your changes could not be saved\.\s*Please reload the page and try it again\./,
|
|
100
|
+
];
|
|
97
101
|
const walk = (node) => {
|
|
98
102
|
for (const child of [...node.childNodes]) {
|
|
99
|
-
if (child.nodeType === 3
|
|
100
|
-
child.
|
|
103
|
+
if (child.nodeType === 3) {
|
|
104
|
+
let text = child.textContent;
|
|
105
|
+
for (const pat of NOISE_PATTERNS) {
|
|
106
|
+
text = text.replace(pat, "");
|
|
107
|
+
}
|
|
108
|
+
if (text.trim()) {
|
|
109
|
+
child.textContent = text;
|
|
110
|
+
} else {
|
|
111
|
+
child.remove();
|
|
112
|
+
}
|
|
101
113
|
} else if (child.nodeType === 1) {
|
|
102
114
|
walk(child);
|
|
103
115
|
}
|