Jump to content

Wikipedia:AutoEd/extrabreaks.js

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by AFigureOfBlue (talk | contribs) at 15:28, 2 May 2009 (Better code). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

//

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

    //Remove extra BR tags
    str = str.replace(/<br>\]\]|<br ?\/>\]\]/gi, '\]\]'); //Remove usually unneeded BR tags from ends of image descriptions and wikilinks
    str = str.replace(/<br> ?\n?\}\}|<br ?\/> ?\n?\}\}/gi, '\}\}'); //Remove usually unneeded BR tags from ends of templates
    str = str.replace(/<br> ?\||<br ?\/> ?\|/gi, '\|'); //Remove from parameters
    str = str.replace(/<br> ?\n ?\||<br ?\/> ?\n ?\|/gi, '\n\|'); //Ditto
    str = str.replace(/<br> ?\n\*|<br ?\/> ?\n\*/gi, '\n\*'); //Remove usually unneeded BR tags in lists
    str = str.replace(/<br> ?\n\n|<br ?\/> ?\n\n/gi, '\n\n'); //Remove usually unneeded BR tags followed by two newlines

    return str;
}

//