User:Lightmouse/monobook.js/script.js: Difference between revisions

Content deleted Content added
No edit summary
mNo edit summary
 
(12 intermediate revisions by 4 users not shown)
Line 1:
//See [[Wikipedia:Requests_for_arbitration/Date_delinking#Temporary_injunction|Date delinking arbitration - Temporary injunction]]
//Quote created on 22 January 2009 (it may have changed when you read this):
//************************************************************************************
//"Until this case is decided or otherwise directed by the Arbitration Committee,
//all editors are instructed not to engage in any program of mass linking or delinking
//of dates in existing articles, including but not limited to through the use of bots,
//scripts, tools, or otherwise. This injunction is entered as an interim measure and
//does not reflect any prejudgment of any aspect of the case. The Clerk will notify the
//parties of this temporary injunction and post a note of it on the appropriate policy page(s).
//Passed 10 to 0 at 11:52, 13 January 2009 (UTC)"
//************************************************************************************
 
 
//'''Instructions for installation'''
//*EITHER: If you have a [[Special:Mypage/monobook.js|monobook]] already, go to it, click "edit this page", and paste in this string underneath your existing script:
Line 28 ⟶ 15:
//*Leave a note at the article talk page if editors need to negotiate which format to use, or need to be alerted to any other date-related issues.
//*Click on "Save page": it's done.
 
function make_dates_bold(){
var txt=document.editform.wpTextbox1;
 
//process date ranges containing a hyphen
txt.value=txt.value.replace(/\*\s?((?:January|February|March|April|May|June|July|August|September|October|November|December) \d\d?\s?[-–]\s?(?:January|February|March|April|May|June|July|August|September|October|November|December) \d\d?)\s?:\s?/gi, '* \'\'\'$1:\'\'\' ');
 
//process date ranges containing a hyphen
txt.value=txt.value.replace(/\*\s?((?:January|February|March|April|May|June|July|August|September|October|November|December) \d\d?\s?[-–]\s?\d\d?)\s?:\s?/gi, '* \'\'\'$1:\'\'\' ');
 
 
//protect date ranges containing a hyphen
txt.value=txt.value.replace(/\*\s?((?:January|February|March|April|May|June|July|August|September|October|November|December) \d\d?\s?)[-–](\s?(?:January|February|March|April|May|June|July|August|September|October|November|December) \d\d?)\s?:\s?/gi, '$1xx$2');
txt.value=txt.value.replace(/\*\s?((?:January|February|March|April|May|June|July|August|September|October|November|December) \d\d?\s?)[-–](\s?\d\d?)\s?:\s?/gi, '$1xx$2');
 
 
 
//process dates containing a hyphen
txt.value=txt.value.replace(/\*\s?((?:January|February|March|April|May|June|July|August|September|October|November|December) \d\d?\s?)[-–]\s?/gi, '* \'\'\'$1:\'\'\' ');
 
//unprotect date ranges containing a hyphen
txt.value=txt.value.replace(/\*\s?((?:January|February|March|April|May|June|July|August|September|October|November|December) \d\d?\s?)xx(\s?(?:January|February|March|April|May|June|July|August|September|October|November|December) \d\d?)\s?:\s?/gi, '$1–$2');
txt.value=txt.value.replace(/\*\s?((?:January|February|March|April|May|June|July|August|September|October|November|December) \d\d?\s?)xx(\s?\d\d?)\s?:\s?/gi, '$1–$2');
 
//process other dates
txt.value=txt.value.replace(/\*\s?((?:January|February|March|April|May|June|July|August|September|October|November|December) \d\d?)\s?:\s?/gi, '* \'\'\'$1:\'\'\' ');
 
 
edit_summary();
}
 
function fix_common_errors() {
var txt=document.editform.wpTextbox1;
//first add template
//if (txt.value.search(/\{\{template\}\}/gi) == -1)
//{
//txt.value='\{\{template\}\}\r\n'+txt.value;
//}
 
Line 42 ⟶ 59:
 
//fix 'bda' template redirect
txt.value=txt.value.replace(/\{\{bda\|([^}]+)\}\}/gi, '\{\{birth date and age|$1\}\}');
 
txt.value=txt.value.replace(/(\[\[)\s([^\]]*\]\])/gi, '$1$2');
Line 56 ⟶ 73:
 
//remove leading zeros from dts templates
txt.value=txt.value.replace(/(\{\{dts\d?\|[^}]*\|)0([^}]*\}\})/gi, '$1$2');
 
//delink ISO dates
Line 65 ⟶ 82:
 
//remove templates that links launch year, baseball year etc
// txt.value=txt.value.replace(/\{\{(?:avyear|by|fy|ly|scy|sdy)\|(\d{1,4})\}\}/gi, '$1');
 
//remove dts1 template that links ISO dates
txt.value=txt.value.replace(/\{\{dts1\|(\d{4}-\d\d-\d\d)\}\}/gi, '$1');
 
