User:Anonymous Dissident/monobook.js
Appearance
Code that you insert on this page could contain malicious content capable of compromising your account. If you import a script from another page with "importScript", "mw.loader.load", "iusc", or "lusc", take note that this causes you to dynamically load a remote script, which could be changed by others. Editors are responsible for all edits and actions they perform, including by scripts. User scripts are not centrally supported and may malfunction or become inoperable due to software changes. A guide to help you find broken scripts is available. If you are unsure whether code you are adding to this page is safe, you can ask at the appropriate village pump. This code will be executed when previewing this page. |
The accompanying .css page for this skin is at User:Anonymous Dissident/monobook.css. |
// [[User:Lupin/popups.js]]
importScript('User:Lupin/popups.js');
importScript('User:AzaToth/twinkle.js');
importScript("User:Lupin/recent2.js");
importScript('User:Animum/reset.js');
importScript("User:Animum/easyblock.js"); //[[User:Animum/easyblock.js]]
importScript('User:Ale_jrb/Scripts/igloo.js'); // [[User:Ale_jrb/Scripts/igloo]]
// [[User:Krimpet/CH2.js]]
importScript('User:Krimpet/CH2.js');
// [[User:Henrik/live-edit-counter]]
importScript('User:Henrik/js/live-edit-counter.js');
importScript('User:Tra/userwatchlist.js'); //[[User:Tra/userwatchlist.js]]
/**** afd helper ****/
document.write('<script type="text/javascript"' +
'src="http://en.wikipedia.org/w/index.php?title=User:Jnothman/afd_helper/' +
'script.js&action=raw&ctype=text/javascript&dontcountme=s"></script>');
/* This is to keep track of who is using this extension: [[User:Jnothman/afd_helper/script.js]] */
afdh_signature = ' -- ~~'+'~';
//A helper function to add a button to one of the toolbars in the interface.
//An improved(I hope) version of [[Wikipedia:WikiProject User scripts/Scripts/Add LI link|addlilink]].
//[[User:JesseW/sig|JesseW, the juggling janitor]] 05:33, 8 November *2005 (UTC)
function addLink(where, url, name, id, title, key, after){
//* where is the id of the toolbar where the button should be added;
// i.e. one of "p-cactions", "p-personal", "p-navigation", or "p-tb".
//
//* url is the URL which will be called when the button is clicked.
// javascript: urls can be used to do more complex things.
//
//* name is what will appear as the name of the button.
//
//* id is the id of the button; it's best to define one.
// Use a prefix to make sure its unique. Optional.
//
//* title is the tooltip title that gives a longer description
// of the button; if you define a accesskey, mention it here. Optional.
//
//* key is the char you want for the accesskey. Optional.
//
//* after is the id of the button you want to follow this one. Optional.
//
var na = document.createElement('a');
na.href = url;
na.appendChild(document.createTextNode(name));
var li = document.createElement('li');
if(id) li.id = id;
li.appendChild(na);
var tabs = document.getElementById(where).getElementsByTagName('ul')[0];
if(after) {
tabs.insertBefore(li,document.getElementById(after));
} else {
tabs.appendChild(li);
}
if(id) {
if(key && title) { ta[id] = [key, title]; }
else if(key) { ta[id] = [key, '']; }
else if(title) { ta[id] = ['', title];}
}
// re-render the title and accesskeys from existing code in wikibits.js
akeytt();
return li;
}
//this helps automate AfD closing by adding a 'close' tab to AfD debates
//written by [[User:Johnleemk]] based on [[Wikipedia:WikiProject User scripts/Scripts/test-n.js]] by [[User:Celestianpower]]
function autoafd_result()
{
var close = prompt("Result of debate?")
var f = document.editform, t = f.wpTextbox1;
t.value = t.value.split('{{REMOVE THIS TEMPLATE WHEN CLOSING THIS AfD').join('{{ns:0');
t.value = "{{subst:" + "at" + "}} '''" + close + "'''. " + "~" + "~" + "~" + "~" + '\n' + '\n' + t.value;
if (t.value.length > 0)
t.value += '\n';
t.value += "{{subst:" + "ab" + "}}";
f.wpSummary.value = "Closing debate; result was " + close;
}
function autoafd_relist()
{
var f = document.editform, t = f.wpTextbox1;
if (t.value.length > 0)
t.value += '\n';
t.value += "{{subst:" + "relist" + "|~" + "~" + "~" + "~}}";
f.wpSummary.value = "Relisting debate";
}
function autoafd_keep()
{
var date = prompt("Nomination was made when?")
var votepage = prompt("Vote page is? (Enter 'd' for default.)")
var f = document.editform, t = f.wpTextbox1;
// If default votepage...
if (votepage=="d")
{
var temp = document.editform.action.split("/w/index.php?title=");
var temp = temp[1].split("&action=submit");
var temp = temp[0].substring(5);
var votepage = temp;
}
t.value = "{{subst:" + "oldafdfull" + "|date=" + date + "|votepage=" + votepage + "}}" + '\n' + '\n' + t.value;
f.wpSummary.value = "Article survived AfD";
}
function autoafd_no_consensus()
{
var date = prompt("Nomination was made when?")
var votepage = prompt("Vote page is? (Enter 'd' for default.)")
var f = document.editform, t = f.wpTextbox1;
// If default votepage...
if (votepage=="d")
{
var temp = document.editform.action.split("/w/index.php?title=");
var temp = temp[1].split("&action=submit");
var temp = temp[0].substring(5);
var votepage = temp;
}
t.value = "{{subst:" + "oldafdfull" + "|date=" + date + "|result='''no consensus'''|votepage=" + votepage + "}}" + '\n' + '\n' + t.value;
f.wpSummary.value = "Article survived AfD with no consensus";
}
function autoafd_redirect()
{
var date = prompt("Nomination was made when?")
var redirect = prompt("Redirect to?")
var votepage = prompt("Vote page is? (Enter 'd' for default.)")
var f = document.editform, t = f.wpTextbox1;
// If default votepage...
if (votepage=="d")
{
var temp = document.editform.action.split("/w/index.php?title=");
var temp = temp[1].split("&action=submit");
var temp = temp[0].substring(5);
var votepage = temp;
}
t.value = "{{subst:" + "oldafdfull" + "|date=" + date + "|result='''redirect to [[" + redirect + "]]'''|votepage=" + votepage + "}}" + '\n' + '\n' + t.value;
f.wpSummary.value = "Article redirected to [[" + redirect + "]] as per AfD";
}
function autoafd_merge()
{
var date = prompt("Nomination was made when?")
var redirect = prompt("Merge and redirect to?")
var votepage = prompt("Vote page is? (Enter 'd' for default.)")
var f = document.editform, t = f.wpTextbox1;
// If default votepage...
if (votepage=="d")
{
var temp = document.editform.action.split("/w/index.php?title=");
var temp = temp[1].split("&action=submit");
var temp = temp[0].substring(5);
var votepage = temp;
}
t.value = "{{subst:" + "oldafdfull" + "|date=" + date + "|result='''merge and redirect to [[" + redirect + "]]'''|votepage=" + votepage + "}}" + '\n' + '\n' + t.value;
f.wpSummary.value = "Article merged and redirected to [[" + redirect + "]] as per AfD";
}
function autoafd_other()
{
var date = prompt("Nomination was made when?")
var result = prompt("Result was?")
var votepage = prompt("Vote page is? (Enter 'd' for default.)")
var f = document.editform, t = f.wpTextbox1;
// If default votepage...
if (votepage=="d")
{
var temp = document.editform.action.split("/w/index.php?title=");
var temp = temp[1].split("&action=submit");
var temp = temp[0].substring(5);
var votepage = temp;
}
t.value = "{{subst:" + "oldafdfull" + "|date=" + date + "|result='''" + result + "'''|votepage=" + votepage + "}}" + '\n' + '\n' + t.value;
f.wpSummary.value = "AfDed; result was " + result;
}
function autoafd_add_afd_tabs()
{
// Only add for pages with the right string somewhere in the title
if (document.title.indexOf("Editing Wikipedia:Articles for deletion/") != -1)
{
addLink('p-cactions', 'javascript:autoafd_result()', "close");
addLink('p-cactions', 'javascript:autoafd_relist()', "relist");
}
if (document.title.indexOf("Editing Talk:") != -1)
{
addLink('p-cactions', 'javascript:autoafd_keep()', "keep");
addLink('p-cactions', 'javascript:autoafd_no_consensus()', "no consensus");
addLink('p-cactions', 'javascript:autoafd_redirect()', "redirect");
addLink('p-cactions', 'javascript:autoafd_merge()', "merge");
addLink('p-cactions', 'javascript:autoafd_other()', "other");
}
}
$(autoafd_add_afd_tabs);
//end AfD closing script
//csdreasonhelper - help insert deleted article reasons
function csdreasonhelper() {
if (document.title.indexOf("Confirm deletion -") == 0) {
var csdReasons = [
['Nonsense', 'Nonsense ([[WP:CSD#G1|CSD G1]])'],
['Test page', 'Test page ([[WP:CSD#G2|CSD G2]])'],
['Vandalism', 'Vandalism ([[WP:CSD#G3|CSD G3]])'],
['Recreated', 'Recreation of deleted material ([[WP:CSD#G4|CSD G4]])'],
['Author blanked', 'Original author blanked the page ([[WP:CSD#G7|CSD G7]])'],
['Talk', 'Talk page of a page that does not exist ([[WP:CSD#G8|CSD G8]])'],
['Attack', 'Attack page ([[WP:CSD#G10|CSD G10]])'],
['Spam', 'Blatant advertising ([[WP:CSD#G11|CSD G11]])'],
['Copyvio', 'Copyright violation ([[WP:CSD#G12|CSD G12]])'],
['No context', 'Very short article providing little or no context ([[WP:CSD#A1|CSD A1]])'],
['No content', 'Contains no content whatsoever, consists only of links elsewhere, or a rephrasing of the title ([[WP:CSD#A3|CSD A3]])'],
['NN bio', 'Article about a person, group of people, band, club, company or website that does not assert the [[Wikipedia:Notability|importance or significance]] of the subject. ([[WP:CSD#A7|CSD A7]])'],
['NN band', 'Article about a band, singer, musician, or musical ensemble that does not assert the [[Wikipedia:Notability|importance or significance]] of the subject. See [[WP:MUSIC]]. ([[WP:CSD#A7|CSD A7]])'],
['NN corp', 'Article about a company or corporation that does not assert the [[Wikipedia:Notability|importance or significance]] of the subject. ([[WP:CSD#A7|CSD A7]])'],
['NN web', 'Article about a web site, blog, online forum, webcomic, podcast, or similar web content that does not assert the [[Wikipedia:Notability|importance or significance]] of the subject. See [[WP:WEB]]. ([[WP:CSD#A7|CSD A7]])'],
['Redir none', 'Redirect to a non-existent page ([[WP:CSD#R1|CSD R1]])'],
['Redir user', 'Redirect to a user page, user talk page, or talk page from the main/article space ([[WP:CSD#R2|CSD R2]])'],
['Redir typo', 'Redirect page resulting from an implausible typo ([[WP:CSD#R3|CSD R3]])'],
['User', 'User page or user subpage requested to be deleted by the user who created it ([[WP:CSD#U1|CSD U1]])'],
];
var csdBreak, csdLabel, csdSelect;
csdBreak = document.createElement('br');
csdLabel = document.createTextNode('Select CSD reason: ');
csdSelect = document.createElement('select');
csdSelect.id = "csd";
csdSelect.onchange = new Function("document.getElementById('wpReason').value = this.options[this.selectedIndex].value");
csdSelect.options[0] = new Option("Clear", "", true, true);
for (var i = 0; i < csdReasons.length; i++) {
csdSelect.options[i + 1] = new Option(csdReasons[i][0], csdReasons[i][1], false, false);
}
if (document.getElementById("Deletereason")) {
document.getElementById("Deletereason").appendChild(csdBreak);
document.getElementById("Deletereason").appendChild(csdLabel);
document.getElementById("Deletereason").appendChild(csdSelect);
}
}
}
$(csdreasonhelper);
// end csdreasonhelper()
//Create 'winc' function:
function winc(s) {
document.write('<script type="text/javascript" src="'
+ 'http://en.wikipedia.org/w/index.php?title=' + s
+ '&action=raw&ctype=text/javascript&dontcountme=s"></script>');
}
//'winc' function allows buttons to be added toolbar
winc('User:Omegatron/monobook.js/addlink.js');
function dates() {
var txt = document.editform.wpTextbox1;
//Identify surprise or 'Easter egg' diversions linking years to 'year in something' articles. Turn them into year links to be dealt with below
txt.value=txt.value.replace(/\[\[\d{1,4}s?\sin\s[^\|]{1,30}\|(\d{1,4}s?)\]\]/gi, '\[\[$1\]\]');
// century
txt.value=txt.value.replace(/\[\[((?:first|second|third|fourth|fifth|sixth|seventh|eighth|ninth|tenth|eleventh|twelfth|thirteenth|fourteenth|fifteenth|sixteenth|seventeenth|eighteenth|nineteenth|twentieth|twenty(?:\s|-)first)(?:\s|-))century\]\]/gi, '$1century');
txt.value=txt.value.replace(/\[\[((?:first|second|third|fourth|fifth|sixth|seventh|eighth|ninth|tenth|eleventh|twelfth|thirteenth|fourteenth|fifteenth|sixteenth|seventeenth|eighteenth|nineteenth|twentieth|twenty(?:\s|-)first)(?:\s|-))century\s(AD|BC|CE|BCE)\]\]/gi, '$1century');
txt.value=txt.value.replace(/\[\[(\d{1,2}(?:st|nd|rd|th)(?:\s|-))century\]\]/gi, '$1century');
txt.value=txt.value.replace(/\[\[(\d{1,2}(?:st|nd|rd|th)(?:\s|-))centuries\]\]/gi, '$1centuries');
txt.value=txt.value.replace(/\[\[\d{1,2}(?:st|nd|rd|th)(?:\s|-)century\|(\d{1,2}(?:st|nd|rd|th))\]\]/gi, '$1');
txt.value=txt.value.replace(/\[\[\d{1,2}(?:st|nd|rd|th)(?:\s|-)century\|(\d{1,2}(?:st|nd|rd|th)(?:\s|-))century\]\]/gi, '$1century');
txt.value=txt.value.replace(/\[\[\d{1,2}(?:st|nd|rd|th)(?:\s|-)century\|(\d{1,2}(?:st|nd|rd|th)(?:\s|-))centuries\]\]/gi, '$1centuries');
txt.value=txt.value.replace(/\[\[(\d{1,2}(?:st|nd|rd|th)(?:\s|-))century\s(AD|BC|CE|BCE)\]\]/gi, '$1century $2');
txt.value=txt.value.replace(/\[\[\d{1,2}(?:st|nd|rd|th)(?:\s|-)century\|(\d{1,2}(?:st|nd|rd|th)(?:\s|-))century\s(AD|BC|CE|BCE)\]\]/gi, '$1century $2');
txt.value=txt.value.replace(/\[\[\d{1,2}(?:st|nd|rd|th)(?:\s|-)century\|(\d{1,2}(?:st|nd|rd|th)(?:\s|-))centuries\s(AD|BC|CE|BCE)\]\]/gi, '$1centuries $2');
//century but avoiding '20th Century Fox'
txt.value=txt.value.replace(/(\d(?:st|nd|rd)(?:\s|-))Century/gi, '$1century');
txt.value=txt.value.replace(/([456789]th(?:\s|-))Century/gi, '$1century');
txt.value=txt.value.replace(/(0th(?:\s|-))Century(.[^F])/gi, '$1century$2');
// decades and years
txt.value=txt.value.replace(/\[\[(\d{1,4})\'?s\]\]/gi, '$1s');
txt.value=txt.value.replace(/\[\[(\d{1,4})\'?(s)?\s?(AD|BC|CE|BCE)\]\]/gi, '$1$2 $3');
txt.value=txt.value.replace(/\[\[\d{1,4}\'?s?\s?(?:AD|BC|CE|BCE)\|(\d{1,4})\'?(s)?\]\]/gi, '$1$2');
txt.value=txt.value.replace(/\[\[\d{1,4}\'?s?\s?(?:AD|BC|CE|BCE)\|(\d{1,4})\'?(s)?\s?(AD|BC|CE|BCE)\]\]/gi, '$1$2 $3');
txt.value=txt.value.replace(/\[\[\d{1,4}\'?s?\|(\d{1,4})\'?(s)?\s?(AD|BC|CE|BCE)\]\]/gi, '$1$2 $3');
txt.value=txt.value.replace(/\[\[\d{1,4}\'?s?\|(\d{1,4})\'?(s)?\]\]/gi, '$1$2');
txt.value=txt.value.replace(/\[\[\d\d?(?:st|nd|rd|th)\scentur(?:y|ies)\|(\d{1,4})\'?(s)?\]\]/gi, '$1$2');
txt.value=txt.value.replace(/\[\[\w{5,12}\scentur(?:y|ies)\|(\d{1,4})\'?(s)?\]\]/gi, '$1$2');
// solitary day_numbers
txt.value=txt.value.replace(/\[\[(?:January|February|March|April|May|June|July|August|September|October|November|December) \d{1,2}\|(\d{1,2}(?:th|st|nd|rd))\]\]/gi, '$1');
txt.value=txt.value.replace(/\[\[\d{1,2} (?:January|February|March|April|May|June|July|August|September|October|November|December)\|(\d{1,2}(?:th|st|nd|rd))\]\]/gi, '$1');
txt.value=txt.value.replace(/\[\[(\d{1,2}(?:st|nd|rd|th))\]\]/gi, '$1');
//month+day: remove incorrect trailing space
txt.value=txt.value.replace(/(\[\[(?:January|February|March|April|May|June|July|August|September|October|November|December)\s\d\d?)\s(\]\])/gi,'$1$2');
//month+year
//Identify surprise or 'Easter egg' diversions linking month+years to year articles. Turn them into month+year links to be dealt with below
txt.value=txt.value.replace(/\[\[\d{1,4}#[^\|]{1,30}\|((?:January|February|March|April|May|June|July|August|September|October|November|December) \d{3,4})\]\]/gi, '\[\[$1\]\]');
txt.value=txt.value.replace(/\[\[((?:January|February|March|April|May|June|July|August|September|October|November|December) \d{3,4})\]\]/gi, '$1');
//year: temporary change to protect accessyear. Undone below at #1
txt.value=txt.value.replace(/(accessyear\s?=\s?)\[\[(\d{1,4})\]\]/gi, '$1xx$2xx');
//Year: temporary change to protext preference dates - y?y?y?. Needed to handle 'year in' piped links
txt.value=txt.value.replace(/(\[\[\d\d?\s(?:January|February|March|April|May|June|July|August|September|October|November|December)\]\],?\s?\s?)\[\[(\d{1,4})\]\]y?y?y?/gi,'$1xx$2xx');
txt.value=txt.value.replace(/(\[\[\d\d?\s(?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\]\],?\s?\s?)\[\[(\d{1,4})\]\]y?y?y?/gi,'$1xx$2xx');
txt.value=txt.value.replace(/(\[\[(?:January|February|March|April|May|June|July|August|September|October|November|December)\s\d\d?\]\],?\s?\s?)\[\[(\d{1,4})\]\]y?y?y?/gi,'$1xx$2xx');
txt.value=txt.value.replace(/(\[\[(?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s\d\d?\]\],?\s?\s?)\[\[(\d{1,4})\]\]y?y?y?/gi,'$1xx$2xx');
txt.value=txt.value.replace(/\[\[(\d{1,4})\]\]y?y?y?(,?\s?\-?\s?\[\[(?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s\d\d?\]\])/gi,'xx$1xx$2');
txt.value=txt.value.replace(/\[\[(\d{1,4})\]\]y?y?y?(,?\s?\-?\s?\[\[(?:January|February|March|April|May|June|July|August|September|October|November|December)\s\d\d?\]\])/gi,'xx$1xx$2');
txt.value=txt.value.replace(/\[\[(\d{1,4})\]\]y?y?y?(,?\s?\-?\s?\[\[\d\d?\s(?:January|February|March|April|May|June|July|August|September|October|November|December)\]\])/gi,'xx$1xx$2');
txt.value=txt.value.replace(/\[\[(\d{1,4})\]\]y?y?y?(,?\s?\-?\s?\[\[\d\d\-\d\d\]\]y?y?y?)/gi,'xx$1xx$2');
//year: now remove unprotected linked years
txt.value=txt.value.replace(/\[\[(\d{1,4})\]\]/gi, '$1');
//year: #1. Undo temporary change to protect accessyear and date preference dates
txt.value=txt.value.replace(/xx(\d{1,4})xx/gi, '\[\[$1\]\]');
}
function formatgeneral() {
var txt = document.editform.wpTextbox1;
//remove flagicons from birth and death
txt.value=txt.value.replace(/(birth\s?=\s?)\{\{flagicon\|[^\}]{1,30}\}\}/gi, '$1');
txt.value=txt.value.replace(/(death\s?=\s?)\{\{flagicon\|[^\}]{1,30}\}\}/gi, '$1');
txt.value=txt.value.replace(/(birth_?place\s?=\s?)\{\{flagicon\|[^\}]{1,30}\}\}/gi, '$1');
txt.value=txt.value.replace(/(death_?place\s?=\s?)\{\{flagicon\|[^\}]{1,30}\}\}/gi, '$1');
//symbol for 'times'
txt.value=txt.value.replace(/×/gi, '×');
//symbol for superscript 2 and 3
//txt.value=txt.value.replace(/<sup>2<\/sup>/gi, '²');
//txt.value=txt.value.replace(/<sup>3<\/sup>/gi, '³');
//Attempt to deal with naval infobox
txt.value=txt.value.replace(/General\sCharacteristics/g, 'General characteristics');
//turn letter 'x' into symbol '×'
txt.value=txt.value.replace(/(\d)\sx\s(\d{1,3})\sin\s\(/gi, '$1 × $2 in (');
txt.value=txt.value.replace(/(\d)\sx\s(\d{1,3})\sinch\s/gi, '$1 × $2 inch ');
// Convert degree symbols into ° symbol, ensure preceding space
txt.value=txt.value.replace(/°/g, '°');
txt.value=txt.value.replace(/º/g, '°');
// Celsius spelling errors
txt.value=txt.value.replace(/celsius/gi, 'Celsius');
txt.value=txt.value.replace(/celcius/gi, 'Celsius');
//Fix common naming error (be careful with this one)
txt.value=txt.value.replace(/centigrade/gi, 'Celsius');
//Celsius or Fahrenheit
txt.value=txt.value.replace(/°\s([CF])/g, '°$1');
txt.value=txt.value.replace(/° ([CF])/g, '°$1');
txt.value=txt.value.replace(/°\s?(celsius)/gi, '°C');
txt.value=txt.value.replace(/° (celsius)/gi, '°C');
txt.value=txt.value.replace(/(\d)\s?(°[CF])/g, '$1 $2');
txt.value=txt.value.replace(/deg[^\(]([CF])/gi, '°$1');
txt.value=txt.value.replace(/deg\s?([CF])/gi, '°$1');
txt.value=txt.value.replace(/deg ([CF])/gi, '°$1');
txt.value=txt.value.replace(/deg\.?\s?([CF])/gi, '°$1');
txt.value=txt.value.replace(/degrees?\s([CF])([\s:;,\.?!][^\d\(\)\/\\][^\d\(\)\/\\])/gi, '°$1$2');
txt.value=txt.value.replace(/degrees? ([CF])([\s:;,\.?!][^\d\(\)\/\\][^\d\(\)\/\\])/gi, '°$1$2');
txt.value=txt.value.replace(/(\d)\s?° ([CF])/g, '$1 °$2');
txt.value=txt.value.replace(/(\d)°([CF])/g, '$1 °$2');
txt.value=txt.value.replace(/(\d)°\[\[/g, '$1 °[[');
txt.value=txt.value.replace(/(\d)° (\[\[[CF])/gi, '$1 °$2');
txt.value=txt.value.replace(/(\d)(\[\[Celsius|°C\]\])/gi, '$1 $2');
txt.value=txt.value.replace(/(\d)(\[\[Fahrenheit|°F\]\])/gi, '$1 $2');
txt.value=txt.value.replace(/([^\d\(\)\/\\=]\s)(-?\d[\d,\.]{0,16})(?:\s|-| )°?F([\s:;,\.?!][^\d\(\)\/\\][^\d\(\)\/\\])/g, '$1\{\{convert|$2|°F|°C|abbr=on\}\}$3');
txt.value=txt.value.replace(/([^\d\(\)\/\\=]\s)(-?\d[\d,\.]{0,16})(?:\s|-| )(?:deg|degree|degrees)(?:\s|-| )Fahrenheit([\s:;,\.?!][^\d\(\)\/\\][^\d\(\)\/\\])/gi, '$1\{\{convert|$2|°F|°C\}\}$3');
// Convert &sup to superscript
txt.value=txt.value.replace(/²/g, '²');
txt.value=txt.value.replace(/³/g, '³');
//metre
//delink this common unit
txt.value=txt.value.replace(/([^\d\(\)\/\\=]\s)(\d[\d,\.]{0,16})(?:\s|-)\[\[(metres|meters|metre|meter)\]\]([\s:;,\.?!][^\d\(\)\/\\][^\d\(\)\/\\])/g, '$1$2 $3$4');
txt.value=txt.value.replace(/([^\d\(\)\/\\=]\s)(\d[\d,\.]{0,16})(?:\s|-)\[\[(metre|meter)\]\]s([\s:;,\.?!][^\d\(\)\/\\][^\d\(\)\/\\])/g, '$1$2 $3s$4');
//space before 'm' only when lower case. Check for dollars and pounds to avoid 'm' used for millions in money.
txt.value=txt.value.replace(/([^\d\(\)\/\\=]\s)(\d[\d,\.]{0,16})(?:\s|-|)m([\s:;,\.?!][^\d\(\)\/\\][^\d\(\)\/\\])/g, '$1$2 m$3');
//convert 'metres' to 'm' when in parentheses
txt.value=txt.value.replace(/(\(\d[\d,\.]{0,16})(?:\s|-)(?:metres|meters|metre|meter)(\))/g, '$1 m$2');
txt.value=txt.value.replace(/(\(\d[\d,\.]{0,16}) (?:metres|meters|metre|meter)(\))/g, '$1 m$2');
txt.value=txt.value.replace(/({convert\|\d{1,16}\|(?:m|ft)[^\}]{0,16})\|lk=(?:on|in|out)/g, '$1');
//metre per second
txt.value=txt.value.replace(/([^\d\(\)\/\\=]\s)(\d[\d,\.]{0,16})(?:\s|-|)(?:m\/second|m\/sec)([\s:;,\.?!][^\d\(\)\/\\][^\d\(\)\/\\])/gi, '$1$2 m/s$3');
txt.value=txt.value.replace(/([^\d\(\)\/\\=]\s)(\d[\d,\.]{0,16}) (?:m\/second|m\/sec)([\s:;,\.?!][^\d\(\)\/\\][^\d\(\)\/\\])/gi, '$1$2 m/s$3');
txt.value=txt.value.replace(/({convert\|\d{1,16}\|(?:m\s|ft\s)[^\}]{0,16})\|lk=(?:on|in|out)/g, '$1');
//square metre
txt.value=txt.value.replace(/(\d)(?:\s|-| )sq(?:\s|\.\s|-| )m([\s:;,\.?!][^\d\(\)\/\\][^\d\(\)\/\\])/gi, '$1 m²$2');
//remove period when followed by close parenthesis character
txt.value=txt.value.replace(/m²\.\)/gi, 'm²)');
txt.value=txt.value.replace(/({convert\|\d{1,16}\|(?:sqm|sqft)[^\}]{0,16})\|lk=(?:on|in|out)/g, '$1');
// millimetre
txt.value=txt.value.replace(/([^\d\(\)\/\\=]\s)(\d[\d,\.]{0,16})(?:\s|-|)mm([\s:;,\.?!][^\d\(\)\/\\][^\d\(\)\/\\])/g, '$1$2 mm$3');
// centimetre, cubic centimetre
txt.value=txt.value.replace(/([^\d\(\)\/\\=]\s)(\d[\d,\.]{0,16})(?:\s|-|)(cm|cc)([\s:;,\.?!][^\d\(\)\/\\][^\d\(\)\/\\])/g, '$1$2 $3$4');
// kilometre
//delink this common unit
txt.value=txt.value.replace(/([^\d\(\)\/\\=]\s)(\d[\d,\.]{0,16})(?:\s|-)\[\[(kilometres|kilometers|kilometre|kilometer)\]\]([\s:;,\.?!][^\d\(\)\/\\][^\d\(\)\/\\])/g, '$1$2 $3$4');
txt.value=txt.value.replace(/([^\d\(\)\/\\=]\s)(\d[\d,\.]{0,16})(?:\s|-)\[\[(kilometre|kilometer)\]\]s([\s:;,\.?!][^\d\(\)\/\\][^\d\(\)\/\\])/g, '$1$2 $3s$4');
txt.value=txt.value.replace(/([^\d\(\)\/\\=]\s)(\d[\d,\.]{0,16}) \[\[(kilometres|kilometers|kilometre|kilometer)\]\]([\s:;,\.?!][^\d\(\)\/\\][^\d\(\)\/\\])/g, '$1$2 $3$4');
txt.value=txt.value.replace(/([^\d\(\)\/\\=]\s)(\d[\d,\.]{0,16}) \[\[(kilometre|kilometer)\]\]s([\s:;,\.?!][^\d\(\)\/\\][^\d\(\)\/\\])/g, '$1$2 $3s$4');
txt.value=txt.value.replace(/([^\d\(\)\/\\=]\s)(\d[\d,\.]{0,16})(?:\s|-|)kms?([\s:;,\.?!][^\d\(\)\/\\][^\d\(\)\/\\])/gi, '$1$2 km$3');
txt.value=txt.value.replace(/([^\d\(\)\/\\=]\s)(\d[\d,\.]{0,16}) kms?([\s:;,\.?!][^\d\(\)\/\\][^\d\(\)\/\\])/gi, '$1$2 km$3');
txt.value=txt.value.replace(/({convert\|\d{1,16}\|(?:mi|km)[^\}]{0,16})\|lk=(?:on|in|out)/g, '$1');
//square kilometre
txt.value=txt.value.replace(/(\d)(\s|-| )\[\[km²\]\]/gi, '$1$2km²');
txt.value=txt.value.replace(/(\d)\s?sq\.?(?:\s|-| )kms?(\s|\.)/gi, '$1 km²$2');
txt.value=txt.value.replace(/({convert\|\d{1,16})00\|ha/g, '$1|sqkm');
txt.value=txt.value.replace(/({convert\|\d{1,16})(\d)0\|ha/g, '$1.$2|sqkm');
txt.value=txt.value.replace(/({convert\|\d{1,16})(\d\d)\|ha/g, '$1.$2|sqkm');
txt.value=txt.value.replace(/({convert\|\d{1,16}\|sqmi\|)ha/g, '$1sqkm');
txt.value=txt.value.replace(/({convert\|\d{1,16}\|(?:sqkm|sqmi)[^\}]{0,16})\|lk=(?:on|in|out)/g, '$1');
txt.value=txt.value.replace(/({convert\|\d{3,16}\|acre\|)ha/g, '$1sqkm');
//kilometre per second
txt.value=txt.value.replace(/([^\d\(\)\/\\=]\s)(\d[\d,\.]{0,16})(?:\s|-|)(?:km\/second|km\/sec)([\s:;,\.?!][^\d\(\)\/\\][^\d\(\)\/\\])/gi, '$1$2 km/s$3');
txt.value=txt.value.replace(/([^\d\(\)\/\\=]\s)(\d[\d,\.]{0,16}) (?:km\/second|km\/sec)([\s:;,\.?!][^\d\(\)\/\\][^\d\(\)\/\\])/gi, '$1$2 km/s$3');
// kilometre per hour
txt.value=txt.value.replace(/([^\d\(\)\/\\=]\s)(\d[\d,\.]{0,16})(?:\s|-|)(?:km\/hr|km\/ph|kph|kmph|kmh)([\s:;,\.?!][^\d\(\)\/\\][^\d\(\)\/\\])/gi, '$1$2 km/h$3');
txt.value=txt.value.replace(/([^\d\(\)\/\\=]\s)(\d[\d,\.]{0,16}) (?:km\/hr|km\/ph|kph|kmph|kmh)([\s:;,\.?!][^\d\(\)\/\\][^\d\(\)\/\\])/gi, '$1$2 km/h$3');
txt.value=txt.value.replace(/([^\d\(\)\/\\=]\s)(\d[\d,\.]{0,16})(?:\s|-|)\[\[(?:km\/hr|km\/ph|kph|kmph|kmh)\]\]([\s:;,\.?!][^\d\(\)\/\\][^\d\(\)\/\\])/gi, '$1$2 km/h$3');
txt.value=txt.value.replace(/([^\d\(\)\/\\=]\s)(\d[\d,\.]{0,16}) \[\[(?:km\/hr|km\/ph|kph|kmph|kmh)\]\]([\s:;,\.?!][^\d\(\)\/\\][^\d\(\)\/\\])/gi, '$1$2 km/h$3');
//millilitre
txt.value=txt.value.replace(/([^\d\(\)\/\\=]\s)(\d[\d,\.]{0,16})(?:\s|-|)(ml)([\s:;,\.?!][^\d\(\)\/\\][^\d\(\)\/\\])/g, '$1$2 $3$4');
// ensure spaces and correct case in kilowatt
txt.value=txt.value.replace(/([^\d\(\)\/\\=]\s)(\d[\d,\.]{0,16})(?:\s|-|)kW([\s:;,\.?!][^\d\(\)\/\\][^\d\(\)\/\\])/gi, '$1$2 kW$3');
// ensure spaces and correct case in hertz
txt.value=txt.value.replace(/([^\d\(\)\/\\=]\s)(\d[\d,\.]{0,16})(?:\s|-|)Hz([\s:;,\.?!][^\d\(\)\/\\][^\d\(\)\/\\])/gi, '$1$2 Hz$3');
txt.value=txt.value.replace(/([^\d\(\)\/\\=]\s)(\d[\d,\.]{0,16})(?:\s|-|)kHz([\s:;,\.?!][^\d\(\)\/\\][^\d\(\)\/\\])/gi, '$1$2 kHz$3');
txt.value=txt.value.replace(/([^\d\(\)\/\\=]\s)(\d[\d,\.]{0,16})(?:\s|-|)GHz([\s:;,\.?!][^\d\(\)\/\\][^\d\(\)\/\\])/gi, '$1$2 GHz$3');
// ensure spaces in megahertz. Must be upper case to avoid clashing with millihertz
txt.value=txt.value.replace(/([^\d\(\)\/\\=]\s)(\d[\d,\.]{0,16})(?:\s|-|)MHz([\s:;,\.?!][^\d\(\)\/\\][^\d\(\)\/\\])/g, '$1$2 MHz$3');
// frames per second
txt.value=txt.value.replace(/frames\/s([\s:;,\.?!][^\d\(\)\/\\][^\d\(\)\/\\])/gi, 'frame/s$1');
// kilogram
txt.value=txt.value.replace(/kilogrammes/gi, 'kilograms');
txt.value=txt.value.replace(/kilogramme/gi, 'kilogram');
txt.value=txt.value.replace(/([^\d\(\)\/\\=]\s)(\d[\d,\.]{0,16})(?:\s|-)\[\[(kilograms?)\]\]([\s:;,\.?!][^\d\(\)\/\\][^\d\(\)\/\\])/g, '$1$2 $3$4');
txt.value=txt.value.replace(/([^\d\(\)\/\\=]\s)(\d[\d,\.]{0,16}) \[\[(kilograms?)\]\]([\s:;,\.?!][^\d\(\)\/\\][^\d\(\)\/\\])/g, '$1$2 $3$4');
txt.value=txt.value.replace(/([^\d\(\)\/\\=]\s)(\d[\d,\.]{0,16})(?:\s|-|)grammes([\s:;,\.?!][^\d\(\)\/\\][^\d\(\)\/\\])/gi, '$1$2 grams$3');
txt.value=txt.value.replace(/([^\d\(\)\/\\=]\s)(\d[\d,\.]{0,16})(?:\s|-|)gramme([\s:;,\.?!][^\d\(\)\/\\][^\d\(\)\/\\])/gi, '$1$2 gram$3');
txt.value=txt.value.replace(/([^\d\(\)\/\\=]\s)(\d[\d,\.]{0,16})(?:\s|-|)(?:kgs?|\[\[kg\]\])([\s:;,\.?!][^\d\(\)\/\\][^\d\(\)\/\\])/gi, '$1$2 kg$3');
txt.value=txt.value.replace(/({convert\|\d{1,16}\|(?:kg|lb)[^\}]{0,16})\|lk=(?:on|in|out)/g, '$1');
//foot
//convert 'foot' to 'ft' when in parentheses
txt.value=txt.value.replace(/(\(\d[\d,\.]{0,16})(?:\s|-)(?:feet|foot)(\))/g, '$1 ft$2');
txt.value=txt.value.replace(/(\(\d[\d,\.]{0,16}) (?:feet|foot)(\))/g, '$1 ft$2');
//remove trailing period when in parentheses
txt.value=txt.value.replace(/(\(\d[\d,\.]{0,16})(?:\s|-)ft\.(\))/g, '$1 ft$2');
txt.value=txt.value.replace(/(\(\d[\d,\.]{0,16}) ft\.(\))/g, '$1 ft$2');
// square foot
//convert 'sq foot' to 'sq ft'
txt.value=txt.value.replace(/(\d)(\s|-)sq\.?(\s|-|)(feet|foot|ft)/gi, '$1 sq ft');
txt.value=txt.value.replace(/(\d) sq\.? (feet|foot|ft)/gi, '$1 sq ft');
//convert 'square ft' to 'sq ft'
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,\.]{0,16})(?:\s|-| )sq(?:\s|-| )ft([\s:;,\.?!][^\d\(\)\/\\][^\d\(\)\/\\])/gi, '$1\{\{convert|$2|sqft|sqm|abbr=on\}\}$3');
txt.value=txt.value.replace(/([^\d\(\)\/\\=]\s)(\d[\d,\.]{0,16})(?:\s|-| )square(?:\s|-| )feet([\s:;,\.?!][^\d\(\)\/\\][^\d\(\)\/\\])/gi, '$1\{\{convert|$2|sqft|sqm\}\}$3');
txt.value=txt.value.replace(/([^\d\(\)\/\\=]\s)(\d[\d,\.]{0,16})(?:\s|-| )square(?:\s|-| )foot([\s:;,\.?!][^\d\(\)\/\\][^\d\(\)\/\\])/gi, '$1\{\{convert|$2|sqft|sqm|sing=on\}\}$3');
txt.value=txt.value.replace(/([^\d\(\)\/\\=]\s)([\d,]{1,16})(?:\s|-| )thousand(?:\s|-| )(?:sq|square)\.?(?:\s|-| )ft([\s:;,\.?!][^\d\(\)\/\\][^\d\(\)\/\\])/gi, '$1\{\{convert|$2000|sqft|sqm|abbr=on\}\}$3');
txt.value=txt.value.replace(/([^\d\(\)\/\\=]\s)([\d,]{1,16})(?:\s|-| )thousand(?:\s|-| )(?:sq|square)\.?(?:\s|-| )feet([\s:;,\.?!][^\d\(\)\/\\][^\d\(\)\/\\])/gi, '$1\{\{convert|$2000|sqft|sqm\}\}$3');
txt.value=txt.value.replace(/([^\d\(\)\/\\=]\s)([\d,]{1,16})(?:\s|-| )thousand(?:\s|-| )(?:sq|square)\.?(?:\s|-| )foot([\s:;,\.?!][^\d\(\)\/\\][^\d\(\)\/\\])/gi, '$1\{\{convert|$2000|sqft|sqm|sing=on\}\}$3');
txt.value=txt.value.replace(/([^\d\(\)\/\\=]\s)([\d,]{1,16})(?:\s|-| )million(?:\s|-| )(?:sq|square)\.?(?:\s|-| )ft([\s:;,\.?!][^\d\(\)\/\\][^\d\(\)\/\\])/gi, '$1\{\{convert|$2000000|sqft|sqm|abbr=on\}\}$3');
txt.value=txt.value.replace(/([^\d\(\)\/\\=]\s)([\d,]{1,16})(?:\s|-| )million(?:\s|-| )(?:sq|square)\.?(?:\s|-| )feet([\s:;,\.?!][^\d\(\)\/\\][^\d\(\)\/\\])/gi, '$1\{\{convert|$2000000|sqft|sqm\}\}$3');
txt.value=txt.value.replace(/([^\d\(\)\/\\=]\s)([\d,]{1,16})(?:\s|-| )million(?:\s|-| )(?:sq|square)\.?(?:\s|-| )foot([\s:;,\.?!][^\d\(\)\/\\][^\d\(\)\/\\])/gi, '$1\{\{convert|$2000000|sqft|sqm|sing=on\}\}$3');
txt.value=txt.value.replace(/([^\d\(\)\/\\=]\s)([\d,]{1,16})\.(\d)(?:\s|-| )million(?:\s|-| )(?:sq|square)\.?(?:\s|-| )ft([\s:;,\.?!][^\d\(\)\/\\][^\d\(\)\/\\])/gi, '$1\{\{convert|$2$300000|sqft|sqm|abbr=on\}\}$4');
txt.value=txt.value.replace(/([^\d\(\)\/\\=]\s)([\d,]{1,16})\.(\d)(?:\s|-| )million(?:\s|-| )(?:sq|square)\.?(?:\s|-| )feet([\s:;,\.?!][^\d\(\)\/\\][^\d\(\)\/\\])/gi, '$1\{\{convert|$2$300000|sqft|sqm\}\}$4');
txt.value=txt.value.replace(/([^\d\(\)\/\\=]\s)([\d,]{1,16})\.(\d)(?:\s|-| )million(?:\s|-| )(?:sq|square)\.?(?:\s|-| )foot([\s:;,\.?!][^\d\(\)\/\\][^\d\(\)\/\\])/gi, '$1\{\{convert|$2$300000|sqft|sqm|sing=on\}\}$4');
txt.value=txt.value.replace(/([^\d\(\)\/\\=]\s)([\d,]{1,16})\.(\d\d)(?:\s|-| )million(?:\s|-| )(?:sq|square)\.?(?:\s|-| )ft([\s:;,\.?!][^\d\(\)\/\\][^\d\(\)\/\\])/gi, '$1\{\{convert|$2$30000|sqft|sqm|abbr=on\}\}$4');
txt.value=txt.value.replace(/([^\d\(\)\/\\=]\s)([\d,]{1,16})\.(\d\d)(?:\s|-| )million(?:\s|-| )(?:sq|square)\.?(?:\s|-| )feet([\s:;,\.?!][^\d\(\)\/\\][^\d\(\)\/\\])/gi, '$1\{\{convert|$2$30000|sqft|sqm\}\}$4');
txt.value=txt.value.replace(/([^\d\(\)\/\\=]\s)([\d,]{1,16})\.(\d\d)(?:\s|-| )million(?:\s|-| )(?:sq|square)\.?(?:\s|-| )foot([\s:;,\.?!][^\d\(\)\/\\][^\d\(\)\/\\])/gi, '$1\{\{convert|$2$30000|sqft|sqm|sing=on\}\}$4');
//feet per second
txt.value=txt.value.replace(/([^\d\(\)\/\\=]\s)(\d[\d,\.]{0,16})(?:\s|-|)(?:ft\/second|ft\/sec)([\s:;,\.?!][^\d\(\)\/\\][^\d\(\)\/\\])/gi, '$1$2 ft/s$3');
txt.value=txt.value.replace(/([^\d\(\)\/\\=]\s)(\d[\d,\.]{0,16}) (?:ft\/second|ft\/sec)([\s:;,\.?!][^\d\(\)\/\\][^\d\(\)\/\\])/gi, '$1$2 ft/s$3');
//feet per second:plural
txt.value=txt.value.replace(/([^\d\(\)\/\\=]\s)(\d[\d,\.]{0,16})(?:\s|-| )feet\sper\ssecond([\s:;,\.?!][^\d\(\)\/\\][^\d\(\)\/\\])/gi, '$1\{\{convert|$2|ft/s|m/s\}\}$3');
//feet per second:singular
txt.value=txt.value.replace(/([^\d\(\)\/\\=]\s)(\d[\d,\.]{0,16})(?:\s|-| )foot\sper\ssecond([\s:;,\.?!][^\d\(\)\/\\][^\d\(\)\/\\])/gi, '$1\{\{convert|$2|ft/s|m/s|sing=on\}\}$3');
//feet per second:abbreviated
txt.value=txt.value.replace(/([^\d\(\)\/\\=]\s)(\d[\d,\.]{0,16})(?:\s|-| )ft\/s([\s:;,\.?!][^\d\(\)\/\\][^\d\(\)\/\\])/gi, '$1\{\{convert|$2|ft/s|m/s|abbr=on\}\}$3');
// foot and inch
txt.value=txt.value.replace(/(ength[.]{1,3})(\d{1,4})\s?['’]\s?(\d{1,3})\s?["”]/gi, '$1$2 ft $3 in');
txt.value=txt.value.replace(/(idth[.]{1,3})(\d{1,4})\s?['’]\s?(\d{1,3})\s?["”]/gi, '$1$2 ft $3 in');
txt.value=txt.value.replace(/([\(\|:]\s?\d{1,4})\s?['’]\s?(\d{1,3})\s?["”]([^NESW])/g, '$1 ft $2 in$3');
txt.value=txt.value.replace(/(\d)\s?ft\s?(\d{1,3})\s?in/gi, '$1 ft $2 in');
// yard
txt.value=txt.value.replace(/(\d)\s?yds([\s:;,\.?!][^\d\(\)\/\\][^\d\(\)\/\\])/gi, '$1 yd$2');
txt.value=txt.value.replace(/(\d) yds([\s:;,\.?!][^\d\(\)\/\\][^\d\(\)\/\\])/gi, '$1 yd$2');
txt.value=txt.value.replace(/sq\.?\s?yds?/gi, 'sq yd');
txt.value=txt.value.replace(/yd\.\)/gi, 'yd)');
//yards: plural
txt.value=txt.value.replace(/([^\d\(\)\/\\=]\s)(\d[\d,\.]{0,16})(?:\s|-| )(?:yards|\[\[yard\]\]s|\[\[yards\]\])([\s:;,\.?!][^\d\(\)\/\\][^\d\(\)\/\\])/gi, '$1\{\{convert|$2|yd|m\}\}$3');
//yards: singular
txt.value=txt.value.replace(/([^\d\(\)\/\\=]\s)(\d[\d,\.]{0,16})(?:\s|-| )(?:yard|\[\[yard\]\])([\s:;,\.?!][^\d\(\)\/\\][^\d\(\)\/\\])/gi, '$1\{\{convert|$2|yd|m|sing=on\}\}$3');
//yards: abbreviated
txt.value=txt.value.replace(/([^\d\(\)\/\\=]\s)(\d[\d,\.]{0,16})(?:\s|-| )yd([\s:;,\.?!][^\d\(\)\/\\][^\d\(\)\/\\])/gi, '$1\{\{convert|$2|yd|m|abbr=on\}\}$3');
//yards: in full
txt.value=txt.value.replace(/([^y]\sone(?:\s|-| )yards?)([\s:;,\.?!][^\d\(\)\/\\][^\d\(\)\/\\])/gi, '$1 (1 m)$2');
txt.value=txt.value.replace(/([^y]\stwo(?:\s|-| )yards?)([\s:;,\.?!][^\d\(\)\/\\][^\d\(\)\/\\])/gi, '$1 (2 m)$2');
txt.value=txt.value.replace(/([^y]\sthree(?:\s|-| )yards?)([\s:;,\.?!][^\d\(\)\/\\][^\d\(\)\/\\])/gi, '$1 (3 m)$2');
txt.value=txt.value.replace(/([^y]\sfour(?:\s|-| )yards?)([\s:;,\.?!][^\d\(\)\/\\][^\d\(\)\/\\])/gi, '$1 (4 m)$2');
txt.value=txt.value.replace(/([^y]\sfive(?:\s|-| )yards?)([\s:;,\.?!][^\d\(\)\/\\][^\d\(\)\/\\])/gi, '$1 (5 m)$2');
txt.value=txt.value.replace(/([^y]\ssix(?:\s|-| )yards?)([\s:;,\.?!][^\d\(\)\/\\][^\d\(\)\/\\])/gi, '$1 (5 m)$2');
txt.value=txt.value.replace(/([^y]\sseven(?:\s|-| )yards?)([\s:;,\.?!][^\d\(\)\/\\][^\d\(\)\/\\])/gi, '$1 (6 m)$2');
txt.value=txt.value.replace(/([^y]\seight(?:\s|-| )yards?)([\s:;,\.?!][^\d\(\)\/\\][^\d\(\)\/\\])/gi, '$1 (7 m)$2');
txt.value=txt.value.replace(/([^y]\snine(?:\s|-| )yards?)([\s:;,\.?!][^\d\(\)\/\\][^\d\(\)\/\\])/gi, '$1 (8 m)$2');
txt.value=txt.value.replace(/([^y]\sten(?:\s|-| )yards?)([\s:;,\.?!][^\d\(\)\/\\][^\d\(\)\/\\])/gi, '$1 (9 m)$2');
txt.value=txt.value.replace(/([^y]\seleven(?:\s|-| )yards?)([\s:;,\.?!][^\d\(\)\/\\][^\d\(\)\/\\])/gi, '$1 (10 m)$2');
txt.value=txt.value.replace(/([^y]\stwelve(?:\s|-| )yards?)([\s:;,\.?!][^\d\(\)\/\\][^\d\(\)\/\\])/gi, '$1 (11 m)$2');
txt.value=txt.value.replace(/([^y]\sthirteen(?:\s|-| )yards?)([\s:;,\.?!][^\d\(\)\/\\][^\d\(\)\/\\])/gi, '$1 (12 m)$2');
txt.value=txt.value.replace(/([^y]\sfourteen(?:\s|-| )yards?)([\s:;,\.?!][^\d\(\)\/\\][^\d\(\)\/\\])/gi, '$1 (13 m)$2');
txt.value=txt.value.replace(/([^y]\sfifteen(?:\s|-| )yards?)([\s:;,\.?!][^\d\(\)\/\\][^\d\(\)\/\\])/gi, '$1 (14 m)$2');
txt.value=txt.value.replace(/([^y]\ssixteen(?:\s|-| )yards?)([\s:;,\.?!][^\d\(\)\/\\][^\d\(\)\/\\])/gi, '$1 (15 m)$2');
txt.value=txt.value.replace(/([^y]\sseventeen(?:\s|-| )yards?)([\s:;,\.?!][^\d\(\)\/\\][^\d\(\)\/\\])/gi, '$1 (16 m)$2');
txt.value=txt.value.replace(/([^y]\seighteen(?:\s|-| )yards?)([\s:;,\.?!][^\d\(\)\/\\][^\d\(\)\/\\])/gi, '$1 (16 m)$2');
txt.value=txt.value.replace(/([^y]\snineteen(?:\s|-| )yards?)([\s:;,\.?!][^\d\(\)\/\\][^\d\(\)\/\\])/gi, '$1 (17 m)$2');
txt.value=txt.value.replace(/([^y]\stwenty(?:\s|-| )yards?)([\s:;,\.?!][^\d\(\)\/\\][^\d\(\)\/\\])/gi, '$1 (18 m)$2');
// knot
txt.value=txt.value.replace(/(\d)(\s|-| )(?:kts|kt|knt)([\s:;,\.?!][^\d\(\)\/\\][^\d\(\)\/\\])/gi, '$1$2knots$3');
txt.value=txt.value.replace(/\[knot\s\(unit\)\|/gi, '[knot (speed)|');
txt.value=txt.value.replace(/\[\[kts\]\]/gi, '[[knot (speed)|knots]]');
txt.value=txt.value.replace(/\|kts\]\]/gi, '|knots]]');
//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,\.]{0,16})(?:\s|-| )nautical(?:\s|-| )miles([\s:;,\.?!][^\d\(\)\/\\][^\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,\.]{0,16})(?:\s|-| )\[\[nautical(?:\s|-| )miles\]\]([\s:;,\.?!][^\d\(\)\/\\][^\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,\.]{0,16})(?:\s|-| )\[\[nautical(?:\s|-| )mile\]\]s([\s:;,\.?!][^\d\(\)\/\\][^\d\(\)\/\\])/gi, '$1\{\{convert|$2|nmi|km\}\}$3');
//nautical mile: singular unlinked
txt.value=txt.value.replace(/([^\d\(\)\/\\=]\s)(\d[\d,\.]{0,16})(?:\s|-| )nautical(?:\s|-| )mile([\s:;,\.?!][^\d\(\)\/\\][^\d\(\)\/\\])/gi, '$1\{\{convert|$2|nmi|km|sing=on\}\}$3');
//nautical mile: singular linked
txt.value=txt.value.replace(/([^\d\(\)\/\\=]\s)(\d[\d,\.]{0,16})(?:\s|-| )\[\[nautical(?:\s|-| )mile\]\]([\s:;,\.?!][^\d\(\)\/\\][^\d\(\)\/\\])/gi, '$1\{\{convert|$2|nmi|km|sing=on\}\}$3');
//nautical mile: abbreviated
txt.value=txt.value.replace(/([^\d\(\)\/\\=]\s)(\d[\d,\.]{0,16})(?:\s|-| )(?:\[\[nautical\smile\|nmi?\]\]|nmi)([\s:;,\.?!][^\d\(\)\/\\][^\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\(\)\/\\][^\d\(\)\/\\])/gi, '$1 (1.9 km)$2');
txt.value=txt.value.replace(/([^y]\stwo(?:\s|-| )nautical(?:\s|-| )miles?)([\s:;,\.?!][^\d\(\)\/\\][^\d\(\)\/\\])/gi, '$1 (4 km)$2');
txt.value=txt.value.replace(/([^y]\sthree(?:\s|-| )nautical(?:\s|-| )miles?)([\s:;,\.?!][^\d\(\)\/\\][^\d\(\)\/\\])/gi, '$1 (6 km)$2');
txt.value=txt.value.replace(/([^y]\sfour(?:\s|-| )nautical(?:\s|-| )miles?)([\s:;,\.?!][^\d\(\)\/\\][^\d\(\)\/\\])/gi, '$1 (7 km)$2');
txt.value=txt.value.replace(/([^y]\sfive(?:\s|-| )nautical(?:\s|-| )miles?)([\s:;,\.?!][^\d\(\)\/\\][^\d\(\)\/\\])/gi, '$1 (9 km)$2');
txt.value=txt.value.replace(/([^y]\ssix(?:\s|-| )nautical(?:\s|-| )miles?)([\s:;,\.?!][^\d\(\)\/\\][^\d\(\)\/\\])/gi, '$1 (11 km)$2');
txt.value=txt.value.replace(/([^y]\sseven(?:\s|-| )nautical(?:\s|-| )miles?)([\s:;,\.?!][^\d\(\)\/\\][^\d\(\)\/\\])/gi, '$1 (13 km)$2');
txt.value=txt.value.replace(/([^y]\seight(?:\s|-| )nautical(?:\s|-| )miles?)([\s:;,\.?!][^\d\(\)\/\\][^\d\(\)\/\\])/gi, '$1 (15 km)$2');
txt.value=txt.value.replace(/([^y]\snine(?:\s|-| )nautical(?:\s|-| )miles?)([\s:;,\.?!][^\d\(\)\/\\][^\d\(\)\/\\])/gi, '$1 (17 km)$2');
txt.value=txt.value.replace(/([^y]\sten(?:\s|-| )nautical(?:\s|-| )miles?)([\s:;,\.?!][^\d\(\)\/\\][^\d\(\)\/\\])/gi, '$1 (19 km)$2');
txt.value=txt.value.replace(/([^y]\seleven(?:\s|-| )nautical(?:\s|-| )miles?)([\s:;,\.?!][^\d\(\)\/\\][^\d\(\)\/\\])/gi, '$1 (20 km)$2');
txt.value=txt.value.replace(/([^y]\stwelve(?:\s|-| )nautical(?:\s|-| )miles?)([\s:;,\.?!][^\d\(\)\/\\][^\d\(\)\/\\])/gi, '$1 (22 km)$2');
txt.value=txt.value.replace(/([^y]\sthirteen(?:\s|-| )nautical(?:\s|-| )miles?)([\s:;,\.?!][^\d\(\)\/\\][^\d\(\)\/\\])/gi, '$1 (24 km)$2');
txt.value=txt.value.replace(/([^y]\sfourteen(?:\s|-| )nautical(?:\s|-| )miles?)([\s:;,\.?!][^\d\(\)\/\\][^\d\(\)\/\\])/gi, '$1 (26 km)$2');
txt.value=txt.value.replace(/([^y]\sfifteen(?:\s|-| )nautical(?:\s|-| )miles?)([\s:;,\.?!][^\d\(\)\/\\][^\d\(\)\/\\])/gi, '$1 (28 km)$2');
txt.value=txt.value.replace(/([^y]\ssixteen(?:\s|-| )nautical(?:\s|-| )miles?)([\s:;,\.?!][^\d\(\)\/\\][^\d\(\)\/\\])/gi, '$1 (30 km)$2');
txt.value=txt.value.replace(/([^y]\sseventeen(?:\s|-| )nautical(?:\s|-| )miles?)([\s:;,\.?!][^\d\(\)\/\\][^\d\(\)\/\\])/gi, '$1 (31 km)$2');
txt.value=txt.value.replace(/([^y]\seighteen(?:\s|-| )nautical(?:\s|-| )miles?)([\s:;,\.?!][^\d\(\)\/\\][^\d\(\)\/\\])/gi, '$1 (33 km)$2');
txt.value=txt.value.replace(/([^y]\snineteen(?:\s|-| )nautical(?:\s|-| )miles?)([\s:;,\.?!][^\d\(\)\/\\][^\d\(\)\/\\])/gi, '$1 (35 km)$2');
txt.value=txt.value.replace(/([^y]\stwenty(?:\s|-| )nautical(?:\s|-| )miles?)([\s:;,\.?!][^\d\(\)\/\\][^\d\(\)\/\\])/gi, '$1 (37 km)$2');
//knot - plural
txt.value=txt.value.replace(/([^\d\(\)\/\\=]\s)(\d[\d,\.]{0,16})(?:\s|-| |)(?:knots|\[\[knot\s\(speed\)\|(?:knots\]\]|knot\]\]s))([\s:;,\.?!][^\d\(\)\/\\][^\d\(\)\/\\])/gi, '$1\{\{convert|$2|knot|km/h\}\}$3');
//knot - singular
txt.value=txt.value.replace(/([^\d\(\)\/\\=]\s)(\d[\d,\.]{0,16})(?:\s|-| )(?:knot|\[\[knot\s\(speed\)\|knot\]\])([\s:;,\.?!][^\d\(\)\/\\][^\d\(\)\/\\])/gi, '$1\{\{convert|$2|knot|km/h|sing=on\}\}$3');
//knot - abbreviation
txt.value=txt.value.replace(/([^\d\(\)\/\\=]\s)(\d[\d,\.]{0,16})(?:\s|-| )(?:kts?|\[\[knot\s\(speed\)\|kts?\]\])([\s:;,\.?!][^\d\(\)\/\\][^\d\(\)\/\\])/gi, '$1\{\{convert|$2|knot|km/h|abbr=on\}\}$3');
//mile - lower case to avoid proper names like 'Five Mile Road'
//mile - protect 'miles per hour' - undone below
txt.value=txt.value.replace(/(miles?)\s(per)/gi, '$1xx$2');
//miles: plural
txt.value=txt.value.replace(/([^\d\(\)\/\\=]\s)(\d[\d,\.]{0,16})(?:\s|-| )(?:miles|\[\[miles\]\]|\[\[mile\]\]s)([\s:;,\.?!][^\d\(\)\/\\][^\d\(\)\/\\])/g, '$1\{\{convert|$2|mi|km\}\}$3');
//miles: singular
txt.value=txt.value.replace(/([^\d\(\)\/\\=]\s)(\d[\d,\.]{0,16})(?:\s|-| )(?:mile|\[\[mile\]\])([\s:;,\.?!][^p\d\(\)\/\\][^\d\(\)\/\\])/g, '$1\{\{convert|$2|mi|km|sing=on\}\}$3');
//miles: abbreviated
txt.value=txt.value.replace(/([^\d\(\)\/\\=]\s)(\d[\d,\.]{0,16})(?:\s|-| )mi([\s:;,\.?!][^\d\(\)\/\\][^\d\(\)\/\\])/g, '$1\{\{convert|$2|mi|km|abbr=on\}\}$3');
//miles: in full
txt.value=txt.value.replace(/([^y]\sone(?:\s|-| )miles?)([\s:;,\.?!][^\d\(\)\/\\][^\d\(\)\/\\])/g, '$1 (1.6 km)$2');
txt.value=txt.value.replace(/([^y]\stwo(?:\s|-| )miles?)([\s:;,\.?!][^\d\(\)\/\\][^\d\(\)\/\\])/g, '$1 (3 km)$2');
txt.value=txt.value.replace(/([^y]\sthree(?:\s|-| )miles?)([\s:;,\.?!][^\d\(\)\/\\][^\d\(\)\/\\])/g, '$1 (5 km)$2');
txt.value=txt.value.replace(/([^y]\sfour(?:\s|-| )miles?)([\s:;,\.?!][^\d\(\)\/\\][^\d\(\)\/\\])/g, '$1 (6 km)$2');
txt.value=txt.value.replace(/([^y]\sfive(?:\s|-| )miles?)([\s:;,\.?!][^\d\(\)\/\\][^\d\(\)\/\\])/g, '$1 (8 km)$2');
txt.value=txt.value.replace(/([^y]\ssix(?:\s|-| )miles?)([\s:;,\.?!][^\d\(\)\/\\][^\d\(\)\/\\])/g, '$1 (10 km)$2');
txt.value=txt.value.replace(/([^y]\sseven(?:\s|-| )miles?)([\s:;,\.?!][^\d\(\)\/\\][^\d\(\)\/\\])/g, '$1 (11 km)$2');
txt.value=txt.value.replace(/([^y]\seight(?:\s|-| )miles?)([\s:;,\.?!][^\d\(\)\/\\][^\d\(\)\/\\])/g, '$1 (13 km)$2');
txt.value=txt.value.replace(/([^y]\snine(?:\s|-| )miles?)([\s:;,\.?!][^\d\(\)\/\\][^\d\(\)\/\\])/g, '$1 (14 km)$2');
txt.value=txt.value.replace(/([^y]\sten(?:\s|-| )miles?)([\s:;,\.?!][^\d\(\)\/\\][^\d\(\)\/\\])/g, '$1 (16 km)$2');
txt.value=txt.value.replace(/([^y]\seleven(?:\s|-| )miles?)([\s:;,\.?!][^\d\(\)\/\\][^\d\(\)\/\\])/g, '$1 (18 km)$2');
txt.value=txt.value.replace(/([^y]\stwelve(?:\s|-| )miles?)([\s:;,\.?!][^\d\(\)\/\\][^\d\(\)\/\\])/g, '$1 (19 km)$2');
txt.value=txt.value.replace(/([^y]\sthirteen(?:\s|-| )miles?)([\s:;,\.?!][^\d\(\)\/\\][^\d\(\)\/\\])/g, '$1 (19 km)$2');
txt.value=txt.value.replace(/([^y]\sfourteen(?:\s|-| )miles?)([\s:;,\.?!][^\d\(\)\/\\][^\d\(\)\/\\])/g, '$1 (21 km)$2');
txt.value=txt.value.replace(/([^y]\sfifteen(?:\s|-| )miles?)([\s:;,\.?!][^\d\(\)\/\\][^\d\(\)\/\\])/g, '$1 (24 km)$2');
txt.value=txt.value.replace(/([^y]\sixteen(?:\s|-| )miles?)([\s:;,\.?!][^\d\(\)\/\\][^\d\(\)\/\\])/g, '$1 (26 km)$2');
txt.value=txt.value.replace(/([^y]\sseventeen(?:\s|-| )miles?)([\s:;,\.?!][^\d\(\)\/\\][^\d\(\)\/\\])/g, '$1 (27 km)$2');
txt.value=txt.value.replace(/([^y]\seighteen(?:\s|-| )miles?)([\s:;,\.?!][^\d\(\)\/\\][^\d\(\)\/\\])/g, '$1 (29 km)$2');
txt.value=txt.value.replace(/([^y]\snineteen(?:\s|-| )miles?)([\s:;,\.?!][^\d\(\)\/\\][^\d\(\)\/\\])/g, '$1 (30 km)$2');
txt.value=txt.value.replace(/([^y]\stwenty(?:\s|-| )miles?)([\s:;,\.?!][^\d\(\)\/\\][^\d\(\)\/\\])/g, '$1 (32 km)$2');
//mile - unprotect 'miles per hour'
txt.value=txt.value.replace(/(miles?)xx(per)/gi, '$1 $2');
//mile per hour
txt.value=txt.value.replace(/([^\d\(\)\/\\=]\s)(\d[\d,\.]{0,16})(?:\s|-| )m\.?p\.?h([\s:;,\.?!][^\d\(\)\/\\][^\d\(\)\/\\])/g, '$1\{\{convert|$2|mi/h|km/h|abbr=on\}\}$3');
// square mile
txt.value=txt.value.replace(/(\d)(?:\s|-)sq(?:\s|\.\s|-)mi([\s:;,\.?!][^\d\(\)\/\\][^\d\(\)\/\\])/gi, '$1 sq mi$2');
txt.value=txt.value.replace(/\[\[(square\smile)\]\]/gi, '$1');
txt.value=txt.value.replace(/\[\[square\smile\|(sq\smi)\]\]/gi, '$1');
txt.value=txt.value.replace(/(sq)(?:\s|-| )(mile)/gi, '$1uare $2');
// square mile:plural
txt.value=txt.value.replace(/([^\d\(\)\/\\=]\s)(\d[\d,\.]{0,16})(?:\s|-| )square(?:\s|-| )miles([\s:;,\.?!][^\d\(\)\/\\][^\d\(\)\/\\])/gi, '$1\{\{convert|$2|sqmi|sqkm\}\}$3');
// square mile:singular
txt.value=txt.value.replace(/([^\d\(\)\/\\=]\s)(\d[\d,\.]{0,16})(?:\s|-| )square(?:\s|-| )mile([\s:;,\.?!][^\d\(\)\/\\][^\d\(\)\/\\])/gi, '$1\{\{convert|$2|sqmi|sqkm|sing=on\}\}$3');
// square mile:abbreviated
txt.value=txt.value.replace(/([^\d\(\)\/\\=]\s)(\d[\d,\.]{0,16})(?:\s|-| )sq(?:\s|-| )mi([\s:;,\.?!][^\d\(\)\/\\][^\d\(\)\/\\])/gi, '$1\{\{convert|$2|sqmi|sqkm|abbr=on\}\}$3');
//acre foot:plural
txt.value=txt.value.replace(/([^\d\(\)\/\\=]\s)([\d,]{3,16}[\d,\.]{0,16})(?:\s|-| )acre(?:\s|-| )feet([\s:;,\.?!][^\d\(\)\/\\][^\d\(\)\/\\])/g, '$1\{\{convert|$2|acre feet\}\}$3');
//acre foot:singular
txt.value=txt.value.replace(/([^\d\(\)\/\\=]\s)([\d,]{3,16}[\d,\.]{0,16})(?:\s|-| )acre(?:\s|-| )foot([\s:;,\.?!][^\d\(\)\/\\][^\d\(\)\/\\])/g, '$1\{\{convert|$2|acre feet|sing=on\}\}$3');
//acre foot:abbreviation
txt.value=txt.value.replace(/([^\d\(\)\/\\=]\s)([\d,]{3,16}[\d,\.]{0,16})(?:\s|-| )(?:acre|ac\.?)(?:\s|-| )(?:foot|feet|ft)([\s:;,\.?!][^\d\(\)\/\\][^\d\(\)\/\\])/g, '$1\{\{convert|$2|acre ft|abbr=on\}\}$3');
//acre
//acres - temporary change to protect acre feet. changed below
txt.value=txt.value.replace(/(acre.feet)/gi, 'xtempx$1ytempy');
txt.value=txt.value.replace(/(\d)-(acre)/gi, '$1 $2');
txt.value=txt.value.replace(/(\d)(?:\s|-| )surface(?:\s|-| )acre/gi, '$1 acre');
txt.value=txt.value.replace(/([^\d\(\)\/\\=]\s)([\d,]{1,16})(?:\s|-| )thousand(?:\s|-| )(?:acres|\[\[acres\]\]|\[\[acre\]\]s)([\s:;,\.?!][^\d\(\)\/\\][^\d\(\)\/\\])/gi, '$1\{\{convert|$2000|acre|sqkm\}\}$3');
txt.value=txt.value.replace(/([^\d\(\)\/\\=]\s)([\d,]{1,16})(?:\s|-| )thousand(?:\s|-| )(?:acre|\[\[acre\]\])([\s:;,\.?!][^\d\(\)\/\\][^\d\(\)\/\\])/gi, '$1\{\{convert|$2000|acre|sqkm|sing=on\}\}$3');
txt.value=txt.value.replace(/([^\d\(\)\/\\=]\s)([\d,]{1,16})(?:\s|-| )million(?:\s|-| )(?:acres|\[\[acres\]\]|\[\[acre\]\]s)([\s:;,\.?!][^\d\(\)\/\\][^\d\(\)\/\\])/gi, '$1\{\{convert|$2000000|acre|sqkm\}\}$3');
txt.value=txt.value.replace(/([^\d\(\)\/\\=]\s)([\d,]{1,16})(?:\s|-| )million(?:\s|-| )(?:acre|\[\[acre\]\])([\s:;,\.?!][^\d\(\)\/\\][^\d\(\)\/\\])/gi, '$1\{\{convert|$2000000|acre|sqkm|sing=on\}\}$3');
txt.value=txt.value.replace(/([^\d\(\)\/\\=]\s)([\d,]{1,16})\.(\d)(?:\s|-| )million(?:\s|-| )(?:acres|\[\[acres\]\]|\[\[acre\]\]s)([\s:;,\.?!][^\d\(\)\/\\][^\d\(\)\/\\])/gi, '$1\{\{convert|$2$300000|acre|sqkm\}\}$4');
txt.value=txt.value.replace(/([^\d\(\)\/\\=]\s)([\d,]{1,16})\.(\d)(?:\s|-| )million(?:\s|-| )(?:acre|\[\[acre\]\])([\s:;,\.?!][^\d\(\)\/\\][^\d\(\)\/\\])/gi, '$1\{\{convert|$2$300000|acre|sqkm|sing=on\}\}$4');
txt.value=txt.value.replace(/([^\d\(\)\/\\=]\s)([\d,]{1,16})\.(\d\d)(?:\s|-| )million(?:\s|-| )(?:acres|\[\[acres\]\]|\[\[acre\]\]s)([\s:;,\.?!][^\d\(\)\/\\][^\d\(\)\/\\])/gi, '$1\{\{convert|$2$30000|acre|sqkm\}\}$4');
txt.value=txt.value.replace(/([^\d\(\)\/\\=]\s)([\d,]{1,16})\.(\d\d)(?:\s|-| )million(?:\s|-| )(?:acre|\[\[acre\]\])([\s:;,\.?!][^\d\(\)\/\\][^\d\(\)\/\\])/gi, '$1\{\{convert|$2$30000|acre|sqkm|sing=on\}\}$4');
txt.value=txt.value.replace(/([^y]\sone(?:\s|-| )million(?:\s|-| )acres?)([\s:;,\.?!][^\d\(\)\/\\][^\d\(\)\/\\])/gi, '$1 (4,000 km²)$2');
txt.value=txt.value.replace(/(\sa(?:\s|-| )million(?:\s|-| )acres?)([\s:;,\.?!][^\d\(\)\/\\][^\d\(\)\/\\])/gi, '$1 (4,000 km²)$2');
txt.value=txt.value.replace(/([^y]\stwo(?:\s|-| )million(?:\s|-| )acres?)([\s:;,\.?!][^\d\(\)\/\\][^\d\(\)\/\\])/gi, '$1 (8,000 km²)$2');
txt.value=txt.value.replace(/([^y]\sthree(?:\s|-| )million(?:\s|-| )acres?)([\s:;,\.?!][^\d\(\)\/\\][^\d\(\)\/\\])/gi, '$1 (12,000 km²)$2');
txt.value=txt.value.replace(/([^y]\sfour(?:\s|-| )million(?:\s|-| )acres?)([\s:;,\.?!][^\d\(\)\/\\][^\d\(\)\/\\])/gi, '$1 (16,000 km²)$2');
txt.value=txt.value.replace(/([^y]\sfive(?:\s|-| )million(?:\s|-| )acres?)([\s:;,\.?!][^\d\(\)\/\\][^\d\(\)\/\\])/gi, '$1 (20,000 km²)$2');
txt.value=txt.value.replace(/([^y]\ssix(?:\s|-| )million(?:\s|-| )acres?)([\s:;,\.?!][^\d\(\)\/\\][^\d\(\)\/\\])/gi, '$1 (24,000 km²)$2');
txt.value=txt.value.replace(/([^y]\sseven(?:\s|-| )million(?:\s|-| )acres?)([\s:;,\.?!][^\d\(\)\/\\][^\d\(\)\/\\])/gi, '$1 (28,000 km²)$2');
txt.value=txt.value.replace(/([^y]\seight(?:\s|-| )million(?:\s|-| )acres?)([\s:;,\.?!][^\d\(\)\/\\][^\d\(\)\/\\])/gi, '$1 (32,000 km²)$2');
txt.value=txt.value.replace(/([^y]\snine(?:\s|-| )million(?:\s|-| )acres?)([\s:;,\.?!][^\d\(\)\/\\][^\d\(\)\/\\])/gi, '$1 (36,000 km²)$2');
txt.value=txt.value.replace(/([^y]\sten(?:\s|-| )million(?:\s|-| )acres?)([\s:;,\.?!][^\d\(\)\/\\][^\d\(\)\/\\])/gi, '$1 (40,000 km²)$2');
//acre:plural
txt.value=txt.value.replace(/([^\d\(\)\/\\=]\s)([\d,]{3,16}[\d,\.]{0,16})(?:\s|-| )(?:acres|\[\[acres\]\]|\[\[acre\]\]s)([\s:;,\.?!][^\d\(\)\/\\][^\d\(\)\/\\])/g, '$1\{\{convert|$2|acre|sqkm\}\}$3');
//acre:singular
txt.value=txt.value.replace(/([^\d\(\)\/\\=]\s)([\d,]{3,16}[\d,\.]{0,16})(?:\s|-| )(?:acre|\[\[acre\]\])([\s:;,\.?!][^\d\(\)\/\\][^\d\(\)\/\\])/g, '$1\{\{convert|$2|acre|sqkm|sing=on\}\}$3');
//undo protection for acre feet
txt.value=txt.value.replace(/xtempx(acre.feet)ytempy/gi, '$1');
// foot pound
txt.value=txt.value.replace(/(\W)lbs?[\s-.·•\/]{1,2}ft([^²\w])/gi, '$1ft·lbf$2');
txt.value=txt.value.replace(/(\W)lbs?ft([\s:;,\.?!][^\d\(\)\/\\][^\d\(\)\/\\])/gi, '$1ft·lbf$2');
txt.value=txt.value.replace(/ftlbs?([\s:;,\.?!][^\d\(\)\/\\][^\d\(\)\/\\])/gi, 'ft·lbf$1');
txt.value=txt.value.replace(/ft[\s-.·•\/]{1,2}lbs?([\s:;,\.?!][^\d\(\)\/\\][^\d\(\)\/\\])/gi, 'ft·lbf$1');
txt.value=txt.value.replace(/ftlbs?([\s:;,\.?!][^\d\(\)\/\\][^\d\(\)\/\\])/gi, 'ft·lbf$1');
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,\.]{0,16})(?:\s|-| )ft.lbf([\s:;,\.?!][^\d\(\)\/\\][^\d\(\)\/\\])/g, '$1\{\{convert|$2|ft.lbf|N.m|abbr=on\}\}$3');
// pound force
txt.value=txt.value.replace(/([^\d\(\)\/\\=]\s)(\d[\d,\.]{0,16})(\s|-| |)lbs?.?\s(thrust|of\sthrust|force|of\sforce)([\s:;,\.?!][^\d\(\)\/\\][^\d\(\)\/\\])/gi, '$1$2$3lbf $4$5');
txt.value=txt.value.replace(/([^\d\(\)\/\\=]\s)(\d[\d,\.]{0,16}000)(?:\s|-| |)lbf([\s:;,\.?!][^\d\(\)\/\\][^\d\(\)\/\\])/gi, '$1\{\{convert|$2|lbf|kN|abbr=on\}\}$3');
txt.value=txt.value.replace(/([^\d\(\)\/\\=]\s)(\d[\d,\.]{0,16})(?:\s|-| |)lbf([\s:;,\.?!][^\d\(\)\/\\][^\d\(\)\/\\])/gi, '$1\{\{convert|$2|lbf|abbr=on\}\}$3');
// pound weight. Parsed after foot pound and pound force
txt.value=txt.value.replace(/\[\[\pound\s\(weight\)\|([^\]]{1,30})\]\]/gi, '[[pound (mass)|$1]]');
txt.value=txt.value.replace(/\|lbs?\.\]\]/gi, '|lb]]');
txt.value=txt.value.replace(/(\d)\s?lbs?([\s:;,\.?!][^\d\(\)\/\\][^\d\(\)\/\\])/gi, '$1 lb$2');
txt.value=txt.value.replace(/(\d\+?)\s?lbs?([\s:;,\.?!][^\d\(\)\/\\][^\d\(\)\/\\])/gi, '$1 lb$2');
txt.value=txt.value.replace(/(\d) lbs?([\s:;,\.?!][^\d\(\)\/\\][^\d\(\)\/\\])/gi, '$1 lb$2');
txt.value=txt.value.replace(/([^\d\(\)\/\\=]\s)(\d[\d,\.]{0,16})(?:\s|-| )lb([\s:;,\.?!][^\d\(\)\/\\][^\d\(\)\/\\])/gi, '$1\{\{convert|$2|lb|abbr=on\}\}$3');
//foot (again). Parsed after 'foot per second' and 'foot pound'
//foot: plural
txt.value=txt.value.replace(/([^\d\(\)\/\\=]\s)(\d[\d,\.]{0,16})(?:\s|-| )feet([\s:;,\.?!][^\d\(\)\/\\][^\d\(\)\/\\])/gi, '$1\{\{convert|$2|ft|m\}\}$3');
//foot: singular
txt.value=txt.value.replace(/([^\d\(\)\/\\=]\s)(\d[\d,\.]{0,16})(?:\s|-| )foot([\s:;,\.?!][^\d\(\)\/\\][^\d\(\)\/\\])/gi, '$1\{\{convert|$2|ft|m|sing=on\}\}$3');
//foot: abbreviated
txt.value=txt.value.replace(/([^\d\(\)\/\\=]\s)(\d[\d,\.]{0,16})(?:\s|-| )ft([\s:;,\.?!][^\d\(\)\/\\][^\d\(\)\/\\])/gi, '$1\{\{convert|$2|ft|m|abbr=on\}\}$3');
//inch: plural
txt.value=txt.value.replace(/([^\Wt'’]\s)(\d[\d,\.]{0,16})(?:\s|-| )inches([\s:;,\.?!][^\d\(\)\/\\][^\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\(\)\/\\][^\d\(\)\/\\])/gi, '$1 (76 mm) $2');
txt.value=txt.value.replace(/([^ty]\sfour(?:\s|-| )(?:inches|\[\[inches\]\]))([\s:;,\.?!][^\d\(\)\/\\][^\d\(\)\/\\])/gi, '$1 (102 mm) $2');
txt.value=txt.value.replace(/([^ty]\sfive(?:\s|-| )(?:inches|\[\[inches\]\]))([\s:;,\.?!][^\d\(\)\/\\][^\d\(\)\/\\])/gi, '$1 (127 mm) $2');
txt.value=txt.value.replace(/([^ty]\ssix(?:\s|-| )(?:inches|\[\[inches\]\]))([\s:;,\.?!][^\d\(\)\/\\][^\d\(\)\/\\])/gi, '$1 (152 mm) $2');
txt.value=txt.value.replace(/([^ty]\sseven(?:\s|-| )(?:inches|\[\[inches\]\]))([\s:;,\.?!][^\d\(\)\/\\][^\d\(\)\/\\])/gi, '$1 (178 mm) $2');
txt.value=txt.value.replace(/([^ty]\seight(?:\s|-| )(?:inches|\[\[inches\]\]))([\s:;,\.?!][^\d\(\)\/\\][^\d\(\)\/\\])/gi, '$1 (203 mm) $2');
txt.value=txt.value.replace(/([^ty]\snine(?:\s|-| )(?:inches|\[\[inches\]\]))([\s:;,\.?!][^\d\(\)\/\\][^\d\(\)\/\\])/gi, '$1 (229 mm) $2');
txt.value=txt.value.replace(/([^ty]\sten(?:\s|-| )(?:inches|\[\[inches\]\]))([\s:;,\.?!][^\d\(\)\/\\][^\d\(\)\/\\])/gi, '$1 (254 mm) $2');
txt.value=txt.value.replace(/([^ty]\seleven(?:\s|-| )(?:inches|\[\[inches\]\]))([\s:;,\.?!][^\d\(\)\/\\][^\d\(\)\/\\])/gi, '$1 (279 mm) $2');
txt.value=txt.value.replace(/([^ty]\stwelve(?:\s|-| )(?:inches|\[\[inches\]\]))([\s:;,\.?!][^\d\(\)\/\\][^\d\(\)\/\\])/gi, '$1 (305 mm) $2');
txt.value=txt.value.replace(/([^ty]\sthirteen(?:\s|-| )(?:inches|\[\[inches\]\]))([\s:;,\.?!][^\d\(\)\/\\][^\d\(\)\/\\])/gi, '$1 (330 mm) $2');
txt.value=txt.value.replace(/([^ty]\sfourteen(?:\s|-| )(?:inches|\[\[inches\]\]))([\s:;,\.?!][^\d\(\)\/\\][^\d\(\)\/\\])/gi, '$1 (356 mm) $2');
txt.value=txt.value.replace(/([^ty]\sfifteen(?:\s|-| )(?:inches|\[\[inches\]\]))([\s:;,\.?!][^\d\(\)\/\\][^\d\(\)\/\\])/gi, '$1 (381 mm) $2');
txt.value=txt.value.replace(/([^ty]\ssixteen(?:\s|-| )(?:inches|\[\[inches\]\]))([\s:;,\.?!][^\d\(\)\/\\][^\d\(\)\/\\])/gi, '$1 (406 mm) $2');
//inch: singular
txt.value=txt.value.replace(/([^\Wt'’]\s)(\d[\d,\.]{0,16})(?:\s|-| )(?:inch|\[\[inch\]\])([\s:;,\.?!][^\d\(\)\/\\][^\d\(\)\/\\])/gi, '$1\{\{convert|$2|in|mm|sing=on\}\}$3');
txt.value=txt.value.replace(/({convert\|\d{1,16}\|(?:in|mm|cm)[^\}]{0,16})\|lk=(?:on|in|out)/g, '$1');
// inch: singular with number in words
txt.value=txt.value.replace(/([^ty]\sthree(?:\s|-| )(?:inch|\[\[inch\]\]))([\s:;,\.?!][^\d\(\)\/\\][^\d\(\)\/\\])/gi, '$1 (76 mm) $2');
txt.value=txt.value.replace(/([^ty]\sfour(?:\s|-| )(?:inch|\[\[inch\]\]))([\s:;,\.?!][^\d\(\)\/\\][^\d\(\)\/\\])/gi, '$1 (102 mm) $2');
txt.value=txt.value.replace(/([^ty]\sfive(?:\s|-| )(?:inch|\[\[inch\]\]))([\s:;,\.?!][^\d\(\)\/\\][^\d\(\)\/\\])/gi, '$1 (127 mm) $2');
txt.value=txt.value.replace(/([^ty]\ssix(?:\s|-| )(?:inch|\[\[inch\]\]))([\s:;,\.?!][^\d\(\)\/\\][^\d\(\)\/\\])/gi, '$1 (152 mm) $2');
txt.value=txt.value.replace(/([^ty]\sseven(?:\s|-| )(?:inch|\[\[inch\]\]))([\s:;,\.?!][^\d\(\)\/\\][^\d\(\)\/\\])/gi, '$1 (178 mm) $2');
txt.value=txt.value.replace(/([^ty]\seight(?:\s|-| )(?:inch|\[\[inch\]\]))([\s:;,\.?!][^\d\(\)\/\\][^\d\(\)\/\\])/gi, '$1 (203 mm) $2');
txt.value=txt.value.replace(/([^ty]\snine(?:\s|-| )(?:inch|\[\[inch\]\]))([\s:;,\.?!][^\d\(\)\/\\][^\d\(\)\/\\])/gi, '$1 (229 mm) $2');
txt.value=txt.value.replace(/([^ty]\sten(?:\s|-| )(?:inch|\[\[inch\]\]))([\s:;,\.?!][^\d\(\)\/\\][^\d\(\)\/\\])/gi, '$1 (254 mm) $2');
txt.value=txt.value.replace(/([^ty]\seleven(?:\s|-| )(?:inch|\[\[inch\]\]))([\s:;,\.?!][^\d\(\)\/\\][^\d\(\)\/\\])/gi, '$1 (279 mm) $2');
txt.value=txt.value.replace(/([^ty]\stwelve(?:\s|-| )(?:inch|\[\[inch\]\]))([\s:;,\.?!][^\d\(\)\/\\][^\d\(\)\/\\])/gi, '$1 (305 mm) $2');
txt.value=txt.value.replace(/([^ty]\sthirteen(?:\s|-| )(?:inch|\[\[inch\]\]))([\s:;,\.?!][^\d\(\)\/\\][^\d\(\)\/\\])/gi, '$1 (330 mm) $2');
txt.value=txt.value.replace(/([^ty]\sfourteen(?:\s|-| )(?:inch|\[\[inch\]\]))([\s:;,\.?!][^\d\(\)\/\\][^\d\(\)\/\\])/gi, '$1 (356 mm) $2');
txt.value=txt.value.replace(/([^ty]\sfifteen(?:\s|-| )(?:inch|\[\[inch\]\]))([\s:;,\.?!][^\d\(\)\/\\][^\d\(\)\/\\])/gi, '$1 (381 mm) $2');
txt.value=txt.value.replace(/([^ty]\ssixteen(?:\s|-| )(?:inch|\[\[inch\]\]))([\s:;,\.?!][^\d\(\)\/\\][^\d\(\)\/\\])/gi, '$1 (406 mm) $2');
// horsepower
txt.value=txt.value.replace(/\.28\s?(bhp|ihp|shp)\.29\|/gi, '($1)|');
txt.value=txt.value.replace(/(\d)(?:\s|-|)(horsepower|hp|bhp|ihp|shp)([\s:;,\.?!][^\d\(\)\/\\][^\d\(\)\/\\])/gi, '$1 $2$3');
txt.value=txt.value.replace(/(\d) (horsepower|hp|bhp|ihp|shp)([\s:;,\.?!][^\d\(\)\/\\][^\d\(\)\/\\])/gi, '$1 $2$3');
txt.value=txt.value.replace(/(\d)(?:\s|-|)horse(?:\s|-|)power([\s:;,\.?!][^\d\(\)\/\\][^\d\(\)\/\\])/gi, '$1 horsepower$2');
txt.value=txt.value.replace(/([^\d\(\)\/\\=]\s)(\d[\d,\.]{0,16})(?:\s|-| )(horsepower)([\s:;,\.?!][^\d\(\)\/\\][^\d\(\)\/\\])/gi, '$1\{\{convert|$2|hp\}\}$4');
txt.value=txt.value.replace(/([^\d\(\)\/\\=]\s)(\d[\d,\.]{0,16})(?:\s|-| )(indicated(?:\s|-| )horsepower)([\s:;,\.?!][^\d\(\)\/\\][^\d\(\)\/\\])/gi, '$1\{\{convert|$2|ihp\}\}$4');
txt.value=txt.value.replace(/([^\d\(\)\/\\=]\s)(\d[\d,\.]{0,16})(?:\s|-| )(hp|bhp|ihp|shp)([\s:;,\.?!][^\d\(\)\/\\][^\d\(\)\/\\])/gi, '$1\{\{convert|$2|$3|abbr=on\}\}$4');
// rpm
txt.value=txt.value.replace(/(\d)\s?rpm([\s:;,\.?!][^\d\(\)\/\\][^\d\(\)\/\\])/gi, '$1 rpm$2');
txt.value=txt.value.replace(/(\d) rpm([\s:;,\.?!][^\d\(\)\/\\][^\d\(\)\/\\])/gi, '$1 rpm$2');
txt.value=txt.value.replace(/(\d)\-rpm([\s:;,\.?!][^\d\(\)\/\\][^\d\(\)\/\\])/gi, '$1 rpm$2');
// decibel
txt.value=txt.value.replace(/(\d)\s?(dB)\b/g, '$1 $2');
// bits per second
txt.value=txt.value.replace(/(\d\s?[KkMmGgTt])(bps|bits?\/s|b\/s)/g, '$1bit/s');
txt.value=txt.value.replace(/(\d)\s?bps/gi, '$1 bit/s');
txt.value=txt.value.replace(/(\d) bps/gi, '$1 bit/s');
txt.value=txt.value.replace(/bits?\/sec([\s:;,\.?!][^\d\(\)\/\\][^\d\(\)\/\\])/gi, 'bit/s$1');
// bytes per second
txt.value=txt.value.replace(/([KkMmGgTt])(Bps|bytes?\/s)/g, ' $1byte/s');
txt.value=txt.value.replace(/bytes?\/s([\s:;,\.?!][^\d\(\)\/\\][^\d\(\)\/\\])/gi, 'byte/s$1');
// capitalization of prefix with bits and bytes
txt.value=txt.value.replace(/K(bit|B|byte)\/s/g, 'k$1/s');
txt.value=txt.value.replace(/m(bit|B|byte)\/s/g, 'M$1/s');
txt.value=txt.value.replace(/g(bit|B|byte)\/s/g, 'G$1/s');
txt.value=txt.value.replace(/t(bit|B|byte)\/s/g, 'T$1/s');
// space with bits and bytes
txt.value=txt.value.replace(/([^\w]\d)\s?(k|M|G|T)(bit|B)/g, '$1 $2$3');
//change format of convert template variables
txt.value=txt.value.replace(/({convert\|[^}]{1,16}km):h/g, '$1/h');
txt.value=txt.value.replace(/({convert\|[^}]{1,16}mi):h/g, '$1/h');
txt.value=txt.value.replace(/({convert\|[^}]{1,16}ft):s/g, '$1/s');
txt.value=txt.value.replace(/({convert\|[^}]{1,16}m):s/g, '$1/s');
//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\}\}');
//remove commas from numerical values in convert template
txt.value=txt.value.replace(/({convert\|\d{1,16}),(\d)/g, '$1$2');
txt.value=txt.value.replace(/({convert\|\d{1,16}),(\d)/g, '$1$2');
txt.value=txt.value.replace(/({convert\|\d{1,16}),(\d)/g, '$1$2');
txt.value=txt.value.replace(/({convert\|\d{1,16}),(\d)/g, '$1$2');
txt.value=txt.value.replace(/({convert\|\d{1,16}),(\d)/g, '$1$2');
//remove leading zeros from convert template
txt.value=txt.value.replace(/({convert\|)0(\d)/g, '$1$2');
txt.value=txt.value.replace(/({convert\|)0(\d)/g, '$1$2');
txt.value=txt.value.replace(/({convert\|)0(\d)/g, '$1$2');
//Remove surprise or 'Easter egg' diversions linking unit name to orders of magnitude articles
txt.value=txt.value.replace(/\[\[1\s?_?E\s?[\-\+]?\d{1,2}\s?..?\|([^\]]{1,50})\]\]/gi, '$1');
txt.value=txt.value.replace(/\[\[Orders\sof\smagnitude\s\([^\)]{1,30}\)\|([^\]]{1,50})\]\]/gi, '$1');
//'present'
txt.value=txt.value.replace(/\[\[Present \(time\)\|(Present)\]\]/gi, '$1');
txt.value=txt.value.replace(/\[\[(Present)\]\]/gi, '$1');
//Season
txt.value=txt.value.replace(/\[\[(spring\s\(season\)|summer|winter|autumn)\]\]/gi, '$1');
txt.value=txt.value.replace(/\[\[spring\s\(season\)\|(spring)\]\]/gi, '$1');
//Identify surprise or 'Easter egg' diversions linking months to year articles.
txt.value=txt.value.replace(/\[\[\d{1,4}#[^\|]{1,30}\|(January|February|March|April|May|June|July|August|September|October|November|December)\]\]/gi, '$1');
// months
txt.value=txt.value.replace(/\[\[\s?(January|February|March|April|May|June|July|August|September|October|November|December)\s?\]\]/gi, '$1');
txt.value=txt.value.replace(/\[\[(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\]\]/gi, '$1');
txt.value=txt.value.replace(/\[\[(?:January|February|March|April|May|June|July|August|September|October|November|December)\|(January|February|March|April|May|June|July|August|September|October|November|December)\]\]/gi, '$1');
//Treat 'Sept' (i.e. month abbreviation) differently from 'sept' (i.e. family)
txt.value=txt.value.replace(/\[\[(Sept)\]\]/g, '$1');
txt.value=txt.value.replace(/\[\[January\|(Jan)\]\]/gi, '$1');
txt.value=txt.value.replace(/\[\[February\|(Feb)\]\]/gi, '$1');
txt.value=txt.value.replace(/\[\[March\|(Mar)\]\]/gi, '$1');
txt.value=txt.value.replace(/\[\[April\|(Apr)\]\]/gi, '$1');
txt.value=txt.value.replace(/\[\[May\|(May)\]\]/gi, '$1');
txt.value=txt.value.replace(/\[\[June\|(Jun)\]\]/gi, '$1');
txt.value=txt.value.replace(/\[\[July\|(Jul)\]\]/gi, '$1');
txt.value=txt.value.replace(/\[\[August\|(Aug)\]\]/gi, '$1');
txt.value=txt.value.replace(/\[\[September\|(Sep)\]\]/gi, '$1');
txt.value=txt.value.replace(/\[\[October\|(Oct)\]\]/gi, '$1');
txt.value=txt.value.replace(/\[\[November\|(Nov)\]\]/gi, '$1');
txt.value=txt.value.replace(/\[\[December\|(Dec)\]\]/gi, '$1');
//month piped to number
txt.value=txt.value.replace(/\[\[(?:January|February|March|April|May|June|July|August|September|October|November|December)\|(\d{1,4})\]\]/gi, '$1');
//Month+day_number "March 7th" -> "March 7"
txt.value=txt.value.replace(/\[\[(January|February|March|April|May|June|July|August|September|October|November|December) (\d?\d)(?:th|st|nd|rd)\]\]/gi, '\[\[$1 $2\]\]');
txt.value=txt.value.replace(/\[\[((?:January|February|March|April|May|June|July|August|September|October|November|December) \d?\d)\]\](?:th|st|nd|rd)/gi, '\[\[$1\]\]');
txt.value=txt.value.replace(/\[\[(\d?\d)(?:th|st|nd|rd) (January|February|March|April|May|June|July|August|September|October|November|December)\]\]/gi, '\[\[$1 $2\]\]');
//Month+day_number piped into number. Preferences do not work. They don't work in sequence because digits in the two dates must be adjacent
txt.value=txt.value.replace(/([^\[]{4})\[\[((?: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{1,2}\|(\d{1,2})\]\]/gi, '$1$2$3$4');
//same again but with ndash or mdash instead of hyphen
txt.value=txt.value.replace(/([^\[]{4})\[\[((?:January|February|March|April|May|June|July|August|September|October|November|December) \d?\d)\]\](\s?&[nm]dash;\s?)\[\[(?:January|February|March|April|May|June|July|August|September|October|November|December) \d{1,2}\|(\d{1,2})\]\]/gi, '$1$2$3$4');
//same again but with slash instead of hyphen
txt.value=txt.value.replace(/([^\[]{4})\[\[((?:January|February|March|April|May|June|July|August|September|October|November|December) \d?\d)\]\](\/)\[\[(?:January|February|March|April|May|June|July|August|September|October|November|December) \d{1,2}\|(\d{1,2})\]\]/gi, '$1$2$3$4');
txt.value=txt.value.replace(/([^\[]{4})\[\[((?:January|February|March|April|May|June|July|August|September|October|November|December) \d?\d)\]\](\s?\-?\s?)\[\[(\d{1,2})\]\]/gi, '$1$2$3$4');
//same again but with ndash instead of hyphen
txt.value=txt.value.replace(/([^\[]{4})\[\[((?:January|February|March|April|May|June|July|August|September|October|November|December) \d?\d)\]\](\s?&[nm]dash;\s?)\[\[(\d{1,2})\]\]/gi, '$1$2$3$4');
//same again but with slash instead of hyphen
txt.value=txt.value.replace(/([^\[]{4})\[\[((?:January|February|March|April|May|June|July|August|September|October|November|December) \d?\d)\]\](\/)\[\[(\d{1,2})\]\]/gi, '$1$2$3$4');
txt.value=txt.value.replace(/([^\[]{4})\[\[(\d?\d) (?:January|February|March|April|May|June|July|August|September|October|November|December)\]\](\s?\-?\s?)\[\[(?:January|February|March|April|May|June|July|August|September|October|November|December) \d{1,2}\|(\d{1,2})\]\]/gi, '$1$2$3$4');
//same again but with ndash instead of hyphen
txt.value=txt.value.replace(/([^\[]{4})\[\[(\d?\d) (?:January|February|March|April|May|June|July|August|September|October|November|December)\]\](\s?&[nm]dash;\s?)\[\[(?:January|February|March|April|May|June|July|August|September|October|November|December) \d{1,2}\|(\d{1,2})\]\]/gi, '$1$2$3$4');
//same again but with slash instead of hyphen
txt.value=txt.value.replace(/([^\[]{4})\[\[(\d?\d) (?:January|February|March|April|May|June|July|August|September|October|November|December)\]\](\/)\[\[(?:January|February|March|April|May|June|July|August|September|October|November|December) \d{1,2}\|(\d{1,2})\]\]/gi, '$1$2$3$4');
txt.value=txt.value.replace(/([^\[]{4})\[\[(\d?\d) (?:January|February|March|April|May|June|July|August|September|October|November|December)\]\](\s?\-?\s?)\[\[(\d{1,2})\]\]/gi, '$1$2$3$4');
//same again but with ndash instead of hyphen
txt.value=txt.value.replace(/([^\[]{4})\[\[(\d?\d) (?:January|February|March|April|May|June|July|August|September|October|November|December)\]\](\s?&[nm]dash;\s?)\[\[(\d{1,2})\]\]/gi, '$1$2$3$4');
//same again but with slash instead of hyphen
txt.value=txt.value.replace(/([^\[]{4})\[\[(\d?\d) (?:January|February|March|April|May|June|July|August|September|October|November|December)\]\](\/)\[\[(\d{1,2})\]\]/gi, '$1$2$3$4');
txt.value=txt.value.replace(/\[\[(?:January|February|March|April|May|June|July|August|September|October|November|December) \d{1,2}\|(\d{1,2})\]\]/gi, '$1');
txt.value=txt.value.replace(/\[\[\d{1,2} (?:January|February|March|April|May|June|July|August|September|October|November|December)\|(\d{1,2})\]\]/gi, '$1');
txt.value=txt.value.replace(/\[\[(?:January|February|March|April|May|June|July|August|September|October|November|December)\s\d{1,2}\|((?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s\d{1,2})\]\]/gi, '$1');
//month+day piped into month+day or vice versa
txt.value=txt.value.replace(/\[\[\d{1,2}\s(?:January|February|March|April|May|June|July|August|September|October|November|December)\|((?:January|February|March|April|May|June|July|August|September|October|November|December)\s\d{1,2})\]\]/gi, '$1');
txt.value=txt.value.replace(/\[\[(?:January|February|March|April|May|June|July|August|September|October|November|December)\s\d{1,2}\|(\d{1,2}\s(?:January|February|March|April|May|June|July|August|September|October|November|December))\]\]/gi, '$1');
// days of the week in full. Optional plurals
txt.value=txt.value.replace(/\[\[(Mondays?|Tuesdays?|Wednesdays?|Thursdays?|Fridays?|Saturdays?|Sundays?)\]\]/gi, '$1');
// days of the week abbreviated. Leave out 'Sun' as potentially valid link to the Sun. Leave out 'SAT' in upper case as potential link to 'Scholastic achievement/aptitude test'.
txt.value=txt.value.replace(/\[\[(Mon|Tue|Tues|Wed|Thu|Thur|Thurs|Fri)\]\]/gi, '$1');
txt.value=txt.value.replace(/\[\[(Sat)\]\]/g, '$1');
txt.value=txt.value.replace(/\[\[Mondays?\|(Mondays?|Mon)\]\]/gi, '$1');
txt.value=txt.value.replace(/\[\[Tuesdays?\|(Tuesdays?|Tues?)\]\]/gi, '$1');
txt.value=txt.value.replace(/\[\[Wednesdays?\|(Wednesdays?|Wed)\]\]/gi, '$1');
txt.value=txt.value.replace(/\[\[Thursdays?\|(Thursdays?|Thur?)\]\]/gi, '$1');
txt.value=txt.value.replace(/\[\[Fridays?\|(Fridays?|Fri)\]\]/gi, '$1');
txt.value=txt.value.replace(/\[\[Saturdays?\|(Saturdays?|Sat)\]\]/gi, '$1');
txt.value=txt.value.replace(/\[\[Sundays?\|(Sundays?|Sun)\]\]/gi, '$1');
//4 digit years piped into 2
txt.value=txt.value.replace(/\[\[\d{1,4}\|(\d{1,2})\]\]/gi, '$1');
}
function run_dates() {
var txt = document.editform.wpTextbox1;
dates();
// Add a tag to the summary box
var txt = document.editform.wpSummary;
var summary = "[[User:Lightmouse/monobook.js|Script]] assisted. Units/dates/other";
if (txt.value.indexOf(summary) == -1) {
if (txt.value.match(/[^\*\/\s][^\/\s]?\s*$/)) {
txt.value += " | ";
}
txt.value += summary;
}
// Press the diff button to check it
document.editform.wpDiff.click()
}
$(function () {
if(document.forms.editform) {
addLink('p-cactions', 'javascript:run_dates()', 'dates', 'ca-unitfixer', 'Fixes some unit formatting', '', '');
}
});
function run_formatgeneral() {
var txt = document.editform.wpTextbox1;
formatgeneral();
// Add a tag to the summary box
var txt = document.editform.wpSummary;
var summary = "[[User:Lightmouse/monobook.js|Script]] assisted. Units/dates/other";
if (txt.value.indexOf(summary) == -1) {
if (txt.value.match(/[^\*\/\s][^\/\s]?\s*$/)) {
txt.value += " | ";
}
txt.value += summary;
}
// Press the diff button to check it
document.editform.wpDiff.click()
}
$(function () {
if(document.forms.editform) {
addLink('p-cactions', 'javascript:run_formatgeneral()', 'general', 'ca-unitfixer', 'Fixes some unit formatting', '', '');
}
});
function combined() {
var txt = document.editform.wpTextbox1;
formatgeneral();
dates();
// Add a tag to the summary box
var txt = document.editform.wpSummary;
var summary = "[[User:Lightmouse/monobook.js|Script]] assisted. Units/dates/other";
if (txt.value.indexOf(summary) == -1) {
if (txt.value.match(/[^\*\/\s][^\/\s]?\s*$/)) {
txt.value += " | ";
}
txt.value += summary;
}
// Press the diff button to check it
document.editform.wpDiff.click()
}
$(function () {
if(document.forms.editform) {
addLink('p-cactions', 'javascript:combined()', 'combined', 'ca-unitfixer', 'Fixes some unit formatting', '', '');
}
});