guidelinescraper 1.0.12 → 1.0.14

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 +12 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "guidelinescraper",
3
- "version": "1.0.12",
3
+ "version": "1.0.14",
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,6 +97,7 @@ 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
  ];
101
102
  const walk = (node) => {
102
103
  for (const child of [...node.childNodes]) {
@@ -121,7 +122,17 @@ export function purge(html) {
121
122
  const cleanHtml =
122
123
  `<!DOCTYPE html>\n<html lang="${document.documentElement?.getAttribute("lang") || "en"}">\n<head>\n<meta charset="utf-8">\n<title>${title}</title>\n<style>body{max-width:72ch;margin:2rem auto;padding:0 1rem;font:1rem/1.6 monospace}img{max-width:100%;height:auto}pre{background:#f5f5f5;padding:1rem;overflow-x:auto;border-radius:4px}code{font-family:monospace}table{border-collapse:collapse;width:100%}th,td{border:1px solid #ccc;padding:.5rem;text-align:left}th{background:#f5f5f5}</style>\n</head>\n<body>\n${main.innerHTML.trim()}\n</body>\n</html>`;
123
124
 
124
- return cleanHtml.replace(/\n{3,}/g, "\n\n").replace(/[ \t]+\n/g, "\n");
125
+ 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";
126
+ // Insert ": " when a format label is concatenated with its value
127
+ const concatRe = new RegExp(`(${COLOR_FORMATS})(#|\\d)`, "g");
128
+ // Remove empty format entries (element containing only a format name, no value)
129
+ const emptyTagRe = new RegExp(`<(p|td|li|dd|span)([^>]*)>\\s*(${COLOR_FORMATS})\\s*<\\/\\1>`, "g");
130
+
131
+ return cleanHtml
132
+ .replace(concatRe, "$1: $2")
133
+ .replace(emptyTagRe, "")
134
+ .replace(/\n{3,}/g, "\n\n")
135
+ .replace(/[ \t]+\n/g, "\n");
125
136
  }
126
137
 
127
138
  // CLI mode: run standalone on a directory