guidelinescraper 1.0.12 → 1.0.13

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 +15 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "guidelinescraper",
3
- "version": "1.0.12",
3
+ "version": "1.0.13",
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
@@ -97,7 +97,12 @@ export function purge(html) {
97
97
  /^(Copy|Download)\s+(markdown|code|link|text)$/i,
98
98
  /Lorem ipsum dolor sit amet[\s\S]{0,300}commodo consequat\./,
99
99
  /Your changes could not be saved\.\s*Please reload the page and try it again\./,
100
+ /^Describe this color palette here$/i,
100
101
  ];
102
+ const COLOR_FORMATS = "HEX|RGB|CMYK|LESS|HSL|HSB|RAL|ORA|PMS|PMS-C|PMS-U|PMS-CP|PMS-PQ|PMS-TCX|CMYK-C|CMYK-U|CMYK-N|NCS|HKS|3M|LAB|PANTONE";
103
+ const COLOR_EMPTY_RE = new RegExp(`^(${COLOR_FORMATS})$`);
104
+ const COLOR_VALUE_RE = new RegExp(`^(${COLOR_FORMATS})(.+)$`);
105
+
101
106
  const walk = (node) => {
102
107
  for (const child of [...node.childNodes]) {
103
108
  if (child.nodeType === 3) {
@@ -105,6 +110,16 @@ export function purge(html) {
105
110
  for (const pat of NOISE_PATTERNS) {
106
111
  text = text.replace(pat, "");
107
112
  }
113
+ // Color palette: remove format-only lines (no value)
114
+ if (COLOR_EMPTY_RE.test(text.trim())) {
115
+ child.remove();
116
+ continue;
117
+ }
118
+ // Color palette: insert ": " between format label and value
119
+ const m = text.trim().match(COLOR_VALUE_RE);
120
+ if (m) {
121
+ text = m[1] + ": " + m[2].trim();
122
+ }
108
123
  if (text.trim()) {
109
124
  child.textContent = text;
110
125
  } else {