Wikipedia:AutoEd/whitespace.js: Difference between revisions
Content deleted Content added
Plastikspork (talk | contribs) Per request on talk page, fix for spacing before stub templates (should work) |
Pppery changed the content model of the page Wikipedia:AutoEd/whitespace.js from "wikitext" to "JavaScript" |
||
(6 intermediate revisions by 2 users not shown) | |||
Line 1:
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,
str = str.replace(/(\n)[ \t]*(\n\{\{[^{}]*\-stub\}\})/gm,
// Remove extra newlines
str = str.replace(/(?:[\
str = str.replace(/(\n[\t ]*\n)(?:[\t ]*\n)+/g, "$1");
// Unmark
str = str.replace(/\uE000/g, '');
Line 23:
str = str.replace(/\n\n\*/g, "\n*");
// str = str.replace(/[ \t][ \t]+/g, " ");
▲ str = str.replace(/(\n[\t ]*\n)(?:[\t ]*\n)+/g, "$1");
str = str.replace(/(=\n[\t ]*\n[\t ]*\n)(?:[\t ]*\n)+/g, "$1");
str = str.replace(/ \n/g, "\n");
Line 42 ⟶ 41:
return str;
}
|