|
|
|
@ -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,11 +25,13 @@ function fixHTML(infile, outfile) {
|
|
|
|
|
let f = fs.readFileSync(infile).toString();
|
|
|
|
|
// Find all go template strings ({{ example }})
|
|
|
|
|
let templateStrings = pre.exec(f, "(?s){{(?:(?!{{).)*?}}", "gi");
|
|
|
|
|
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"]) {
|
|
|
|
|
let items = doc("."+item);
|
|
|
|
@ -58,12 +62,14 @@ function fixHTML(infile, outfile) {
|
|
|
|
|
}
|
|
|
|
|
let out = doc.html();
|
|
|
|
|
// let out = f
|
|
|
|
|
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("<!--", "{{");
|
|
|
|
|
out = out.replaceAll("-->", "}}");
|
|
|
|
|
}
|
|
|
|
|
fs.writeFileSync(outfile, out);
|
|
|
|
|
console.log(infile, outfile);
|
|
|
|
|
};
|
|
|
|
|