Wikipedia:AutoEd/whitespace.js: Difference between revisions

Content deleted Content added
Try making this more aggressive
Pppery changed the content model of the page Wikipedia:AutoEd/whitespace.js from "wikitext" to "JavaScript"
 
(3 intermediate revisions by 2 users not shown)
Line 1:
//<source lang=javascript>
 
function autoEdWhitespace(str) { //MAIN FUNCTION describes list of fixes
 
Line 9 ⟶ 7:
if(str.search(/\uE000/g) < 0) { // see [[Private Use Area]]
// Mark spacing before stub templates
str = str.replace(/(\n)[ \t]*(\n)[ \t]*(\n\{\{[^{}]*\-stub\}\})/gm, '"$1\uE000$2\uE000$3'");
str = str.replace(/(\n)[ \t]*(\n\{\{[^{}]*\-stub\}\})/gm, '"$1\uE000$2'");
// Remove extra newlines
str = str.replace(/(?:[\nt ]*\n)+[\t ]*(\n+\uE000\n\uE000\n)/ggm, "$1");
str = str.replace(/(\n\n)\n+/gm, "$1");
str = str.replace(/(\n[\t ]*\n)(?:[\t ]*\n)+/g, "$1");
// Unmark
Line 42 ⟶ 41:
return str;
}
 
//</source>