// century
Line 161 ⟶ 178:
txt.value=txt.value.replace(/(\[\[(?:January|February|March|April|May|June|July|August|September|October|November|December)\s(?:[0123][\d]|[\d])\]\]),\s\[\[(\d{1,4})\sin\s[^\]]{1,32}\]\]/gi, '$1 $2');
txt.value=txt.value.replace(/(\[\[(?:[0123][\d]|[\d])\s(?:January|February|March|April|May|June|July|August|September|October|November|December)\]\])\s\[\[(\d{1,4})\sin\s[^\]]{1,32}\]\]/gi, '$1 $2');
txt.value=txt.value.replace(/(\[\[(?:[0123][\d]|[\d])\s(?:January|February|March|April|May|June|July|August|September|October|November|December)\]\])\s\{\{(?:avyear|by|fy|ly|scy|sdy)\|(\d{1,4})\}\}/gi, '$1 [[$2]]');
txt.value=txt.value.replace(/(\[\[(?:January|February|March|April|May|June|July|August|September|October|November|December)\s(?:[0123][\d]|[\d])\]\]),\s\{\{(?:avyear|by|fy|ly|scy|sdy)\|(\d{1,4})\}\}/gi, '$1 [[$2]]');
 
}
Line 203 ⟶ 220:
txt.value=txt.value.replace(/(\d) (\[\[Fahrenheit|°F\]\])/gi, '$1 $2');
txt.value=txt.value.replace(/(\d)(?:\s|)(\[\[Fahrenheit|°F\]\])/gi, '$1 $2');
txt.value=txt.value.replace(/([^\d\(\)\/\\]\s)(-?\d[\d,\.]*)(?:\s|-| |)°?F([:;,\.?!]?\s[^\d\(\)\/\\])/g, '$1\{\{convert|$2|°F|°C|abbr=on\}\}$3');
txt.value=txt.value.replace(/([^\d\(\)\/\\]\s)(-?\d[\d,\.]*)(?:\s|-| |)(?:deg|degree|degrees)(?:\s|-| |)Fahrenheit([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1\{\{convert|$2|°F|°C\}\}$3');
 
// Convert &sup to superscript
Line 317 ⟶ 334:
txt.value=txt.value.replace(/(\d)(\s|-)square(\s|-)ft/gi, '$1 sq ft');
txt.value=txt.value.replace(/(\d) square ft/gi, '$1 sq ft');
txt.value=txt.value.replace(/([^\d\(\)\/\\]\s)(\d[\d,\.]*)(?:\s|-| |)sq(?:\s|-| |)ft([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1\{\{convert|$2|sqft|m2|abbr=on\}\}$3');
txt.value=txt.value.replace(/([^\d\(\)\/\\]\s)(\d[\d,\.]*)(?:\s|-| |)square(?:\s|-| |)feet([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1\{\{convert|$2|sqft|m2\}\}$3');
txt.value=txt.value.replace(/([^\d\(\)\/\\]\s)(\d[\d,\.]*)(?:\s|-| |)square(?:\s|-| |)foot([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1\{\{convert|$2|sqft|m2|adj=on\}\}$3');
txt.value=txt.value.replace(/([^\d\(\)\/\\]\s)([\d,]+)(?:\s|-| |)thousand(?:\s|-| |)(?:sq|square)\.?(?:\s|-| |)ft([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1\{\{convert|$2000|sqft|m2|abbr=on\}\}$3');
txt.value=txt.value.replace(/([^\d\(\)\/\\]\s)([\d,]+)(?:\s|-| |)thousand(?:\s|-| |)(?:sq|square)\.?(?:\s|-| |)feet([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1\{\{convert|$2000|sqft|m2\}\}$3');
txt.value=txt.value.replace(/([^\d\(\)\/\\]\s)([\d,]+)(?:\s|-| |)thousand(?:\s|-| |)(?:sq|square)\.?(?:\s|-| |)foot([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1\{\{convert|$2000|sqft|m2|adj=on\}\}$3');
txt.value=txt.value.replace(/([^\d\(\)\/\\]\s)([\d,]+)(?:\s|-| |)million(?:\s|-| |)(?:sq|square)\.?(?:\s|-| |)ft([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1\{\{convert|$2000000|sqft|m2|abbr=on\}\}$3');
txt.value=txt.value.replace(/([^\d\(\)\/\\]\s)([\d,]+)(?:\s|-| |)million(?:\s|-| |)(?:sq|square)\.?(?:\s|-| |)feet([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1\{\{convert|$2000000|sqft|m2\}\}$3');
txt.value=txt.value.replace(/([^\d\(\)\/\\]\s)([\d,]+)(?:\s|-| |)million(?:\s|-| |)(?:sq|square)\.?(?:\s|-| |)foot([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1\{\{convert|$2000000|sqft|m2|adj=on\}\}$3');
txt.value=txt.value.replace(/([^\d\(\)\/\\]\s)([\d,]+)\.(\d)(?:\s|-| |)million(?:\s|-| |)(?:sq|square)\.?(?:\s|-| |)ft([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1\{\{convert|$2$300000|sqft|m2|abbr=on\}\}$4');
txt.value=txt.value.replace(/([^\d\(\)\/\\]\s)([\d,]+)\.(\d)(?:\s|-| |)million(?:\s|-| |)(?:sq|square)\.?(?:\s|-| |)feet([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1\{\{convert|$2$300000|sqft|m2\}\}$4');
txt.value=txt.value.replace(/([^\d\(\)\/\\]\s)([\d,]+)\.(\d)(?:\s|-| |)million(?:\s|-| |)(?:sq|square)\.?(?:\s|-| |)foot([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1\{\{convert|$2$300000|sqft|m2|adj=on\}\}$4');
txt.value=txt.value.replace(/([^\d\(\)\/\\]\s)([\d,]+)\.(\d\d)(?:\s|-| |)million(?:\s|-| |)(?:sq|square)\.?(?:\s|-| |)ft([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1\{\{convert|$2$30000|sqft|m2|abbr=on\}\}$4');
txt.value=txt.value.replace(/([^\d\(\)\/\\]\s)([\d,]+)\.(\d\d)(?:\s|-| |)million(?:\s|-| |)(?:sq|square)\.?(?:\s|-| |)feet([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1\{\{convert|$2$30000|sqft|m2\}\}$4');
txt.value=txt.value.replace(/([^\d\(\)\/\\]\s)([\d,]+)\.(\d\d)(?:\s|-| |)million(?:\s|-| |)(?:sq|square)\.?(?:\s|-| |)foot([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1\{\{convert|$2$30000|sqft|m2|adj=on\}\}$4');
 
//square foot: singular
txt.value=txt.value.replace(/([^\d\(\)\/\\]\s)(\d[\d,\.]*)(?:\s|-| |)(?:square\sfoot|\[\[square\sfoot\]\])([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1\{\{convert|$2|sqft|m2|adj=on\}\}$3');
 
//square foot: plural
txt.value=txt.value.replace(/([^\d\(\)\/\\]\s)(\d[\d,\.]*)(?:\s|-| |)(?:square\sfeet|\[\[square\sfeet\]\])([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1\{\{convert|$2|sqft|m2\}\}$3');
 
//feet per second
Line 343 ⟶ 360:
txt.value=txt.value.replace(/([^\d\(\)\/\\]\s)(\d[\d,\.]*) (?:ft\/second|ft\/sec)([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1$2 ft/s$3');
//feet per second:plural
txt.value=txt.value.replace(/([^\d\(\)\/\\]\s)(\d[\d,\.]*)(?:\s|-| |)feet\sper\ssecond([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1\{\{convert|$2|ft/s|m/s\}\}$3');
//feet per second:singular
txt.value=txt.value.replace(/([^\d\(\)\/\\]\s)(\d[\d,\.]*)(?:\s|-| |)foot\sper\ssecond([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1\{\{convert|$2|ft/s|m/s|adj=on\}\}$3');
//feet per second:abbreviated
txt.value=txt.value.replace(/([^\d\(\)\/\\]\s)(\d[\d,\.]*)(?:\s|-| |)ft\/s([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1\{\{convert|$2|ft/s|m/s|abbr=on\}\}$3');
 
// foot and inch
Line 360 ⟶ 377:
txt.value=txt.value.replace(/yd\.\)/gi, 'yd)');
//yards: plural
txt.value=txt.value.replace(/([^\d\(\)\/\\]\s)(\d[\d,\.]*)(?:\s|-| |)(?:yards|\[\[yard\]\]s|\[\[yards\]\])([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1\{\{convert|$2|yd|m\}\}$3');
//yards: singular
txt.value=txt.value.replace(/([^\d\(\)\/\\]\s)(\d[\d,\.]*)(?:\s|-| |)(?:yard|\[\[yard\]\])([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1\{\{convert|$2|yd|m|adj=on\}\}$3');
//yards: abbreviated
txt.value=txt.value.replace(/([^\d\(\)\/\\]\s)(\d[\d,\.]*)(?:\s|-| |)yd([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1\{\{convert|$2|yd|m|abbr=on\}\}$3');
//yards: in full
txt.value=txt.value.replace(/([^y]\sone(?:\s|-| |)yards?)([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1 (1 m)$2');
Line 394 ⟶ 411:
 
//nautical mile - rename 'miles' as 'nautical miles' when followed by knots or conversion code
txt.value=txt.value.replace(/(\d)(?:\s|-| |)miles\s(?:at|@)\s([\d\.]{1,9}(?:\s|-| |)knots|\{\{convert)/gi, '$1 nautical miles at $2');
txt.value=txt.value.replace(/(\d)(\s|-| )(?:mi|nm|nmi)\s(?:at|@)\s([\d\.]{1,9}(?:\s|-| |)knots|\{\{convert)/gi, '$1$2nmi at $3');
//nautical mile: plural unlinked
txt.value=txt.value.replace(/([^\d\(\)\/\\]\s)(\d[\d,\.]*)(?:\s|-| |)nautical(?:\s|-| |)miles([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1\{\{convert|$2|nmi|km\}\}$3');
//nautical mile: plural linked with 's' inside link
txt.value=txt.value.replace(/([^\d\(\)\/\\]\s)(\d[\d,\.]*)(?:\s|-| |)\[\[nautical(?:\s|-| |)miles\]\]([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1\{\{convert|$2|nmi|km\}\}$3');
//nautical mile: plural linked with 's' outside link
txt.value=txt.value.replace(/([^\d\(\)\/\\]\s)(\d[\d,\.]*)(?:\s|-| |)\[\[nautical(?:\s|-| |)mile\]\]s([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1\{\{convert|$2|nmi|km\}\}$3');
//nautical mile: singular unlinked
txt.value=txt.value.replace(/([^\d\(\)\/\\]\s)(\d[\d,\.]*)(?:\s|-| |)nautical(?:\s|-| |)mile([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1\{\{convert|$2|nmi|km|adj=on\}\}$3');
//nautical mile: singular linked
txt.value=txt.value.replace(/([^\d\(\)\/\\]\s)(\d[\d,\.]*)(?:\s|-| |)\[\[nautical(?:\s|-| |)mile\]\]([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1\{\{convert|$2|nmi|km|adj=on\}\}$3');
//nautical mile: abbreviated
txt.value=txt.value.replace(/([^\d\(\)\/\\]\s)(\d[\d,\.]*)(?:\s|-| |)(?:\[\[nautical\smile\|nmi?\]\]|nmi)([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1\{\{convert|$2|nmi|km|abbr=on\}\}$3');
//nautical mile: in full
txt.value=txt.value.replace(/([^y]\sone(?:\s|-| |)nautical(?:\s|-| |)miles?)([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1 (1.9 km)$2');
Line 431 ⟶ 448:
 
//knot - plural
txt.value=txt.value.replace(/([^\d\(\)\/\\]\s)(\d[\d,\.]*)(?:\s|-| |)(?:knots|\[\[knot\s\(speed\)\|(?:knots\]\]|knot\]\]s|kts\]\]|kt\]\]s))([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1\{\{convert|$2|kn|km/h\}\}$3');
//knot - singular
txt.value=txt.value.replace(/([^\d\(\)\/\\]\s)(\d[\d,\.]*)(?:\s|-| |)(?:knot|\[\[knot\s\(speed\)\|(?:knot|kt|kn)\]\])([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1\{\{convert|$2|kn|km/h|adj=on\}\}$3');
//knot - abbreviation
txt.value=txt.value.replace(/([^\d\(\)\/\\]\s)(\d[\d,\.]*)(?:\s|-| |)(?:kts?|\[\[knot\s\(speed\)\|(?:kt|kn)\]\])([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1\{\{convert|$2|kn|km/h|abbr=on\}\}$3');
 
//mile - delink this common unit
Line 445 ⟶ 462:
txt.value=txt.value.replace(/(miles?)\s(per)/gi, '$1xx$2');
//miles: plural
txt.value=txt.value.replace(/([^\d\(\)\/\\]\s)(\d[\d,\.]*)(?:\s|-| |)(?:miles|\[\[miles\]\]|\[\[mile\]\]s)([:;,\.?!]?\s[^\d\(\)\/\\])/g, '$1\{\{convert|$2|mi|km\}\}$3');
//miles: singular
txt.value=txt.value.replace(/([^\d\(\)\/\\]\s)(\d[\d,\.]*)(?:\s|-| |)(?:mile|\[\[mile\]\])([:;,\.?!]?\s[^\d\(\)\/\\])/g, '$1\{\{convert|$2|mi|km|adj=on\}\}$3');
//miles: abbreviated
txt.value=txt.value.replace(/([^\d\(\)\/\\]\s)(\d[\d,\.]*)(?:\s|-| |)mi([:;,\.?!]?\s[^\d\(\)\/\\])/g, '$1\{\{convert|$2|mi|km|abbr=on\}\}$3');
//miles: in full
txt.value=txt.value.replace(/([^y]\sone(?:\s|-| |)miles?)([:;,\.?!]?\s[^\d\(\)\/\\])/g, '$1 (1.6 km)$2');
Line 476 ⟶ 493:
 
//mile per hour
txt.value=txt.value.replace(/([^\d\(\)\/\\]\s)(\d[\d,\.]*)(?:\s|-| |)m\.?p\.?h([:;,\.?!]?\s[^\d\(\)\/\\])/g, '$1\{\{convert|$2|mi/h|km/h|abbr=on\}\}$3');
 
// square mile
Line 484 ⟶ 501:
txt.value=txt.value.replace(/(sq)(?:\s|-| |)(mile)/gi, '$1uare $2');
// square mile:plural
txt.value=txt.value.replace(/([^\d\(\)\/\\]\s)(\d[\d,\.]*)(?:\s|-| |)square(?:\s|-| |)miles([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1\{\{convert|$2|sqmi|km2\}\}$3');
// square mile:singular
txt.value=txt.value.replace(/([^\d\(\)\/\\]\s)(\d[\d,\.]*)(?:\s|-| |)square(?:\s|-| |)mile([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1\{\{convert|$2|sqmi|km2|adj=on\}\}$3');
// square mile:abbreviated
txt.value=txt.value.replace(/([^\d\(\)\/\\]\s)(\d[\d,\.]*)(?:\s|-| |)sq(?:\s|-| |)mi([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1\{\{convert|$2|sqmi|km2|abbr=on\}\}$3');
 
//acre foot:plural
txt.value=txt.value.replace(/([^\d\(\)\/\\]\s)(\d+)\.(\d)(?:\s|-| |)million(?:\s|-| |)acre(?:\s|-| |)feet([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1\{\{convert|$2$300000|acre feet\}\}$4');
txt.value=txt.value.replace(/([^\d\(\)\/\\]\s)(\d+)\.(\d)(?:\s|-| |)MAF([:;,\.?!]?\s[^\d\(\)\/\\])/g, '$1\{\{convert|$2$300000|acre feet\}\}$4');
txt.value=txt.value.replace(/([^\d\(\)\/\\]\s)(\d+)\.(\d\d)(?:\s|-| |)million(?:\s|-| |)acre(?:\s|-| |)feet([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1\{\{convert|$2$30000|acre feet\}\}$4');
txt.value=txt.value.replace(/([^\d\(\)\/\\]\s)(\d+)\.(\d\d)(?:\s|-| |)MAF([:;,\.?!]?\s[^\d\(\)\/\\])/g, '$1\{\{convert|$2$30000|acre feet\}\}$4');
txt.value=txt.value.replace(/([^\d\(\)\/\\]\s)(\d+)(?:\s|-| |)million(?:\s|-| |)acre(?:\s|-| |)feet([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1\{\{convert|$2000000|acre feet\}\}$3');
txt.value=txt.value.replace(/([^\d\(\)\/\\]\s)(\d+)(?:\s|-| |)MAF([:;,\.?!]?\s[^\d\(\)\/\\])/g, '$1\{\{convert|$2000000|acre feet\}\}$3');
 
txt.value=txt.value.replace(/([^\d\(\)\/\\]\s)(\d[\d,\.]*)(?:\s|-| |)acre(?:\s|-| |)feet([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1\{\{convert|$2|acre feet\}\}$3');
txt.value=txt.value.replace(/([^\d\(\)\/\\]\s)(\d[\d,\.]*)(?:\s|-| |)\[\[acre(?:\s|-| |)foot\|acre(?:\s|-| |)feet\]\]([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1\{\{convert|$2|acre feet\}\}$3');
//acre foot:singular
txt.value=txt.value.replace(/([^\d\(\)\/\\]\s)(\d[\d,\.]*)(?:\s|-| |)acre(?:\s|-| |)foot([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1\{\{convert|$2|acre feet|adj=on\}\}$3');
txt.value=txt.value.replace(/([^\d\(\)\/\\]\s)(\d[\d,\.]*)(?:\s|-| |)\[\[acre(?:\s|-| |)foot\|acre(?:\s|-| |)feet\]\]([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1\{\{convert|$2|acre feet|adj=on\}\}$3');
//acre foot:abbreviation
txt.value=txt.value.replace(/([^\d\(\)\/\\]\s)(\d[\d,\.]*)(?:\s|-| |)(?:acre|ac\.?)(?:\s|-| |)(?:foot|feet|ft)([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1\{\{convert|$2|acre ft|abbr=on\}\}$3');
txt.value=txt.value.replace(/([^\d\(\)\/\\]\s)(\d[\d,\.]*)(?:\s|-| |)\[\[acre(?:\s|-| |)foot\|acre(?:\s|-| |)ft\]\]([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1\{\{convert|$2|acre ft|abbr=on\}\}$3');
txt.value=txt.value.replace(/([^\d\(\)\/\\]\s)(\d[\d,\.]*)(?:\s|-| |)\[\[acre(?:\s|-| |)ft\]\]([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1\{\{convert|$2|acre ft|abbr=on\}\}$3');
 
//acre
Line 513 ⟶ 530:
txt.value=txt.value.replace(/(\d)-(acre)/gi, '$1 $2');
txt.value=txt.value.replace(/(\d)(?:\s|-| |)(?:surface|square)(?:\s|-| |)acre/gi, '$1 acre');
txt.value=txt.value.replace(/([^\d\(\)\/\\]\s)([\d,]+)(?:\s|-| |)thousand(?:\s|-| |)(?:acres|\[\[acres\]\]|\[\[acre\]\]s)([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1\{\{convert|$2000|acre|km2\}\}$3');
txt.value=txt.value.replace(/([^\d\(\)\/\\]\s)([\d,]+)(?:\s|-| |)thousand(?:\s|-| |)(?:acre|\[\[acre\]\])([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1\{\{convert|$2000|acre|km2|adj=on\}\}$3');
txt.value=txt.value.replace(/([^\d\(\)\/\\]\s)([\d,]+)(?:\s|-| |)million(?:\s|-| |)(?:acres|\[\[acres\]\]|\[\[acre\]\]s)([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1\{\{convert|$2|e6acre|km2\}\}$3');
txt.value=txt.value.replace(/([^\d\(\)\/\\]\s)([\d,]+)(?:\s|-| |)million(?:\s|-| |)(?:acre|\[\[acre\]\])([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1\{\{convert|$2|e6acre|km2|adj=on\}\}$3');
txt.value=txt.value.replace(/([^\d\(\)\/\\]\s)([\d,]+)\.(\d)(?:\s|-| |)million(?:\s|-| |)(?:acres|\[\[acres\]\]|\[\[acre\]\]s)([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1\{\{convert|$2$300000|acre|km2\}\}$4');
txt.value=txt.value.replace(/([^\d\(\)\/\\]\s)([\d,]+)\.(\d)(?:\s|-| |)million(?:\s|-| |)(?:acre|\[\[acre\]\])([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1\{\{convert|$2$300000|acre|km2|adj=on\}\}$4');
txt.value=txt.value.replace(/([^\d\(\)\/\\]\s)([\d,]+)\.(\d\d)(?:\s|-| |)million(?:\s|-| |)(?:acres|\[\[acres\]\]|\[\[acre\]\]s)([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1\{\{convert|$2$30000|acre|km2\}\}$4');
txt.value=txt.value.replace(/([^\d\(\)\/\\]\s)([\d,]+)\.(\d\d)(?:\s|-| |)million(?:\s|-| |)(?:acre|\[\[acre\]\])([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1\{\{convert|$2$30000|acre|km2|adj=on\}\}$4');
txt.value=txt.value.replace(/([^y]\sone(?:\s|-| |)million(?:\s|-| |)acres?)([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1 (4,000 km²)$2');
txt.value=txt.value.replace(/(\sa(?:\s|-| |)million(?:\s|-| |)acres?)([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1 (4,000 km²)$2');
Line 534 ⟶ 551:
 
//acre:plural
txt.value=txt.value.replace(/([^\d\(\)\/\\]\s)([\d,]+\d\d[\d\.]*)(?:\s|-| |)(?:acres|\[\[acres\]\]|\[\[acre\]\]s)([:;,\.?!]?\s[^\d\(\)\/\\])/g, '$1\{\{convert|$2|acre|km2\}\}$3');
txt.value=txt.value.replace(/([^\d\(\)\/\\]\s)(\d?\d\.\d+|\d?\d)(?:\s|-| |)(?:acres|\[\[acres\]\]|\[\[acre\]\]s)([:;,\.?!]?\s[^\d\(\)\/\\])/g, '$1\{\{convert|$2|acre|m2\}\}$3');
 
//acre:singular
txt.value=txt.value.replace(/([^\d\(\)\/\\]\s)([\d,]+\d\d[\d\.]*)(?:\s|-| |)(?:acre|\[\[acre\]\])([:;,\.?!]?\s[^\d\(\)\/\\])/g, '$1\{\{convert|$2|acre|km2|adj=on\}\}$3');
txt.value=txt.value.replace(/([^\d\(\)\/\\]\s)(\d?\d\.\d+|\d?\d)(?:\s|-| |)(?:acre|\[\[acre\]\])([:;,\.?!]?\s[^\d\(\)\/\\])/g, '$1\{\{convert|$2|acre|m2|adj=on\}\}$3');
 
//undo protection for acre feet
Line 552 ⟶ 569:
txt.value=txt.value.replace(/ft[\s-.·•\/]{1,2}lbf([^\|])/gi, 'ft·lbf$1');
txt.value=txt.value.replace(/ft[\s-.·•\/]{1,2}lbff/gi, 'ft·lbf');
txt.value=txt.value.replace(/([^\d\(\)\/\\]\s)(\d[\d,\.]*)(?:\s|-| |)pounds?(?:\s|-| |)feet([:;,\.?!]?\s[^\d\(\)\/\\])/g, '$1\{\{convert|$2|ft.lbf|N.m\}\}$3');
txt.value=txt.value.replace(/([^\d\(\)\/\\]\s)(\d[\d,\.]*)(?:\s|-| |)foot(?:\s|-| |)pounds([:;,\.?!]?\s[^\d\(\)\/\\])/g, '$1\{\{convert|$2|ft.lbf|N.m\}\}$3');
txt.value=txt.value.replace(/([^\d\(\)\/\\]\s)(\d[\d,\.]*)(?:\s|-| |)pound(?:\s|-| |)foot([:;,\.?!]?\s[^\d\(\)\/\\])/g, '$1\{\{convert|$2|ft.lbf|N.m|adj=on\}\}$3');
txt.value=txt.value.replace(/([^\d\(\)\/\\]\s)(\d[\d,\.]*)(?:\s|-| |)foot(?:\s|-| |)pound([:;,\.?!]?\s[^\d\(\)\/\\])/g, '$1\{\{convert|$2|ft.lbf|N.m|adj=on\}\}$3');
txt.value=txt.value.replace(/([^\d\(\)\/\\]\s)(\d[\d,\.]*)(?:\s|-| |)ft.lbf([:;,\.?!]?\s[^\d\(\)\/\\])/g, '$1\{\{convert|$2|ft.lbf|N.m|abbr=on\}\}$3');
 
// pound force
txt.value=txt.value.replace(/([^\d\(\)\/\\]\s)(\d[\d,\.]*)(\s|-| |)lbs?.?\s(thrust|of\sthrust|force|of\sforce)([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1$2$3lbf $4$5');
txt.value=txt.value.replace(/([^\d\(\)\/\\]\s)(\d[\d,\.]*000)(?:\s|-| |)pounds\sforce([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1\{\{convert|$2|lbf|kN\}\}$3');
txt.value=txt.value.replace(/([^\d\(\)\/\\]\s)(\d[\d,\.]*)(?:\s|-| |)pounds\sforce([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1\{\{convert|$2|lbf|N\}\}$3');
txt.value=txt.value.replace(/([^\d\(\)\/\\]\s)(\d[\d,\.]*000)(?:\s|-| |)pound\sforce([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1\{\{convert|$2|lbf|kN|adj=on\}\}$3');
txt.value=txt.value.replace(/([^\d\(\)\/\\]\s)(\d[\d,\.]*)(?:\s|-| |)pound\sforce([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1\{\{convert|$2|lbf|N|adj=on\}\}$3');
txt.value=txt.value.replace(/([^\d\(\)\/\\]\s)(\d[\d,\.]*000)(?:\s|-| |)lbf([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1\{\{convert|$2|lbf|kN|abbr=on\}\}$3');
txt.value=txt.value.replace(/([^\d\(\)\/\\]\s)(\d[\d,\.]*)(?:\s|-| |)lbf([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1\{\{convert|$2|lbf|abbr=on\}\}$3');
 
// pound weight. Parsed after foot pound and pound force
Line 573 ⟶ 590:
txt.value=txt.value.replace(/(\d\+?)\s?lbs?([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1 lb$2');
txt.value=txt.value.replace(/(\d) lbs?([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1 lb$2');
txt.value=txt.value.replace(/([^\d\(\)\/\\]\s)(\d[\d,\.]*)(?:\s|-| |)lb([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1\{\{convert|$2|lb|abbr=on\}\}$3');
//pounds and ounces - plural
txt.value=txt.value.replace(/([^\d\(\)\/\\]\s)(\d[\d,\.]*)(?:\s|-| |)pounds(?:\s|-| |)(\d[\d,\.]*)(?:\s|-| |)ounces?([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1\{\{convert|$2|lb|$3|oz|kg\}\}$4');
//pounds and ounces - singular
txt.value=txt.value.replace(/([^\d\(\)\/\\]\s)(\d[\d,\.]*)(?:\s|-| |)pound(?:\s|-| |)(\d[\d,\.]*)(?:\s|-| |)ounces?([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1\{\{convert|$2|lb|$3|oz|kg|adj=on\}\}$4');
//pounds and ounces - abbreviated
txt.value=txt.value.replace(/([^\d\(\)\/\\]\s)(\d[\d,\.]*)(?:\s|-| |)lbs?\.?,?(?:\s|-| |)(\d[\d,\.]*)(?:\s|-| |)oz\.?([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1\{\{convert|$2|lb|$3|oz|kg|abbr=on\}\}$4');
 
//foot and inch: plural
txt.value=txt.value.replace(/([^\d\(\)\/\\]\s)(\d[\d,\.]*)(?:\s|-| |)feet\.?(?:\s|-| |)(\d[\d,\.]*)(?:\s|-| |)(?:in|ins|inch|inches)\.?([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1\{\{convert|$2|ft|$3|in|m\}\}$4');
//foot and inch: singular
txt.value=txt.value.replace(/([^\d\(\)\/\\]\s)(\d[\d,\.]*)(?:\s|-| |)foot\.?(?:\s|-| |)(\d[\d,\.]*)(?:\s|-| |)(?:in|ins|inch|inches)\.?([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1\{\{convert|$2|ft|$3|in|m|adj=on\}\}$4');
//foot and inch: abbreviated
txt.value=txt.value.replace(/([^\d\(\)\/\\]\s)(\d[\d,\.]*)(?:\s|-| |)ft\.?(?:\s|-| |)(\d[\d,\.]*)(?:\s|-| |)(?:in|ins|inch|inches)\.?([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1\{\{convert|$2|ft|$3|in|m|abbr=on\}\}$4');
 
//foot (again). Parsed after 'foot per second' and 'foot pound'
//foot: plural
txt.value=txt.value.replace(/([^\d\(\)\/\\]\s)(\d[\d,\.]*)(?:\s|-| |)feet([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1\{\{convert|$2|ft|m\}\}$3');
txt.value=txt.value.replace(/([^\d\(\)\/\\]\s)(\d[\d,\.]*)(?:\s|-| |)linear(?:\s|-| |)feet([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1\{\{convert|$2|ft|m\}\}$3');
//foot: singular
txt.value=txt.value.replace(/([^\d\(\)\/\\]\s)(\d[\d,\.]*)(?:\s|-| |)foot([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1\{\{convert|$2|ft|m|adj=on\}\}$3');
//foot: abbreviated
txt.value=txt.value.replace(/([^\d\(\)\/\\]\s)(\d[\d,\.]*)(?:\s|-| |)ft\.?([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1\{\{convert|$2|ft|m|abbr=on\}\}$3');
 
//inch: plural
txt.value=txt.value.replace(/([^\Wt'’]\s)(\d[\d,\.]*)(?:\s|-| |)inches([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1\{\{convert|$2|in|mm\}\}$3');
// inch: plural with number in words
txt.value=txt.value.replace(/([^ty]\sthree(?:\s|-| |)(?:inches|\[\[inches\]\]))([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1 (76 mm) $2');
Line 615 ⟶ 632:
txt.value=txt.value.replace(/([^ty]\ssixteen(?:\s|-| |)(?:inches|\[\[inches\]\]))([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1 (406 mm) $2');
//inch: singular
txt.value=txt.value.replace(/([^\Wt'’]\s)(\d[\d,\.]*)(?:\s|-| |)(?:inch|\[\[inch\]\])([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1\{\{convert|$2|in|mm|adj=on\}\}$3');
txt.value=txt.value.replace(/({convert\|\d+\|(?:in|mm|cm)[^\}]*)\|lk=(?:on|in|out)/g, '$1');
// inch: singular with number in words
Line 638 ⟶ 655:
txt.value=txt.value.replace(/(\d) (horsepower|hp|bhp|ihp|shp)([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1 $2$3');
txt.value=txt.value.replace(/(\d)(?:\s|-|)horse(?:\s|-|)power([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1 horsepower$2');
txt.value=txt.value.replace(/([^\d\(\)\/\\]\s)(\d[\d,\.]*)(?:\s|-| |)(?:horsepower|\[\[horsepower\]\])([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1\{\{convert|$2|hp\}\}$3');
txt.value=txt.value.replace(/([^\d\(\)\/\\]\s)(\d[\d,\.]*)(?:\s|-| |)(indicated(?:\s|-| |)horsepower)([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1\{\{convert|$2|ihp\}\}$4');
txt.value=txt.value.replace(/([^\d\(\)\/\\]\s)(\d[\d,\.]*)(?:\s|-| |)(hp|bhp|ihp|shp)([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1\{\{convert|$2|$3|abbr=on\}\}$4');
 
txt.value=txt.value.replace(/({convert\|\d+\|)horsepower\|/gi, '$1horsepower|');
Line 685 ⟶ 702:
 
//replace other templates with convert template
txt.value=txt.value.replace(/\{\{mi\sto\skm\|(\d{1,9})\}\}/gi, '\{\{convert|$1|mi|km\}\}');
txt.value=txt.value.replace(/\{\{mi\sto\skm\|(\d{1,9})\|round[^\}]{1,5\}\}}/gi, '\{\{convert|$1|mi|km\}\}');
txt.value=txt.value.replace(/\{\{mi2\sto\skm2\|(\d{1,9})\}\}/gi, '\{\{convert|$1|mi|km\}\}');
txt.value=txt.value.replace(/\{\{mi2\sto\skm2\|(\d{1,9})\|round[^\}]{1,5\}\}}/gi, '\{\{convert|$1|mi|km\}\}');
 
//replace rail gauge template
txt.value=txt.value.replace(/\{\{(\d?\d)\s?in\}\}/gi, '\{\{convert|$1|in|mm|0|abbr=on\}\}');
txt.value=txt.value.replace(/\{\{(\d?\d)\s?ft\}\}/gi, '\{\{convert|$1|ft|mm|0|abbr=on\}\}');
txt.value=txt.value.replace(/\{\{(\d?\d)\s?ft\s?(\d?\d)\s?in\}\}/gi, '\{\{convert|$1|ft|$2|in|mm|0|abbr=on\}\}');
txt.value=txt.value.replace(/\{\{(\d?\d)\s?ft\s?(\d?\d\.\d+)\s?in\}\}/gi, '\{\{convert|$1|ft|$2|in|mm|0|abbr=on\}\}');
 
txt.value=txt.value.replace(/(\{\{railgauge\|[^}]+)\|lk=on(\}\})/gi, '$1$2');
txt.value=txt.value.replace(/\{\{railgauge\|(\d?\d)\s?in\}\}/gi, '\{\{convert|$1|in|mm|0|abbr=on\}\}');
txt.value=txt.value.replace(/\{\{railgauge\|(\d?\d)\s?ft\}\}/gi, '\{\{convert|$1|ft|mm|0|abbr=on\}\}');
txt.value=txt.value.replace(/\{\{railgauge\|(\d?\d)\s?ft\s?(\d?\d)\s?in\}\}/gi, '\{\{convert|$1|ft|$2|in|mm|0|abbr=on\}\}');
txt.value=txt.value.replace(/\{\{railgauge\|(\d?\d)\s?ft\s?(\d?\d\.\d+)\s?in\}\}/gi, '\{\{convert|$1|ft|$2|in|mm|0|abbr=on\}\}');
 
txt.value=txt.value.replace(/\{\{railgauge\|24\}\}/gi, '\{\{convert|2|ft|mm|0|abbr=on\}\}');
txt.value=txt.value.replace(/\{\{railgauge\|25\}\}/gi, '\{\{convert|2|ft|1|in|mm|0|abbr=on\}\}');
txt.value=txt.value.replace(/\{\{railgauge\|26\}\}/gi, '\{\{convert|2|ft|2|in|mm|0|abbr=on\}\}');
txt.value=txt.value.replace(/\{\{railgauge\|27\}\}/gi, '\{\{convert|2|ft|3|in|mm|0|abbr=on\}\}');
txt.value=txt.value.replace(/\{\{railgauge\|28\}\}/gi, '\{\{convert|2|ft|4|in|mm|0|abbr=on\}\}');
txt.value=txt.value.replace(/\{\{railgauge\|29\}\}/gi, '\{\{convert|2|ft|5|in|mm|0|abbr=on\}\}');
txt.value=txt.value.replace(/\{\{railgauge\|30\}\}/gi, '\{\{convert|2|ft|6|in|mm|0|abbr=on\}\}');
txt.value=txt.value.replace(/\{\{railgauge\|31\}\}/gi, '\{\{convert|2|ft|7|in|mm|0|abbr=on\}\}');
txt.value=txt.value.replace(/\{\{railgauge\|32\}\}/gi, '\{\{convert|2|ft|8|in|mm|0|abbr=on\}\}');
txt.value=txt.value.replace(/\{\{railgauge\|33\}\}/gi, '\{\{convert|2|ft|9|in|mm|0|abbr=on\}\}');
txt.value=txt.value.replace(/\{\{railgauge\|34\}\}/gi, '\{\{convert|2|ft|10|in|mm|0|abbr=on\}\}');
txt.value=txt.value.replace(/\{\{railgauge\|35\}\}/gi, '\{\{convert|2|ft|11|in|mm|0|abbr=on\}\}');
txt.value=txt.value.replace(/\{\{railgauge\|36\}\}/gi, '\{\{convert|3|ft|mm|0|abbr=on\}\}');
txt.value=txt.value.replace(/\{\{railgauge\|37\}\}/gi, '\{\{convert|3|ft|1|in|mm|0|abbr=on\}\}');
txt.value=txt.value.replace(/\{\{railgauge\|38\}\}/gi, '\{\{convert|3|ft|2|in|mm|0|abbr=on\}\}');
txt.value=txt.value.replace(/\{\{railgauge\|39\}\}/gi, '\{\{convert|3|ft|3|in|mm|0|abbr=on\}\}');
txt.value=txt.value.replace(/\{\{railgauge\|40\}\}/gi, '\{\{convert|3|ft|4|in|mm|0|abbr=on\}\}');
txt.value=txt.value.replace(/\{\{railgauge\|41\}\}/gi, '\{\{convert|3|ft|5|in|mm|0|abbr=on\}\}');
txt.value=txt.value.replace(/\{\{railgauge\|42\}\}/gi, '\{\{convert|3|ft|6|in|mm|0|abbr=on\}\}');
txt.value=txt.value.replace(/\{\{railgauge\|48\}\}/gi, '\{\{convert|4|ft|mm|0|abbr=on\}\}');
txt.value=txt.value.replace(/\{\{railgauge\|49\}\}/gi, '\{\{convert|4|ft|1|in|mm|0|abbr=on\}\}');
txt.value=txt.value.replace(/\{\{railgauge\|50\}\}/gi, '\{\{convert|4|ft|2|in|mm|0|abbr=on\}\}');
txt.value=txt.value.replace(/\{\{railgauge\|51\}\}/gi, '\{\{convert|4|ft|3|in|mm|0|abbr=on\}\}');
txt.value=txt.value.replace(/\{\{railgauge\|52\}\}/gi, '\{\{convert|4|ft|4|in|mm|0|abbr=on\}\}');
txt.value=txt.value.replace(/\{\{railgauge\|53\}\}/gi, '\{\{convert|4|ft|5|in|mm|0|abbr=on\}\}');
txt.value=txt.value.replace(/\{\{railgauge\|54\}\}/gi, '\{\{convert|4|ft|6|in|mm|0|abbr=on\}\}');
txt.value=txt.value.replace(/\{\{railgauge\|55\}\}/gi, '\{\{convert|4|ft|7|in|mm|0|abbr=on\}\}');
txt.value=txt.value.replace(/\{\{railgauge\|56\}\}/gi, '\{\{convert|4|ft|8|in|mm|0|abbr=on\}\}');
txt.value=txt.value.replace(/\{\{railgauge\|57\}\}/gi, '\{\{convert|4|ft|9|in|mm|0|abbr=on\}\}');
txt.value=txt.value.replace(/\{\{railgauge\|58\}\}/gi, '\{\{convert|4|ft|10|in|mm|0|abbr=on\}\}');
txt.value=txt.value.replace(/\{\{railgauge\|59\}\}/gi, '\{\{convert|4|ft|11|in|mm|0|abbr=on\}\}');
txt.value=txt.value.replace(/\{\{railgauge\|60\}\}/gi, '\{\{convert|5|ft|mm|0|abbr=on\}\}');
txt.value=txt.value.replace(/\{\{railgauge\|61\}\}/gi, '\{\{convert|5|ft|1|in|mm|0|abbr=on\}\}');
txt.value=txt.value.replace(/\{\{railgauge\|62\}\}/gi, '\{\{convert|5|ft|2|in|mm|0|abbr=on\}\}');
txt.value=txt.value.replace(/\{\{railgauge\|63\}\}/gi, '\{\{convert|5|ft|3|in|mm|0|abbr=on\}\}');
txt.value=txt.value.replace(/\{\{railgauge\|64\}\}/gi, '\{\{convert|5|ft|4|in|mm|0|abbr=on\}\}');
txt.value=txt.value.replace(/\{\{railgauge\|65\}\}/gi, '\{\{convert|5|ft|5|in|mm|0|abbr=on\}\}');
txt.value=txt.value.replace(/\{\{railgauge\|66\}\}/gi, '\{\{convert|5|ft|6|in|mm|0|abbr=on\}\}');
txt.value=txt.value.replace(/\{\{railgauge\|67\}\}/gi, '\{\{convert|5|ft|7|in|mm|0|abbr=on\}\}');
txt.value=txt.value.replace(/\{\{railgauge\|68\}\}/gi, '\{\{convert|5|ft|8|in|mm|0|abbr=on\}\}');
txt.value=txt.value.replace(/\{\{railgauge\|69\}\}/gi, '\{\{convert|5|ft|9|in|mm|0|abbr=on\}\}');
txt.value=txt.value.replace(/\{\{railgauge\|70\}\}/gi, '\{\{convert|5|ft|10|in|mm|0|abbr=on\}\}');
txt.value=txt.value.replace(/\{\{railgauge\|71\}\}/gi, '\{\{convert|5|ft|11|in|mm|0|abbr=on\}\}');
txt.value=txt.value.replace(/\{\{railgauge\|72\}\}/gi, '\{\{convert|6|ft|mm|0|abbr=on\}\}');
 
//remove commas from numerical values in convert template
Line 775 ⟶ 792:
var txt=document.editform.wpTextbox1;
 
txt.value=txt.value.replace(/\{\{(?:avyear|by|fy|ly|mlby|mlb\syear|scy|sdy)\|(\d{1,4})\}\}/gi, '$1');
txt.value=txt.value.replace(/\[\[\d{1,4}\sin\s\w+\|(\d{1,4})\]\]/gi, "[[$1]]");
 
Line 795 ⟶ 812:
txt.value=txt.value.replace(/(\[\[(?:2300|2000))\s(AD\]\])/gi, '$1xx$2');
txt.value=txt.value.replace(/(\[\[(?:112|911|999))(\]\])/gi, '$1xx$2');
txt.value=txt.value.replace(/(\[\[september)xx(11\]\])/gi, '$1 $2');
txt.value=txt.value.replace(/(\[\[7)xx(july\]\])/gi, '$1 $2');
}
 
Line 854 ⟶ 873:
 
//remove dts-simple template that links dates
txt.value=txt.value.replace(/\{\{dts-simple\|(Jan(?:uary)?|Feb(?:ruary)?|Mar(?:ch)?|Apr(?:il)?|May|June?|July?|Aug(?:ust)?|Sep(?:tember)?|Oct(?:ober)?|Nov(?:ember)?|Dec(?:ember)?)\|\s?(\d\d?)\|(\d{1,4})\}\}/gi, '$2 $1 $3');
 
//remove dts3 template that links dates
txt.value=txt.value.replace(/\{\{dts3\|(Jan(?:uary)?|Feb(?:ruary)?|Mar(?:ch)?|Apr(?:il)?|May|June?|July?|Aug(?:ust)?|Sep(?:tember)?|Oct(?:ober)?|Nov(?:ember)?|Dec(?:ember)?)\|(\d\d?)\|(\d{1,4})\}\}/gi, '$2 $1 $3');
 
//change deprecated dts2 template
txt.value=txt.value.replace(/\{\{dts2\|(.*?)\|(.*?)\|(.*?)\}\}/gi, '\{\{dts|link=off|format=dmy|$3|$2|$1\}\}');
//fix dts template
txt.value=txt.value.replace(/(\{\{dts\|)/gi, '$1link=off|format=dmy|');
txt.value=txt.value.replace(/(\{\{dts\|)link=off\|([^}]*link=off)/gi, '$1$2');
txt.value=txt.value.replace(/(\{\{dts\|)format=dmy\|([^}]*format=dmy)/gi, '$1$2');
 
//change deprecated birth and death templates
txt.value=txt.value.replace(/(\{\{(?:Birth|Death|release)[^}]*)\|mf=ye?s?/gi, '$1');
txt.value=txt.value.replace(/(\{\{(?:Birth|Death|release)[^|]*\|)/gi, '$1df=yes|');
txt.value=txt.value.replace(/(\{\{(?:Birth|Death|release)[^|]*\|)df=ye?s?\|([^}]*df=ye?s?)/gi, '$1$2');
 
unprotect_dates();
Line 897 ⟶ 916:
 
//remove dts-simple template that links dates
txt.value=txt.value.replace(/\{\{dts-simple\|(Jan(?:uary)?|Feb(?:ruary)?|Mar(?:ch)?|Apr(?:il)?|May|June?|July?|Aug(?:ust)?|Sep(?:tember)?|Oct(?:ober)?|Nov(?:ember)?|Dec(?:ember)?)\|\s?(\d\d?)\|(\d{1,4})\}\}/gi, '$1 $2, $3');
 
//remove dts3 template that links dates
txt.value=txt.value.replace(/\{\{dts3\|(Jan(?:uary)?|Feb(?:ruary)?|Mar(?:ch)?|Apr(?:il)?|May|June?|July?|Aug(?:ust)?|Sep(?:tember)?|Oct(?:ober)?|Nov(?:ember)?|Dec(?:ember)?)\|(\d\d?)\|(\d{1,4})\}\}/gi, '$1 $2, $3');
 
//change deprecated dts2 template
txt.value=txt.value.replace(/\{\{dts2\|(.*?)\|(.*?)\|(.*?)\}\}/gi, '\{\{dts|link=off|$3|$2|$1\}\}');
//fix dts template
txt.value=txt.value.replace(/(\{\{dts\|)/gi, '$1link=off|');
txt.value=txt.value.replace(/(\{\{dts\|)link=off\|([^}]*link=off)/gi, '$1$2');
 
//change deprecated birth and death templates
txt.value=txt.value.replace(/(\{\{(?:Birth|Death|release)[^}]*)\|df=ye?s?/gi, '$1');
txt.value=txt.value.replace(/(\{\{(?:Birth|Death|release)[^|]*\|)/gi, '$1mf=yes|');
txt.value=txt.value.replace(/(\{\{(?:Birth|Death|release)[^|]*\|)mf=ye?s?\|([^}]*mf=ye?s?)/gi, '$1$2');
 
unprotect_dates();
Line 944 ⟶ 963:
txt.value=txt.value.replace(/([^\d][^\w\d])(Jan(?:uary)?|Feb(?:ruary)?|Mar(?:ch)?|Apr(?:il)?|May|June?|July?|Aug(?:ust)?|Sep(?:tember)?|Oct(?:ober)?|Nov(?:ember)?|Dec(?:ember)?)\s([0123]?\d)(?:th|st|nd|rd|),?\s(\d{1,4})([^\w\d][^\d])/gi, '$1$3 $2 $4$5');
txt.value=txt.value.replace(/([^\d][^\w\d])(Jan(?:uary)?|Feb(?:ruary)?|Mar(?:ch)?|Apr(?:il)?|May|June?|July?|Aug(?:ust)?|Sep(?:tember)?|Oct(?:ober)?|Nov(?:ember)?|Dec(?:ember)?)\s([0123]?\d)(?:th|st|nd|rd|)([^\w\d][^\d])/gi, '$1$3 $2$4');
 
 
//Month+day_number "March 7th" -> "March 7"
txt.value=txt.value.replace(/([^\d][^\w\d])([0123]?\d)(?:th|st|nd|rd|)\s(Jan(?:uary)?|Feb(?:ruary)?|Mar(?:ch)?|Apr(?:il)?|May|June?|July?|Aug(?:ust)?|Sep(?:tember)?|Oct(?:ober)?|Nov(?:ember)?|Dec(?:ember)?)\s(\d{1,4})([^\w\d][^\d])/gi, '$1$2 $3 $4$5');
txt.value=txt.value.replace(/([^\d][^\w\d])([0123]?\d)(?:th|st|nd|rd|)\s(Jan(?:uary)?|Feb(?:ruary)?|Mar(?:ch)?|Apr(?:il)?|May|June?|July?|Aug(?:ust)?|Sep(?:tember)?|Oct(?:ober)?|Nov(?:ember)?|Dec(?:ember)?)([^\w\d][^\d])/gi, '$1$2 $3$4');
 
Line 977 ⟶ 996:
txt.value=txt.value.replace(/([^\d][^\w\d])([0123]?\d)(?:th|st|nd|rd|)\s(Jan(?:uary)?|Feb(?:ruary)?|Mar(?:ch)?|Apr(?:il)?|May|June?|July?|Aug(?:ust)?|Sep(?:tember)?|Oct(?:ober)?|Nov(?:ember)?|Dec(?:ember)?)\s(\d{1,4})([^\w\d][^\d])/gi, '$1$3 $2, $4$5');
txt.value=txt.value.replace(/([^\d][^\w\d])([0123]?\d)(?:th|st|nd|rd|)\s(Jan(?:uary)?|Feb(?:ruary)?|Mar(?:ch)?|Apr(?:il)?|May|June?|July?|Aug(?:ust)?|Sep(?:tember)?|Oct(?:ober)?|Nov(?:ember)?|Dec(?:ember)?)([^\w\d][^\d])/gi, '$1$3 $2$4');
 
 
//Month+day_number "March 7th" -> "March 7"
txt.value=txt.value.replace(/([^\d][^\w\d])(Jan(?:uary)?|Feb(?:ruary)?|Mar(?:ch)?|Apr(?:il)?|May|June?|July?|Aug(?:ust)?|Sep(?:tember)?|Oct(?:ober)?|Nov(?:ember)?|Dec(?:ember)?)\s([0123]?\d)(?:th|st|nd|rd|)(,?\s)(\d{1,4})([^\w\d][^\d])/gi, '$1$2 $3$4$5$6');
txt.value=txt.value.replace(/([^\d][^\w\d])(Jan(?:uary)?|Feb(?:ruary)?|Mar(?:ch)?|Apr(?:il)?|May|June?|July?|Aug(?:ust)?|Sep(?:tember)?|Oct(?:ober)?|Nov(?:ember)?|Dec(?:ember)?)\s([0123]?\d)(?:th|st|nd|rd|)([^\w\d][^\d])/gi, '$1$2 $3$4');
 
//add comma when missing
txt.value=txt.value.replace(/([^\d][^\w\d])(Jan(?:uary)?|Feb(?:ruary)?|Mar(?:ch)?|Apr(?:il)?|May|June?|July?|Aug(?:ust)?|Sep(?:tember)?|Oct(?:ober)?|Nov(?:ember)?|Dec(?:ember)?)\s([0123]?\d)(?:th|st|nd|rd|)(\s)(\d{1,4})([^\w\d][^\d])/gi, '$1$2 $3,$4$5$6');
 
 
Line 998 ⟶ 1,020:
// Add a tag to the summary box
var txt=document.editform.wpSummary;
var summary = "[[Userwp:Lightmouse/monobook.js/script.js|scriptdatescript]]-assisted date/terms audit; see [[Wikipediawp:MOSNUM#Date_autoformatting|mosnumunlinkdates]], [[wp:overlink]]";
if (txt.value.indexOf(summary) == -1) {
if (txt.value.match(/[^\*\/\s][^\/\s]?\s*$/)) {
Line 1,037 ⟶ 1,059:
}
 
$.when(mw.loader.using(['mediawiki.util']), $.ready).done(function () {
addOnloadHook(function () {
if(document.forms.editform) {
mw.util.addPortletLink('p-tb', 'javascript:CommonTerms()', 'Delink common terms', 't-dmydelinkcommon', 'Regexp common terms', '', '');
mw.util.addPortletLink('p-tb', 'javascript:run_formatgeneral()', 'Add metric units', 'cat-unitfixeraddmetric', 'Fixes some unit formatting', '', '');
mw.util.addPortletLink('p-tb', 'javascript:button_delink_dates_to_dmy()', 'Delink dates to dmy', 't-dmydelinkdmy', 'day month', '', '');
mw.util.addPortletLink('p-tb', 'javascript:button_delink_dates_to_mdy()', 'Delink dates to mdy', 't-mdydelinkmdy', 'month day', '', '');
mw.util.addPortletLink('p-tb', 'javascript:all_dates_to_dmy()', 'All dates to dmy', 't-dmyalldmy', 'day month', '', '');
mw.util.addPortletLink('p-tb', 'javascript:all_dates_to_mdy()', 'All dates to mdy', 't-mdyallmdy', 'month day', '', '');
mw.util.addPortletLink('p-tb', 'javascript:delink_year_in_X()' , 'Delink year-in-X dates', 't-yearinX', 'Regexp yearinX', '', '');
mw.util.addPortletLink('p-tb', 'javascript:delink_dates_to_dmy_and_common_terms()', 'Delink dates to dmy+common terms', 'cat-unitfixerdmyandcommon', 'Fixes some unit formatting', '', '');
mw.util.addPortletLink('p-tb', 'javascript:delink_dates_to_mdy_and_common_terms()', 'Delink dates to mdy+common terms', 'cat-unitfixermdyandcommon', 'Fixes some unit formatting', '', '');
mw.util.addPortletLink('p-tb', 'javascript:make_dates_bold()', 'Make dates bold', 't-bolddates', 'Fixes some unit formatting', '', '');
}
});