Add one-off script for adding hrothgar/viera headwear compatibility data

This commit is contained in:
ewin 2025-08-12 18:27:59 -04:00
parent 7b5357c050
commit 4d7bd2515a
Signed by: erin
SSH key fingerprint: SHA256:swjoHhREbZPbWe+gyJNi24d4NAxJSyUIm3fpZj4z3wc
2 changed files with 84 additions and 0 deletions

View file

@ -49,3 +49,18 @@ export function addParameterBesideExistingParameter (pageContent, newParamName,
}
return null;
}
/** RegExp that matches the last parameter in an infobox. */
const existingLastParameterRegExp = /^( *)\|( *)([a-z0-9-_]+)( *)=( *)(.*)(\n *}})$/m;
/** Inserts a new parameter at the end of the infobox. */
export function addParameterAtBottom (pageContent, newParamName, value) {
if (pageContent.match(existingLastParameterRegExp)) {
// has science gone too far?
return pageContent.replace(
existingLastParameterRegExp,
`$1|$2$3$4=$5$6\n$1|$2${newParamName}$4=$5${value}$7`,
);
}
return null;
}