User:Ohconfucius/script/formatgeneral.js: Difference between revisions

Content deleted Content added
downcasing Genocide
align to test script
Line 31:
regex(/({{(?:end|start)[-–]date)\|df=y(?:es|)/gi, "$1"); //rem deprecated parameter
regex(/({{(?:end|start)[-–]date(?:[^\{\}]*))\|df=y(?:es|)(}})/gi, "$1$2"); //rem deprecated parameter
regex(/\| ?(?:tele|)phone numbers?= ?([^|}]*)(?=[|}])/gi, "");
 
//add correct hyphenation
Line 44 ⟶ 45:
regex(/([Ff]rom \d{4})\s?[‐‒–—―]\s?(\d{4})/g, "$1 to $2"); //ungrammatical constructs involving year ranges"
regex(/([Ff]rom (\d{2})\d{2})\s?[‐‒–—―]\s?(\d{2})/g, "$1 to $2$3"); //ungrammatical constructs involving year ranges"
regex(/(\| ?colou?rs?= ?[^|}]+)&([^|}]+)(?=[|}])/gi, "$1and$2");
 
regex(/(?:\| ?date= ?)(Cric\w{4,})(?=[|}])/gi, "|publisher=$1");
// regex(/\{\{color ?(?:box|sample)\s?\|#?[^\w}]+}\}\s?}([^\{\}]*|)\{\{color ?(?:box|sample)\s?\|#?[^\w}]+}\}\s?}([^\{\}]*|)\{\{color ?(?:box|sample)\s?\|#?[^\w}]+\}\}([^\{\}]*|)/gi, "$1$2$3");
// regex(/\{\{color ?(?:box|sample)\s?\|#?[^\w+}]+\}\s?}([^\{\}]*|)\{\{color ?(?:box|sample)\s?\|#?[^\w}]+\}\}([^\{\}]*|)/gi, "$1$2");
// regex(/(\|\s*(?:\w+_|)colou?rs\s*=\s*[^{]*)\{\{color ?(?:box|sample)\s?\|#?[^\w}]+\}\}([^\{|\}]*|)(?=\n?[|{}])/gi, "$1$2");
 
}
Line 55 ⟶ 57:
//WP:AMPERSAND
regex(/(==[ ]*[^=&\n]* )&( [^=&\n]*)(?=[ ]*=)/g, '$1and$2');
regex(/(\|\s*(?:\w+_|)colou?rs\s*=\s*[\w ,]+)& (\w+)/gi, '$1and $2'); //replace ampersand
//improper capitalisation within section headings
Line 92 ⟶ 95:
regex(/(\|\s*(?:\w+_|)colou?rs\s*=\s*[A-Z])([\w ,&]+)(?=[\n|}])/gi, '$1{{' + 'subst:' + 'lc:$2}}'); //downcase colours in infobox
regex(/(\|\s*(?:\w+_|)colou?rs\s*=\s*[\w ,]+)&([\w ]+)/gi, '$1and$2'); //replace ampersand
regex(/(==\w+) M(atch(?:es|))\b/gi, '$1 m$2');
Line 109 ⟶ 113:
regex(/((?:'''|\|)Population)[\s]D(ensity(?:'''|\s?\|))/gi, '$1 d$2');
regex(/((?:'''|\|)Population)[\s]P(rojection(?: \w+|)(?:'''|\s?\|))/gi, '$1 p$2');
regex(/(\[\[List of political parties in [^\]]+\|National )P(arty\]\])/g, '$1p$2');
 
