Content deleted Content added
MusikAnimal (talk | contribs) declare dependency on mediawiki.util |
Ohconfucius (talk | contribs) align to test script |
||
Line 12:
regex(/\[\[[\w]*_\d{4}#\d{4}_[\w]*_\d\d?\|(Jan(?:uary|\.|)|Feb(?:ruary|\.|)|Mar(?:ch|\.|)|Apr(?:il|\.|)|May\.?|Jun(?:e|\.|)|Jul(?:y|\.|)|Aug(?:ust|\.|)|Sep(?:tember|\.|t\.|)|Oct(?:ober|\.|)|Nov(?:ember|\.|)|Dec(?:ember|\.|))( \d\d?)\]\]/g, '$1$2');
// regex(/<br>/gi, '<br/>');
regex(/(\d)(<sup>)(m)(\d<\/sup>)/gi, '$1$3$2$4'); //misplaced unit (squared)il
//rem linking within section headings
Line 24 ⟶ 22:
//rem refs within section headings
regex(/(==[ ]?(?:[^<>\n]*))(?:<ref(?:>[^<>]*<\/ref| name=[^\/>]+\/)>)([^<>\n]*)(?=[ ]?==)/gi, '$1$2');
//rem empty parameters
Line 48 ⟶ 39:
regex(/(\bnon)-(grata)/g, "$1 $2"); //reinstate for "persona non grata"
regex(/(qua non)-([A-Z])/gi, "$1 $2"); //reinstate for "sine qua non"
regex(/([Bb]etween \d{4})\s?[‐‒–—―]\s?(\d{4})/g, "$1 and $2"); //ungrammatical constructs involving year ranges"
regex(/([Bb]etween (\d{2})\d{2})\s?[‐‒–—―]\s?(\d{2})/g, "$1 and $2$3"); //ungrammatical constructs involving year ranges"
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(/(?:\| ?date= ?)(Cric\w{4,})(?=[|}])/gi, "|publisher=$1");
regex(/
regex(/
regex(/(\|\s*(?:\w+_|)colou?rs\s*=\s*[^{]*){{color ?sample\s?\|#?\w+}}([^{|]*)(?=\n?[|{}])/gi, "$1$2");
Line 63 ⟶ 58:
regex(/(==[ ]*External )(Links)(?=[ ]*=)/g, '$1links');
regex(/(==[ ]*See )(Also)(?=[ ]*=)/g, '$1also');
regex(/(==[ ]*)Notable Alumnae/g, '$1Alumni');
regex(/(==[ ]*)Notable ([A-Z]\w*?)/g, '$1$2');
regex(/(==[ ]*Box )O(ffice)(?=[ ]*=)/g, '$1o$2');
Line 79 ⟶ 75:
regex(/(==[^=\n]+) +S((?:chedule|creenings?|ummary) ?==)/gi, '$1 s$2');
regex(/(==[ ]*[\w\s]+? )T(ables?|ournaments|ransport(?:ations?|))(?=[ ]*=)/gi, '$1t$2');
regex(/(==[ ]*[\w\s]+? )Y(ears)(?=[ ]*=)/g, '$1y$2');
Line 91 ⟶ 88:
regex(/(==[ ]*Campaign )C(redits)(?=[ ]*=)/g, '$1c$2');
regex(/(==[ ]*Combat )C(hronicle)(?=[ ]*=)/g, '$1c$2');
regex(/(==[ ]*[\w\s]+? )(International Trips)(?=[ ]*=)/g, '$1{{' + 'subst:' + 'lc:$2}}');
regex(/(\|\s*(?:\w+_|)colou?rs\s*=\s*[A-Z])([\w ,&]+)(?=[\n|}])/gi, '$1{{' + 'subst:' + 'lc:$2}}'); //downcase colours in infobox
Line 107 ⟶ 105:
regex(/((?:'''|\|)\w+)[-–\s]H((?:alf|alves)(?:'''|\]\]))/gi, '$1-h$2');
regex(/((?:'''|\|)(?:[Oo]ne|[Tt]hree|[Ff]our))[-–\s]Q(uarters?(?:'''|\]\]))/gi, '$1-q$2');
regex(/((?:'''|\|) ?Player )(One|Two|Three|Four)/gi, '$1{{' + 'subst:' + 'lc:$2}}');
regex(/((?:'''|\|)Population)[\s]D(ensity(?:'''|\s?\|))/gi, '$1 d$2');
regex(/((?:'''|\|)Population)[\s]P(rojection(?: \w+|)(?:'''|\s?\|))/gi, '$1 p$2');
Line 112 ⟶ 111:
regex(/([^\n]*\[\[)(One Country, Two Systems)(?=[|\]])/g, '$1{{' + 'subst:' + 'lc:$2}}');
regex(/((?:[^\n]*|[^\.]\s)\[\[)(Exclusive Economic Zone)(?=[|\]])/g, '$1{{' + 'subst:' + 'lc:$2}}');
regex(/(\[\[(?:\d{3,4} |)(?:[A-Z][a-z]+ )(?:[A-Z][a-z]+ )*)(Conspiracy|Controversy|(?:Race |)Riot|Massacre|Murder|Protest|Uprising)(?=s?(?: of \d{3,4}|)\]| \(\d{3,4}\))/g, '$1{{' + 'subst:' + 'lc:$2}}'); //per Frietjes: you cannot use subst: inside of references
//improper capitalisation within infobox strings
Line 141 ⟶ 140:
// regex(/((?:occupation|profession)[ ]*=[ ]*)(?:\[\[Dewan Rakyat\|Member of Parliament\]\])(?=[^\n]*\n[ ]*\|)/gi, '$1Politican');
regex(/((?:occupation|profession)[ ]*=[ ]*)(?:(?:\[\[[^|\]]+\||)Member of Parliament\]\])(?=[^\n]*\n[ ]*\|)/gi, '$1Politican');
regex(/((?:instrument|occupation|products|profession)[ ]*=[ ]*[A-Z]+)([a-z]+[^=|}]+)(?=\n[ ]*\|)/gi, '$1{{' + 'subst:' + 'lc:$2}}'); //to genericise downcasing of occupations and musical instruments
//other improper capitalisation -sports
Line 182 ⟶ 181:
regex(/(Airport) +(Name|Code)/g, '$1 {{' + 'subst:' + 'lc:$2}}');
regex(/(Bonus )P(oints|ts)/g, '$1p$2');
regex(/(Busiest) +((?:International |Domestic |) *(?:Flight|Routes(?: Out [Oo]f|)))/gi, '$1 {{' + 'subst:' + 'lc:$2}}');
regex(/(City ) ?S(erved)/g, '$1s$2');
Line 201:
regex(/(Years |When )S(igned)/gi, '$1s$2');
regex(/(Match )I(nformation)/gi, '$1i$2');
regex(/(\|\s*\w+ )S(taff\b)(?=\s?\w)/gi, '$1s$2'); //bug fix
regex(/N(ational Distribution of Seats)/gi, 'N{{' + 'subst:' + 'lc:$1}}');
regex(/([-–]\s?Won (?:Gold|Silver|Bronze) Medal)/gi, '{{' + 'subst:' + 'lc:$1}}');
Line 255:
regex(/(Bring |Turn )[Ii]t o(n)/g, '$1It O$2'); //reverting proper name - title of song or work
regex(/(Carry )o(n [A-Z]\w*|n film)/g, '$1O$2'); //reverting proper name - 'Carry On' film series
regex(/(
regex(/(NZ |New Zealand )o(n Air|n Screen)/g, '$1O$2'); //reverting proper name - 'NZ On Air'
regex(/(\w (?:\[\[|))O(ff-Broadway\b)/g, '$1O$2'); //not a proper noundowncase
regex(/in t(he [Aa]ir [Tt]onight)/g, 'In t$1'); //reverting per "In the Air Tonight"
regex(/in t(he Flesh [Tt]our)/g, 'In t$1'); //reverting per "In the Flesh tour"
regex(/(\W)o(n This Day)/g, '$1O$2'); //reverting per "on This Day"
regex(/({NYT )o(n this day)/g, '$1O$2'); //reverting per "on This Day"
regex(/(\bWing )o(n\
regex(/(Star Trek )into( Darkness)/g, '$1Into$2'); //reverting proper name - title of work
regex(/((?:Sonata|Symphony|Concerto|Prelude)(?: No\. \d\d?|)) in a((?:-flat|) [Mm](?:inor|ajor))/g, '$1 in A$2'); //reverting musical term
Line 269 ⟶ 270:
function Ohc_format_MOSFLAG(){
//remove flagicons from country, birth and death
regex(/((?:birth|death|place|captain|chairman|club|coach|manager|headquarters|citizenship|nationality|occupation|origin|party|region_served|stadium)\s*=\s*)(?:\{\{flag ?icon\|[^{}]+(?:\|[^{}]+|)\}\} ?|\[\[(?:File|Image):Flag of [^\]]\]\] ?)/gi, '$1');
regex(/((?:birth|death)(?:_?place|)\s*=\s*)\{\{flag(?:country|u|)\|([^{}|]+)(?:\|[^{}]+|)\}\}/gi, '$1$2');
regex(/((?:(?:birth|death)(?:_?place|)|citizenship|residence|nationality)\s*=\s*)(?:\{\{flag ?icon\|[^{}]+(?:\|[^{}]+|)\}\} ?|\[\[(?:File|Image):Flag of [^\]]+\]\] ?)/gi, '$1$2');
Line 294 ⟶ 295:
regex(/(.)[“„”«»](.)/gi, '$1\"$2');
// regex(/([\s>()])[‘`´’′](\[?\w+)/gi, '$1\'$2');
regex(/([\w;,\]\)>] ) +([\[(]|[a-z\d])/gi, '$1$2'); //rem multiple spaces except when preceded by full stop; tweaked to not remove dbl spaces where preceded by new sentence (caps)
regex(/(^\.U\.)[ ]+((?:S|K)\.)/gi, '$1$2'); //U. S. and U. K. to U.S. and U.K.
regex(/(<\/?ref(?: name=[^<>\/]*?|)>)[ ,\.]*(<ref)/gi, '$1$2'); // remove punctuation between ref tags
regex(/[ ]{1,3}(<\/?ref(?:>| >| n))/gi, '$1'); // remove spaces and line feeds preceding ref tags and templates
// regex(/[ ]{1,3}(:\s)/gi, '$1'); // remove spaces preceding colons //disabled following complaint (Peter Coxhead Sept 2017)
// regex(/(<\/ref ?>|<ref name=[^>\/]+\/>)([^\s<])/gi, '$1 $2'); // add spaces after ref tags
// regex(/[ ]+(\n|\r)/gi, '$1'); //removes multiple spaces preceding line break
Line 517 ⟶ 519:
regex(/(<(?:imagemap)>)([\s\S]*)(<\/(?:imagemap)>)/gi, protect_function);
regex(/(\{(?:Coord|See ?also|Main|Wikisource))(\|[^{}]*)(\})/gi, protect_function);
regex(/(\{\{cit(?:ation|e))([^<>}]*)(\}\})/gi, protect_function);
regex(/((?:Category|File|Image):)([^|\]]*)([\|\]])/gi, protect_function);
regex(/(\|\s*edition\s*=)([^|\]]*)([\|\]])/gi, protect_function);
Line 525 ⟶ 528:
regex(/(\[\[\w*)([^\|\]]*)(\|)/gi, protect_function);
regex(/(\{\{\w*)([^\|=\[\]]*)(\}\})/gi, protect_function);
regex(/(<ref(?: name=
regex(/(<ref(?: name=\w+)>)([\s\S]*?)(<\/ref>)/gi, protect_function);
regex(/(\{Infobox)( non Test)( cricket)/gi, protect_function);
regex(/(.)((?:Chairman's|President'?s) (?:XI|Cup))(.)/g, protect_function);
regex(/(.)(100\scrore club)(.)/gi, protect_function);
regex(/(.)(Conference of Presidents)(.)/g, protect_function);
regex(/(.)(Pussy Riot)(.)/g, protect_function);
regex(/(\[\[)((?:The |)Texas Chain ?Saw Massacre[^\]|]*)([\]|])/gi, protect_function);
regex(/
regex(/
regex(/C(hief )O(perating )O(fficer\W)/g, 'c$1o$2o$3');▼
regex(/C(hief )I(nformation )O(fficer\W)/g, 'c$1i$2o$3');▼
regex(/C(hief )M(arketing )O(fficer\W)/g, 'c$1m$2o$3');▼
▲ regex(/M(anaging )D(irector\W)/g, 'm$1d$2');
regex(/G(eneral )M(anager\b)(?!of|[ ]*=)/g, 'g$1m$2');
regex(/
regex(/
regex(/
regex(/
regex(/
regex(/
regex(/
regex(/
regex(/N(on[\s\-])P(rofit\W)/g, 'n$1p$2');▼
regex(/N(on[\s\-])[Ee](xecutive )[Dd](irector)/g, 'n$1e$2d$3');▼
regex(/(\w\s)V(ice)[\s\-]C(hair(?:man|)\W)(?!of)/g, '$1v$2-c$3');
regex(/(\w\s)C(hairman\W)(?!of)/g, '$1c$2');
Line 573 ⟶ 571:
regex(/(\|[\s\']+)(\d+)[\. ](\d{3})[\. ](\d{3})[\. ](\d{3})(?=[ ']*[|\n<])/g, '$1$2,$3,$4,$5');
regex(/(\|[\s\']+)(\d+)[\. ](\d{3})[\. ](\d{3})(?=[ ']*[|\n<])/g, '$1$2,$3,$4');
// regex(/(\|[\s\']+)(\d+)[\. ](\d{3})(?=[ ']*[|\n<])/g, '$1$2,$3'); //disabled 2 april 2017 due to false positives
// replace comma as decimal separator
Line 647 ⟶ 645:
regex(/(== ?(?:Bibliography|Further reading|References|Sources|Works) ?==+)(\n[\S\s]*?)(\n)(?===)/gi, protect_function);
regex(/(== ?(?:Attribution|External links) ?==+)(\n[\S\s]*?)(\[\[Category:[^\]]+\]\])/gi, protect_function);
regex(/({{(?:refn|sfnp)\|)([^}]*?)(}})/gi, protect_function);
regex(/(<ref name="[^\"]*?" ?>)([\s\S]*?)(<\/ref>)/gi, protect_function);
regex(/(<ref[^/>]*?>)([\s\S]*?)(<\/ref>)/gi, protect_function);
regex(/(\|\s?(?:image|model|references?|video)\d\s?=\s?[\'\"]?\[https?:)([^\]]*)(\])/gi, protect_function);
regex(/([=\*][ ]?\[(?:https?:|ftp:))([^\]]*)(\])/gi, protect_function);
Line 683 ⟶ 681:
//add {{url}} template to infobox parameter
regex(/({{) ?(url) ?(?=\|)/gi, '$1$2');
regex(/({{url\|)[ ]*(?:https?:\/\/|)(?:www\.|)([^\}]+}})[ ]*(?=[\n\r])/gi, '$1$2');
regex(/({{url\|)(?:https?:\/\/|)(?:www\.|)([^\}]+)\|(?:\2|Official (?:web|)site)}}(?=[\s])/gi, '$1$2}}');
regex(/(\| ?homepage[ ]*=)[ ]*https?:\/\/(?:www\.|)([^\s\[\]]+)(?=[\s])/gi, '$1{{url|$2}}'); //rem 'website='
regex(/(\| ?(?:homepage|website)[ ]*=)[ ]*\[https?:\/\/(www\.|)([^\s\[\]]+) \2\3\](?=[\s])/gi, '$1{{url|$3}}');
regex(/(\| ?(?:homepage|website)[ ]*=)[ ]*\[https?:\/\/(?:www\.|)([^\s\[\]]+) official (?:web|)site\](?=[\s])/gi, '$1{{url|$2}}');
▲ regex(/({{url\|)([^\}]+)\|\2}}(?=[\s])/gi, '$1$2}}');
//remove icons from headers (needs to occur before protection)
Line 697 ⟶ 696:
//adjust piping - remove redundant, adding piping for parentheticals
regex(/\[\[E([^\]\|]*)\|(e)\1([^-\] ]*|)(\]\])/g, '[[$2$1$4$3');
regex(/\[\[F([^\]\|]*)\|(f)\1([^-\] ]*|)(\]\])/g, '[[$2$1$4$3');
regex(/\[\[G([^\]\|]*)\|(g)\1([^-\] ]*|)(\]\])/g, '[[$2$1$4$3');
regex(/\[\[H([^\]\|]*)\|(h)\1([^-\] ]*|)(\]\])/g, '[[$2$1$4$3');
regex(/\[\[I([^\]\|]*)\|(i)\1([^-\] ]*|)(\]\])/g, '[[$2$1$4$3');
regex(/\[\[J([^\]\|]*)\|(j)\1([^-\] ]*|)(\]\])/g, '[[$2$1$4$3');
regex(/\[\[K([^\]\|]*)\|(k)\1([^-\] ]*|)(\]\])/g, '[[$2$1$4$3');
regex(/\[\[L([^\]\|]*)\|(l)\1([^-\] ]*|)(\]\])/g, '[[$2$1$4$3');
regex(/\[\[M([^\]\|]*)\|(m)\1([^-\] ]*|)(\]\])/g, '[[$2$1$4$3');
regex(/\[\[O([^\]\|]*)\|(o)\1([^-\] ]*|)(\]\])/g, '[[$2$1$4$3');
regex(/\[\[P([^\]\|]*)\|(p)\1([^-\] ]*|)(\]\])/g, '[[$2$1$4$3');
regex(/\[\[Q([^\]\|]*)\|(q)\1([^-\] ]*|)(\]\])/g, '[[$2$1$4$3');
regex(/\[\[R([^\]\|]*)\|(r)\1([^-\] ]*|)(\]\])/g, '[[$2$1$4$3');
regex(/\[\[S([^\]\|]*)\|(s)\1([^-\] ]*|)(\]\])/g, '[[$2$1$4$3');
regex(/\[\[T([^\]\|]*)\|(t)\1([^-\] ]*|)(\]\])/g, '[[$2$1$4$3');
regex(/\[\[W([^\]\|]*)\|(w)\1([^-\] ]*|)(\]\])/g, '[[$2$1$4$3');
regex(/\[\[X([^\]\|]*)\|(x)\1([^-\] ]*|)(\]\])/g, '[[$2$1$4$3');
regex(/\[\[Y([^\]\|]*)\|(y)\1([^-\] ]*|)(\]\])/g, '[[$2$1$4$3');
regex(/\[\[Z([^\]\|]*)\|(z)\1([^-\] ]*|)(\]\])/g, '[[$2$1$4$3');
regex(/\[\[([^\]\|]*)\|\1([^-\] ]*|)(\]\])/gi, '[[$1$3$2');
regex(/\[\[([^\[\]\(\)\|:]*)( \((?:\d{4} |)film\))(\]\])/gi, '\'\'[[$1$2|$1$3\'\'');
regex(/\[\[([^\[\]\(\)\|:]*)( \([^\[\]\(\)\|]*(?:album|film|magazine|newspaper|song|\bEP)\))(\]\])/g, '[[$1$2|$1$3'); //adding piping to album|film|magazine dabbed by parentheticals
// regex(/([^"]\[\[)([^\[\]\(\)\|:]*)( \([^\[\]\(\)\|]*\))(\]\])(?![\s\n])/gi, '$1$2$3|$2$4'); //ensure songs titles not piped by default, but disabled due to false removal from visible disambiguators
// deprecated parameters in citation templates
Line 706 ⟶ 729:
}
function Ohc_downcase_headings(){
//cleanup of headings per MOSHEAD before complete downcasing (most code is copied from other parts of the script)
Line 715 ⟶ 740:
regex(/(==[ ]?(?:[^\[\n=]*))\[\[[^\|\]]+?\|([^\]]+?)\]\]((?:[^\[=\n]*|)[ ]?==)/gi, '$1$2$3');
regex(/(==[ ]?(?:[^\[\n=]*))\[\[(?:[^\|\]]+?\||)([^\]]+?)\]\]([^\[\|]*)\[\[(?:[^\|\]]+?\||)([^\]]+?)\]\](?:([^\[\|]*)\[\[(?:[^\|\]]+?\||)([^\]]+?)\]\]|)((?:[^\[=\n]*|)[ ]?==)/gi, '$1$2$3$4$5$6$7');
//original code
Line 755 ⟶ 777:
regex(/(\d[]*)(Cr App R)(.)/g, protect_function);
regex(/(.)(On a Friday)(.)/g, protect_function);
regex(/(.)(Not On Our Watch Project)(.)/g, protect_function);
regex(/(.)(Octopussy and the living daylights)(.)/gi, protect_function);
regex(/(.)(\'?Carry On [A-Z][a-z]*)(.)/g, protect_function);
|