Jump to content

Wikipedia:AutoEd/templates.js

From Wikipedia, the free encyclopedia
This is the current revision of this page, as edited by Pppery (talk | contribs) at 14:37, 26 January 2024 (Pppery changed the content model of the page Wikipedia:AutoEd/templates.js from "wikitext" to "JavaScript"). The present address (URL) is a permanent link to this version.
(diff) ← Previous revision | Latest revision (diff) | Newer revision → (diff)
function autoEdTemplates(str) { //MAIN FUNCTION describes list of fixes

 //Remove unneeded Template: text from transclusions
 str = str.replace(/{{[_ ]*Template:[_ ]*/gi, '{{');

 //Replace redirects to Reflist with Reflist
 str = str.replace(/{{[_ ]*(?:Reference[_ ]+List|References-Small|Reflink)[_ ]*(\||}})/gi, '{{Reflist$1');
 str = str.replace(/{{[_ ]*(?:Refs|Reference|Ref-list|Listaref|FootnotesSmall)[_ ]*(\||}})/gi, '{{Reflist$1');

 //Replace a long version of Reflist with Reflist
 str = str.replace(/<div[^<>]*[ ]+class=['"]*references-small['"]*[^<>]*>[\r\n]*<references[ ]*\/>[\r\n]*<\/div>/gim, '{{Reflist}}');

 //Replace redirects to about with about
 str = str.replace(/{{[_ ]*(?:Otheruses4|Four[_ ]+other[_ ]+uses|Otherusesabout|This2)[_ ]*(\||}})/gi, '{{about$1');

 return str;
}