regex(/([^\n]*\[\[)(One Country, Two Systems)(?=[|\]])/g, '$1{{' + 'subst:' + 'lc:$2}}');
Line 139 ⟶ 144:
 
//rem inappropriate
regex(/((?:occupation|profession)[ ]*=[ ]*\w+) & (\w+)/gi, '$1, $2');
regex(/((?:occupation|profession)[ ]*=[^\n]*)(?:, (?:activ|philanthrop)ist|Member of Parliament)(?=[^\n]*\n[ ]*\|)/gi, '$1');
// regex(/((?:occupation|profession)[ ]*=[ ]*)(?:\[\[Dewan Rakyat\|Member of Parliament\]\])(?=[^\n]*\n[ ]*\|)/gi, '$1Politican');
regex(/((?:occupation|profession)[ ]*=[ ]*)(?:(?:\[\[[^|\]]+\||)Member of Parliament\]\])(?=[^\n]*\n[ ]*\|)/gi, '$1Politican');
regex(/((?:focus|instrument|industry|known for|method|occupation|products|profession)[ ]*=[ ]*[A-Z]+)([a-z]+[^=|}]+)(?=\n[ ]*\|)/gi, '$1{{' + 'subst:' + 'lc:$2}}'); //to genericise downcasing of occupations and musical instruments
regex(/(?:activ|philanthrop)ist, (politician|businessman)(?=[^\n]*\n[ ]*\|)/gi, '$1');
regex(/(?:Activ|Philanthrop)ist, ([pbl])(olitician|usinessman|awyer)/g, '{{' + 'subst:' + 'uc:$1}}$2');
 
//other improper capitalisation -sports
Line 215 ⟶ 223:
regex(/(Current(?:<br>| ))(Streak)/gi, '$1 {{' + 'subst:' + 'lc:$2}}');
 
regex(/\b(st|ndCurrent(?:<br>|rd|th) G))(radeStreak)\b/ggi, '$1 g{{' + 'subst:' + 'lc:$2}}');
 
regex(/(MEP<br ?\/>)P(arty)/g, '$1p$2');
regex(/(MEP<br ?\/>\()P(arty\))/g, '$1 p$2');
regex(/(Single Transferable Vote)/g, '{{' + 'subst:' + 'lc:$1}}');
// regex(/(Official )S(ite)/g, '$1s$2');
// regex(/([A-Z][a-z]+ )O(fficial )W(ebsite\])/g, '$1o$2w$3');
Line 221 ⟶ 233:
 
regex(/([a-z] )A(nd|t) A(n? \w)/g, '$1a$2 a$3');
regex(/([a-z] )A(nd|t) M(Myy \w)/g, '$1a$2 m$3');
regex(/([a-z] )A(nd|t) T(he \w)/g, '$1a$2 t$3');
regex(/([a-z] )By A(n? \w)/g, '$1by a$2');
regex(/([a-z] )By m(Myy \w)/g, '$1by m$2');
regex(/([a-z] )By T(he \w)/g, '$1by t$2');
regex(/([a-z] )For A(n? \w)/g, '$1for a$2');
regex(/([a-z] )For M(Myy \w)/g, '$1for m$2');
regex(/([a-z] )For T(he \w)/g, '$1for t$2');
regex(/([a-z] )In A(n? \w)/g, '$1in a$2');
regex(/([a-z] )In M(Myy \w)/g, '$1in m$2');
regex(/([a-z] )In T((?:he|o) \w)/g, '$1in t$2');
regex(/([a-z] )I(nto \w)/g, '$1i$2');
regex(/([a-z] )O(f|n|r) A(n? \w)/g, '$1o$2 a$3');
regex(/([a-z] )O(f|n|r) M(Myy \w)/g, '$1o$2 m$3');
regex(/([a-z] )O(f|n|r) T(he \w)/g, '$1o$2 t$3');
regex(/([a-z] )To A(n? \w)/g, '$1to a$2');
regex(/([a-z] )To M(Myy \w)/g, '$1to m$2');
regex(/([a-z] )To T(he \w)/g, '$1to t$2');
regex(/([a-z] )With A(n? \w)/g, '$1with a$2');
Line 245 ⟶ 257:
regex(/([a-z] )A(t \w)/g, '$1a$2');
regex(/([a-z] )I(n \w)/g, '$1i$2');
// regex(/([a-z] )O([fn] \w)/g, '$1o$2'); //'Or' - false positive (with heraldric Or); 'On' - name (e.g. Ma On Shan)
 
regex(/([Rr]unners?)[\- ]U(p\b)/g, '$1-u$2');