English Wikipedia @ Freddythechick:AutoEd/extrabreaks.js

From English Wikipedia @ Freddythechick

This is the current revision of this page, as edited by imported>Pppery at 21:28, 25 January 2024 (Pppery changed the content model of the page Wikipedia:AutoEd/extrabreaks.js from "wikitext" to "JavaScript"). The present address (URL) is a permanent link to this version.

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
function autoEdExtraBreaks(str) { //MAIN FUNCTION describes list of fixes
 
//Usually unneeded BR tags from ends of image descriptions and wikilinks (]]), templates (}}), template parameters (|)
str = str.replace(/[\t ]*<[\s\/\.]*br[\s\/\.]*>[\t ]*([\t\n ]*?)(\]\]|}}|\|)/gim, '$1$2');
//BR tag before a list item
str = str.replace(/[\t ]*<[\s\/\.]*br[\s\/\.]*>[\t ]*([\s]*?[\n]\*)/gim, '$1');
//BR tag followed by at least two newlines
str = str.replace(/[\t ]*<[\s\/\.]*br[\s\/\.]*>[\t ]*([\n])[\t ]*([\n])/gim, '$1$2');
 
return str;
}