1
0
mirror of https://github.com/hrfee/jfa-go.git synced 2024-12-22 09:00:10 +00:00

add NOTEMPLATE env var to missing-colors.js

This commit is contained in:
Harvey Tindall 2022-01-30 14:41:11 +00:00
parent dec8d75083
commit baffa4a38c
Signed by: hrfee
GPG Key ID: BBC65952848FB1A2
3 changed files with 7001 additions and 27 deletions

7002
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -3,6 +3,8 @@ let fs = require("fs");
let path = require("path");
let pre = require("perl-regex");
const template = process.env.NOTEMPLATE != "1";
const hasDark = (item) => {
let list = item.attr("class").split(/\s+/);
for (let i = 0; i < list.length; i++) {
@ -23,10 +25,12 @@ function fixHTML(infile, outfile) {
let f = fs.readFileSync(infile).toString();
// Find all go template strings ({{ example }})
let templateStrings = pre.exec(f, "(?s){{(?:(?!{{).)*?}}", "gi");
for (let i = 0; i < templateStrings.length; i++) {
let s = templateStrings[i].replace(/\\/g, '');
// let s = templateStrings[i];
f = f.replaceAll(s, "<!--" + s.slice(3).slice(0, -3) + "-->");
if (template) {
for (let i = 0; i < templateStrings.length; i++) {
let s = templateStrings[i].replace(/\\/g, '');
// let s = templateStrings[i];
f = f.replaceAll(s, "<!--" + s.slice(3).slice(0, -3) + "-->");
}
}
let doc = new parser.load(f);
for (let item of ["badge", "chip", "shield", "input", "table", "button", "portal", "select", "aside", "card", "field", "textarea"]) {
@ -58,12 +62,14 @@ function fixHTML(infile, outfile) {
}
let out = doc.html();
// let out = f
for (let i = 0; i < templateStrings.length; i++) {
let s = templateStrings[i].replace(/\\/g, '');
out = out.replaceAll("<!--" + s.slice(3).slice(0, -3) + "-->", s);
}
if (template) {
for (let i = 0; i < templateStrings.length; i++) {
let s = templateStrings[i].replace(/\\/g, '');
out = out.replaceAll("<!--" + s.slice(3).slice(0, -3) + "-->", s);
}
out = out.replaceAll("&lt;!--", "{{");
out = out.replaceAll("--&gt;", "}}");
}
fs.writeFileSync(outfile, out);
console.log(infile, outfile);
};

View File

@ -1,7 +1,7 @@
all:
-mkdir -p out
cp ../css/modal.css out/
node ../scripts/missing-colors.js index.html out/index.html
NOTEMPLATE=1 node ../scripts/missing-colors.js index.html out/index.html
cp -r node_modules/remixicon/fonts/remixicon.css node_modules/remixicon/fonts/remixicon.woff2 out/
-rm -r tempts
cp -r ts tempts
@ -19,7 +19,7 @@ all:
debug:
-mkdir -p out
cp ../css/modal.css out/
node ../scripts/missing-colors.js index.html out/index.html
NOTEMPLATE=1 node ../scripts/missing-colors.js index.html out/index.html
cp -r node_modules/remixicon/fonts/remixicon.css node_modules/remixicon/fonts/remixicon.woff2 out/
-rm -r tempts
cp -r ts tempts