Remove deprecated scripts for adding head-matter to wt_config.xml, including Python and Bash implementations, to streamline configuration management.

This commit is contained in:
Torsten Schulz (local)
2025-12-04 16:34:45 +01:00
parent 4b674c7c60
commit 6e9116e819
13187 changed files with 1493219 additions and 337 deletions

View File

@@ -0,0 +1,43 @@
const SepSub = "%separator";
function sub(p, token, isJson = false) {
let val;
if (token === "s" || token === "pageTitle") {
val = p.pageTitle;
} else if (token.includes(".")) {
const dotIndex = token.indexOf(".");
val = p[token.substring(0, dotIndex)]?.[token.substring(dotIndex + 1)];
} else {
val = p[token];
}
if (val !== void 0) {
return isJson ? (val || "").replace(/\\/g, "\\\\").replace(/</g, "\\u003C").replace(/"/g, '\\"') : val || "";
}
return void 0;
}
function processTemplateParams(s, p, sep, isJson = false) {
if (typeof s !== "string" || !s.includes("%"))
return s;
let decoded = s;
try {
decoded = decodeURI(s);
} catch {
}
const tokens = decoded.match(/%\w+(?:\.\w+)?/g);
if (!tokens) {
return s;
}
const hasSepSub = s.includes(SepSub);
s = s.replace(/%\w+(?:\.\w+)?/g, (token) => {
if (token === SepSub || !tokens.includes(token)) {
return token;
}
const re = sub(p, token.slice(1), isJson);
return re !== void 0 ? re : token;
}).trim();
if (hasSepSub) {
s = s.split(SepSub).map((part) => part.trim()).filter((part) => part !== "").join(sep ? ` ${sep} ` : " ");
}
return s;
}
export { processTemplateParams as p };