//<syntaxhighlight lang=javascript>

function autoEdTemplates(str) { //MAIN FUNCTION describes list of fixes

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

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

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

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

 return str;
}

//</syntaxhighlight>