Saltar para o conteúdo

Usuário:Mr. Fulano/extrabreaks.js

Origem: Wikipédia, a enciclopédia livre.

Nota: Depois de publicar, poderá ter de contornar a cache do seu navegador para ver as alterações.

  • Firefox / Safari: Pressione Shift enquanto clica Recarregar, ou pressione Ctrl-F5 ou Ctrl-R (⌘-R no Mac)
  • Google Chrome: Pressione Ctrl-Shift-R (⌘-Shift-R no Mac)
  • Edge: Pressione Ctrl enquanto clica Recarregar, ou pressione Ctrl-F5.
//<source lang=javascript>
 
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;
}
 
//</source>