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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/purge-html.mjs +16 -4
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "guidelinescraper",
3
- "version": "1.0.10",
3
+ "version": "1.0.12",
4
4
  "type": "module",
5
5
  "description": "Scrape a Frontify brand portal and save every page as PDF and clean HTML",
6
6
  "bin": {
package/purge-html.mjs CHANGED
@@ -92,12 +92,24 @@ export function purge(html) {
92
92
  }
93
93
  }
94
94
 
95
- // Remove stray button labels left behind from copy/download widgets
96
- const strayLabels = /^(Copy|Download)\s+(markdown|code|link|text)$/i;
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 && strayLabels.test(child.textContent.trim())) {
100
- child.remove();
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
  }