Add one-off script for adding hrothgar/viera headwear compatibility data
This commit is contained in:
parent
7b5357c050
commit
4d7bd2515a
2 changed files with 84 additions and 0 deletions
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue