User:Michael Anon/customwhitespace.js

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

str = str.replace(/([A-Za-z0-9])[ \t]{2,}(?![ \t=])/g, "$1 "); str = str.replace(/\n{3,}/g, "\n\n"); str = str.replace(/\n\n(\* ?\[?http)/g, "\n$1"); str = str.replace(/\n\n\*/g, "\n*"); str = str.replace(/[ \t]+\n/g, "\n"); //* bullet points str = str.replace(/^([\*#]+:*)([^ \t])/gm, "$1 $2"); //==Headings== str = str.replace(/^(={1,4}) ?(.*?) ?(={1,4})$/gm, "$1$2$3"); return str; }