// Feedback and constructive criticism are welcome
// <pre>
$.when(
$.ajax("//tools-static.wmflabs.org/meta/scripts/pathoschild.templatescript.js", { dataType: "script", cache: true }),
$.ajax("//en.wikipedia.org/w/index.php?title=User:Ohconfucius/script/MOSNUM_utils.js&action=raw&ctype=text/javascript", { dataType: "script", cache: true })
).then(function() {
pathoschild.TemplateScript.add(
[
{
name: "DATES to dmy",
tooltip: "Align all dates to dmy",
script: ohc_all_to_dmy_driver
},
{
name: "DATES to mdy",
tooltip: "Align all dates to mdy",
script: ohc_all_to_mdy_driver
},
{
name: "DMY_cs1=ly",
tooltip: "Access & archive dates",
script: ohc_dmy_cs1_ly_driver
},
{
name: "MDY_cs1=ly",
tooltip: "say hello",
script: ohc_mdy_cs1_ly_driver
},
{
name: "US-slash dates",
tooltip: "US-slash",
script: ohc_US_slash_dates_driver
},
{
name: "UK-slash dates",
tooltip: "UK-slash",
script: ohc_UK_slash_dates_driver
}
],
// common options
{ forActions: "edit", category: "MOSNUM Dates" }
);
});
/**
* TemplateScriptAdd addscustom configurableextension templates and scriptsmethods to the sidebar, and adds an example regexTemplateScript editor.
* @seeparam editor The https://meta.wikimedia.org/wiki/TemplateScript editor to extend.
*/
function ohc_extend_editor(editor) {
// <pre>
editor.ohc_regex = function(rg, sub, func) {
if ($.inArray(mw.config.get('wgAction'), ['edit', 'submit']) !== -1) {
var text = editor.get();
$.ajax(
text = ohc.dateutil.regex(text, rg, sub, func);
'//tools-static.wmflabs.org/meta/scripts/pathoschild.templatescript.js',
editor.set(text);
{dataType: 'script', cache: true}
).done(function () {
$.when(
mw.loader.using(['mediawiki.util']),
$.ajax('//en.wikipedia.org/w/index.php?title=User:Ohconfucius/script/MOSNUM_utils.js&action=raw&ctype=text/javascript',
{dataType: 'script', cache: true}),
$.ready
).done(function () {
var add = function() {
return mw.util.addPortletLink.apply(mw.util, arguments);
};
return editor;
$(add('p-tb', '#', 'DATES to dmy', 'dmy-unitfixer', 'Align all dates to dmy', '', '')).click(ohc_all_to_dmy_driver);
};
$(add('p-tb', '#', 'DATES to mdy', 'mdy-unitfixer', 'Align all dates to mdy', '', '')).click(ohc_all_to_mdy_driver);
// $(add('p-tb', '#', 'Expand ref dates', 't-expandref', 'Expand month names within refs', '', '')).click(ohc_expand_ref_dates_driver);
// $(add('p-tb', '#', 'Expand all dates', 't-expandall', 'Expand month names throughout', '', '')).click(ohc_expand_all_dates_driver);
$( add('p-tb', '#', 'US-slash dates', 't-US', 'US-slash', '', '') ).click(ohc_US_slash_dates_driver);
$( add('p-tb', '#', 'UK-slash dates', 't-UK', 'UK-slash', '', '') ).click(ohc_UK_slash_dates_driver);
});
});
}
function ohc_fix_unambiguous_dates(editor) {
editor
{
// resolvable ambiguous date formats
// UK style
.ohc_regex(/([^-\w/:\.])@DD\.@MM\.@YYYY(?=[^-–/\w&])/gi, "$1@Day @Month @YYYY", function(d) {
if (d.d == d.m) return true;
if (d.d > 12) return true;
return false;
});
.ohc_regex(/([^-\w/:\.])@DD\/@MM\/@YYYY(?=[^-–/\w&])/gi, "$1@Day @Month @YYYY", function(d) {
if (d.d == d.m) return true;
if (d.d > 12) return true;
return false;
});
// US style
.ohc_regex(/([^-\w/:\.])@MM\.@DD\.@YYYY(?=[^-–/\w&])/gi, "$1@Month @Day, @YYYY", function(d) {
if (d.d > 12) return true;
return false;
});
.ohc_regex(/([^-\w/:\.])@MM\/@DD\/@YYYY(?=[^-–/\w&])/gi, "$1@Month @Day, @YYYY", function(d) {
if (d.d > 12) return true;
return false;
});
}
function ohc_US_slash_dates_to_mdy(editor) {
editor
{
// ranges
.ohc_regex(/([^-\d/:\.])@MM\/@DD\/@YYNN( |\s)?(?:(?:[-–—]|&[mn]dash;)(?: |\s)?)@MM\/@DD\/@YYNN(?=[^-–/\w&])/gi, "$1@Mon1 @Day1, @Year1$2 – @Mon2 @Day2, @Year2");
.ohc_regex(/([^-\d/:\.])@MM\.@DD\.@YYNN( |\s)?(?:(?:[-–—]|&[mn]dash;)(?: |\s)?)@MM\.@DD\.@YYNN(?=[^-–/\w&])/gi, "$1@Mon1 @Day1, @Year1$2 – @Mon2 @Day2, @Year2");
.ohc_regex(/(\| ?)@MM\/@DD\/@YYNN( |\s)?(?:(?:[-–—]|&[mn]dash;)(?: |\s)?)@MM\/@DD\/@YYNN(?=\s*\|)/gi, "$1@Mon1 @Day1, @Year1$2 – @Mon2 @Day2, @Year2");
.ohc_regex(/(\| ?)@MM\.@DD\.@YYNN( |\s)?(?:(?:[-–—]|&[mn]dash;)(?: |\s)?)@MM\.@DD\.@YYNN(?=\s*\|)/gi, "$1@Mon1 @Day1, @Year1$2 – @Mon @Day2, @Year2");
// resolvable ambiguous date formats
.ohc_regex(/([^-\d/:\.])@MM\/@DD\/@YYNN(?=[^-–/\w&])/gi, '"$1@Month @Day, @YYYY'");
.ohc_regex(/([^-\d/:\.])@MM\.@DD\.@YYNN(?=[^-–/\w&])/gi, '"$1@Month @Day, @YYYY'");
.ohc_regex(/([^-\d/:\.])@MM[-–]@DD[-–]@YYNN(?=[^-–/\w&])/gi, '"$1@Month @Day, @YYYY'");
.ohc_regex(/(\| ?)@MM\/@DD\/@YYNN(?=\s*\|)/gi, '"$1@Month @Day, @YYYY'");
.ohc_regex(/(\| ?)@MM\.@DD\.@YYNN(?=\s*\|)/gi, '"$1@Month @Day, @YYYY'");
// .ohc_regex(/(\| ?)@MM[-–]@DD[-–]@YYNN(?=\s*\|)/gi, '"$1@Month @Day, @YYYY'");
}
function ohc_UK_slash_dates_to_dmy()
{
//ranges
ohc_regex(/([^-\d/:\.])@DD\/@MM\/@YYNN( |\s)?(?:(?:[-–—]|&[mn]dash;)(?: |\s)?)@DD\/@MM\/@YYNN(?=[^-–/\w&])/gi, "$1@Day1 @Mon1 @Year1$2 – @Day2 @Mon2 @Year2");
ohc_regex(/([^-\d/:\.])@DD\.@MM\.@YYNN( |\s)?(?:(?:[-–—]|&[mn]dash;)(?: |\s)?)@DD\.@MM\.@YYNN(?=[^-–/\w&])/gi, "$1@Day1 @Mon1 @Year1$2 – @Day2 @Mon2 @Year2");
ohc_regex(/(\| ?)@DD\/@MM\/@YYNN( |\s)?(?:(?:[-–—]|&[mn]dash;)(?: |\s)?)@DD\/@MM\/@YYNN(?=\s*\|)/gi, "$1@Day1 @Mon1 @Year1$2 – @Day2 @Mon2 @Year2");
ohc_regex(/(\| ?)@DD\.@MM\.@YYNN( |\s)?(?:(?:[-–—]|&[mn]dash;)(?: |\s)?)@DD\.@MM\.@YYNN(?=\s*\|)/gi, "$1@Day1 @Mon1 @Year1$2 – @Day2 @Mon2 @Year2");
function ohc_UK_slash_dates_to_dmy(editor) {
// resolvable ambiguous date formats
editor
ohc_regex(/([^-\d/:\.])@DD\/@MM\/@YYNN(?=[^-–/\w&])/gi, '$1@Day @Month @YYYY');
// ranges
ohc_regex(/([^-\d/:\.])@DD\.@MM\.@YYNN(?=[^-–/\w&])/gi, '$1@Day @Month @YYYY');
.ohc_regex(/([^-\d/:\.])@DD[-–]\/@MM\/@YYNN( |\s)?(?:(?:[-––—]|&[mn]dash;)(?: |\s)?)@DD\/@MM\/@YYNN(?=[^-–/\w&])/gi, '"$1@DayDay1 @MonthMon1 @YYYY'Year1$2 – @Day2 @Mon2 @Year2");
.ohc_regex(/([^-\d/:\.])@DD\.@MM\.@YYNN( | \s)?(?:(?:[-–—]|&[mn]dash;)(?: |\s)?)@DD\/.@MM\/.@YYNN(?=[^-–/\s*\|w&])/gi, '"$1@DayDay1 @MonthMon1 @YYYY'Year1$2 – @Day2 @Mon2 @Year2");
.ohc_regex(/(\| ?)@DD\./@MM\./@YYNN( |\s)?(?:(?:[-–—]|&[mn]dash;)(?: |\s)?)@DD\/@MM\/@YYNN(?=\s*\|)/gi, '"$1@DayDay1 @MonthMon1 @YYYY'Year1$2 – @Day2 @Mon2 @Year2");
// .ohc_regex(/(\| ?)@DD[-–]\.@MM\.@YYNN( |\s)?(?:(?:[-––—]|&[mn]dash;)(?: |\s)?)@DD\.@MM\.@YYNN(?=\s*\|)/gi, '"$1@DayDay1 @MonthMon1 @YYYY'Year1$2 – @Day2 @Mon2 @Year2");
// resolvable ambiguous date formats
.ohc_regex(/([^-\d/:\.])@DD\/@MM\/@YYNN(?=[^-–/\w&])/gi, "$1@Day @Month @YYYY")
.ohc_regex(/([^-\d/:\.])@DD\.@MM\.@YYNN(?=[^-–/\w&])/gi, "$1@Day @Month @YYYY")
.ohc_regex(/([^-\d/:\.])@DD[-–]@MM[-–]@YYNN(?=[^-–/\w&])/gi, "$1@Day @Month @YYYY")
.ohc_regex(/(\| ?)@DD\/@MM\/@YYNN(?=\s*\|)/gi, "$1@Day @Month @YYYY")
.ohc_regex(/(\| ?)@DD\.@MM\.@YYNN(?=\s*\|)/gi, "$1@Day @Month @YYYY");
//.ohc_regex(/(\| ?)@DD[-–]@MM[-–]@YYNN(?=\s*\|)/gi, "$1@Day @Month @YYYY");
}
function ohc_remove_leading_zeroes(editor) {
editor
{
.ohc_regex(/(\D[^\w\/])@Month\s@ZD@th?,?\s@YYYY(?=\W\D)/gi, "$1@LMonth @Day, @LYear");
.ohc_regex(/(\D[^\w\/])@Month\s@ZD@th?(?=\W\D)/gi, "$1@LMonth @Day");
.ohc_regex(/(\D[^\w\/])@ZD@th?\s@Month\s@YYYY(?=\W\D)/gi, "$1@Day @LMonth @LYear");
.ohc_regex(/(\D[^\w\/])@ZD@th?\s@Month(?=\W\D)/gi, "$1@Day @LMonth");
}
function ohc_delink_dates(editor) {
editor
{
// add missing space between wikilinks
regex .replace(/(\]\])(\[\[)(?!file:)/gi, '"$1 $2'"); // remove (?!file:) to ensure a space between all links
// rem redundant quote marks and parentheses
regex(/(\|\s*(?:publication|archive|access|air|)-?date\s*=\s*)\'\'\'([^|}\[\]]*)\'\'\'(?=\s*[|}])/gi, "$1$2");
regex(/(\|\s*(?:publication|archive|access|air|)-?date\s*=\s*)\'\'([^|}\[\]]*)\'\'(?=\s*[|}])/gi, "$1$2");
regex(/(\|\s*(?:publication|archive|access|air|)-?date\s*=\s*)\"([^|}\[\]]*)\"(?=\s*[|}])/gi, "$1$2");
regex(/(\|\s*(?:publication|archive|access|air|)-?date\s*=\s*)\(([^|}\[\]]*)\)(?=\s*[|}])/gi, "$1$2");
// rem redundant quote marks and parentheses
//rem linking date parameters
regex .replace(/(\|\s*(?:publication|archive|access|air|)-?date\s*=\s*)\['\['\'([^|}\[\]]+?*)\]'\]'\'(?=\s*[|}])/gi, '"$1$2'");
regex .replace(/(\|\s*(?:publication|archive|access|air|)-?date\s*=\s*)\['\['([^|}\]]+?\|([^\]]+?*)\]'\]'(?=\s*[|}])/gi, '"$1$2'");
regex .replace(/(\|\s*(?:publication|archive|access|air|)-?date\s*=\s*)\[\["(?:[^|}\]]+?\||)([^\]]+?)\]\]([^|\[]*)\[\[(?:[^|\]]+?\||)([^\]]+?)\]\](?:([^|\[]*)\[\[(?:[^|\]]+?\||)([^\]]+?)\]\]|)"(?=\s*[|}])/gi, '"$1$2$3$4$5$6'");
.replace(/(\|\s*(?:publication|archive|access|air|)-?date\s*=\s*)\(([^|}\[\]]*)\)(?=\s*[|}])/gi, "$1$2")
//underscore anddelink nbsp in linkedunpiped dates
// delink full dates
ohc_regex(/\[\[@DD@th?(?:\s|_| )@Month\]\]/gi, "@Day @LMonth");
.ohc_regex(/\[\[@Day[\s_](?:of[\s_])?@Month(?:\]\]\s?\[\[\|_| )@DD@th?YYYY\]\]@th?/gi, "@Day @LMonth @DayYYYY"); //consolidated regex with flexible removal of ordinal simple date
.ohc_regex(/\[\[@Month (?:the\s)?@Day(?:\]\],? \[\[|, )@MonthYYYY\]\]/gi, "@LMonth @Day, @MonthYYYY");
ohc_regex(/\[\[@Month @YYYY\]\]/gi, "@Month @YYYY");
ohc_regex(/\[\[@YYYY\]\]/gi, "@YYYY");
// delink yyyy-mm-dd dates
//remove leading zero and links from linked date
.ohc_regex(/\[\[@MonthYYYY(?:[ _\]\]-\[\[| -)@ZDMM-@thDD\]\]/gi, "@LMonth YYYY-@MM-@DayDD");
.ohc_regex(/@YYYY-\[\[@ZDMM-@th(?:[ _]| )@MonthDD\]\]/gi, "@Day YYYY-@MM-@LMonthDD");
//delink piped md|dm, md|dd and my|m dates
ohc_regex(/\[\[@month @dd(?:#[^|]+|)\|([^|\]]+)\]\]/gi, "$1");
ohc_regex(/\[\[@dd @month(?:#[^|]+|)\|([^|\]]+)\]\]/gi, "$1");
ohc_regex(/\[\[@month @yyyy(?:#[^|]+|)\|([^|\]]+)\]\]/gi, "$1");
// removeunderscore nowrapand templatenbsp from dm andin mdlinked dates
.ohc_regex(/(date\[ ]*=\[ ]*)\{\{(?:j|no @DD@th?(?:break|wrap))\s|(?:@DD(?:[ _]| )@Month)( @yyyy|)\}]\}]/gi, '$1"@DDDay @Month$2'LMonth");
.ohc_regex(/(date\[ ]*=\[ ]*)\{\{@Month(?:j|no ?(?:break|wrap))\s|(?:@Month(?:[ _]| )@DD)( @yyyy|)th?\}]\}]@th?/gi, '$1"@MonthLMonth @DD$2'Day"); //consolidated regex with flexible removal of ordinal simple date
.ohc_regex(/\[\[@Day @Month\]\]/gi, "@Day @LMonth")
.ohc_regex(/\[\[@Month @YYYY\]\]/gi, "@LMonth @YYYY")
//delink yyyy-mm-dd dates
.ohc_regex(/\[\[@YYYY(?:\]\]-\[\[|-)@MM-@DD\]\]/gi, "@YYYY-@MM-@DD");
ohc_regex(/@YYYY-\[\[@MM-@DD\]\]/gi, "@YYYY-@MM-@DD");
// remove leading zero and links from linked date
//delink dates from automated templates
regex .ohc_regex(/\[\[@Month(\{\{CURRENTDAY\}\}?:[ \{\{CURRENTMONTHNAME\}\}_]| )@ZD@th\]\]/gi, "$1@LMonth @Day");
regex .ohc_regex(/\[\[@ZD@th(\{\{CURRENTYEAR\}\}?:[ _]| )@Month\]\]/gi, "$1@Day @LMonth");
// remove nowrap template from dm and md dates
//delink full dates
.ohc_regex(/\(date[\ ]*=[@Day[\s_ ]*)\{\{(?:of[\s_])j|no ?@Month(?:break|wrap))\]\]\s|(?\:@DD(?:[\[\| _]| )@YYYYMonth)( @yyyy|)\]}\]}/gi, "$1@DayDD @LMonth @YYYY$2");
.ohc_regex(/\(date[\ ]*=[@Month ]*)\{\{(?:the\s)j|no ?@Day(?:break|wrap))\]\],|(? \[\:@Month(?:[ _]|, )@YYYYDD)( @yyyy|)\]}\]}/gi, "$1@LMonth @Day, @YYYYDD$2");
// delink single dm or 'dth the m'
.ohc_regex(/(?:the\s)?\[\[@Day@th?[\s_](?:of[\s_])?@Month\]\]/gi, "@Day @LMonth");
//delink single md or 'm the dth'
ohc_regex(/\[\[@Month[\s_](?:the[\s_])?@Day\]\](?=\W)/gi, "@LMonth @Day");
// delink single md or 'm the dth'
//Month+day_number "[[March 7]]th" -> "March 7"
.ohc_regex(/\[\[@Month[\s@DD\s_](?:the[\s_])?@Day@th?\]\](?=\W)/gi, "@LMonth @Day");
// month+day+year pseudo-ISO datespiped
.ohc_regex(/(\|[\s*[(?:publication|archive|access|air|)-@dd@th?date[\s*=s_](?:of[\s*s_])?@month|@month[\s_]@dd@th?)-\|((?:@Mon-month |)@YYYYday)@th?\]\]/gi, "$1 @FullMonth @YYYY");
.ohc_regex(/(\|[\s*[(?:publication|archive|access|air|)-@dd@th?date[\s*=s_](?:of[\s*s_])?@YYYY-month|@DD-month[\s_]@Mondd@th?)\|@Day@th?[\s_](@month|)\]\]/gi, "$1 @DDDay @FullMonth @YYYY$1");
//.ohc_regex(/\[\[@month @dd(?:#[^|]+|)\|([^|\]]+)@th?\]\]/gi, "$1")
//.ohc_regex(/\[\[@dd @month(?:#[^|]+|)\|([^|\]]+)@th?\]\]/gi, "$1")
.ohc_regex(/\[\[@month @yyyy(?:#[^|]+|)\|([^|\]]+)\]\]/gi, "$1")
// month+day+year pseudo-ISO dates
ohc_regex(/\[\[@Month @DD\|\d\d-\d\d\]\]-(?:\[\[)?(?:@yyyy[^|]*\|)?@YYYY(?:\]\])/gi, "@Day @Month @YYYY");
.ohc_regex(/\[\[@DD\s@Month @DD\|\d\d-\d\d\]\]-(?:\[\[)?(?:@yyyy[^|]*\|)?@YYYY(?:\]\])/gi, "@Day @MonthLMonth @YYYY");
.ohc_regex(/\[\[@DD\s@Month\|\d\d-\d\d\]\]-(?:\[\[)?(?:@yyyy[^|]*\|)?@YYYY(?:\]\])/gi, "@Day @LMonth @YYYY")
//'[[month+ day|xxXxx]]Xyyyy ' to 'month day, pipedyear'
.ohc_regex(/(?:the\s)?\[\[@day[Month\s_](?:of[\s_])?s@monthDay\|([^\]]{1,30})@dd.@dd\]\].@YYYY/gi, "$1@LMonth @Day, @YYYY");
//'[[day month day|xxXxx]]Xyyyy ' to 'day month day, year'
.ohc_regex(/\[\[@MonthDay\s@DayMonth\|@dd.@dd\]\].@YYYY/gi, "@LMonthDay @Day,LMonth @YYYY");
//'[[day month|xxXxx]]Xyyyy' to 'day month year'
ohc_regex(/\[\[@Day\s@Month\|@dd.@dd\]\].@YYYY/gi, "@Day @LMonth @YYYY");
// century
regex .replace(/\[\[((?:first|second|third|(?:(?:thir|four|fif|six|seven|eigh|nin|ten|eleven|twelf|thirteen|fourteen|fifteen|sixteen|seventeen|eighteen|nineteennine)teen|twentie)th|twenty[\s\-]first[\s\-])centur(?:y|ies)(?:\s(?:AD|BC|CE|BCE))?)\]\]/gi, '"$1'");
regex .replace(/\[\[(?:first|second|third|(?:(?:thir|four|fif|six|seven|eigh|nin|ten|eleven|twelf|thirteen|fourteen|fifteen|sixteen|seventeen|eighteen|nineteennine)teen|twentie)th|twenty[\s\-]first)[\s\-_]centur(?:y|ies)(?:\s(?:AD|BC|CE|BCE))?\|([^\]]{1,30})\]\]/gi, '"$1'");
regex .replace(/\[\[(\d{1,2}(?:st|[nr]d|th))[\s\-_])(centur(?:y|ies))(\s(?:AD|BC|CE|BCE)|)\]\]/gi, '"$1 $2$3'");
regex .ohc_regex(/\[\[\d{1,2}(?:st|[nr]d|@th)[\s\-_]centur(?:y|ies)(?:\s(?:AD|BC|CE|BCE)|)\|([^\]]{1,30})\]\]/gi, '"$1'");
// months
.ohc_regex(/\[\[@Month\]\]/gi, "@MonthLMonth");
.ohc_regex(/\[\[@FullMonth\|([^\]]{1,30})\]\]/gi, "$1");
// decades and years
regex .replace(/(\d{1,3}0)[‘`´’′]?s/g, '"$1s'");
regex .replace(/\[\[(\d{1,3}0)\'?s\]\]/g, '"$1s'");
regex .replace(/\[\[\d{1,3}0\'?s?\|([^\]]{1,30})\]\]/g, '"$1'");
regex// .replace(/\[\[(\d{12,3}0)\'?(s)?\s(AD|BC|CE|BCE)\]\]/gi, '"$1$2 $3'");
regex// .replace(/\[\[(\d{1,4}[\s_]?)(AD|BC|CE|BCE)\]\]/gi, '"$1$2'");
regex .replace(/\[\[(AD|BC|CE|BCE)([\s_]?)(\d{1,4})\]\]/gi, '"$1$2$3'");
.ohc_regex(/([-–])\[\[\s?@yyyy\s?\|\s?(\d{2,4})\s?\]\]/gi, '"$1$2'"); // piped year
regex .replace(/\[\[([12]\d{3}|[1-9]\d{0,2})\]\]/gi, '"$1'");
regex .replace(/\[\[\d{1,3}0\'?s?\s(?:AD|BC|CE|BCE)\|([^\]]{1,30})\]\]/gi, '"$1'");
regex .replace(/\[\[\d{1,3}0\'?s?\s\(decade\)\|([^\]]{1,30})\]\]/gi, '"$1'");
// 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
.ohc_regex(/\[\[@yyyy in[^|\]]+\|@Day @Month @YYYY\]\]/gi, "@Day @MonthLMonth @YYYY");
.ohc_regex(/\[\[@yyyy in[^|\]]+\|@Month @Day,? @YYYY\]\]/gi, "@MonthLMonth @Day, @YYYY");
.ohc_regex(/\[\[@yyyy#[^|\]]+\|(@month\s|)(@yyyy)\]\]/gi, "$1$2");
.ohc_regex(/\[\[@yyyy#[^|\]]+\|(@month|@yyyy)\]\]/gi, "$1");
.ohc_regex(/\[\[(@month\s@yyyy)\]\]/gi, "$1");
.ohc_regex(/\[\[@month\s@yyyy\|([^\]]{1,30})\]\]/gi, "$1");
.ohc_regex(/\[\[(?:List of |)Bollywood films of @yyyy\|@YYYY\]\](?= [^\[]{2}^B)/gi, "@YYYY");
.ohc_regex(/(\[\[@yyyy[^|\]]+\|@yyyy)(\]\])( season)/gi, "$1$3$2");
ohc_regex(/@Month\s\[\[@yyyy[^|\]]+\|@YYYY\]\]/gi, "@LMonth @Year");
ohc_regex(/(\[\[The Who[^|\]]+\|@YYNN)(\]\])/gi, "@YYNN"); //The Who tours
// removed piped years when in full date (excepting disambiguated parentheses - updated 24/2/2012)
//.ohc_regex(/\[\[@DD\s@Month\]\],?\s?\[\[[^|\]\(\)]{1,32}\|@YearYYYY\]\]/gi, '@DD @LMonth "@Year'"); // 23/6/2021 – disabled delinking "other" year-in articles
ohc_regex(/\[\[@Month\s@DD\]\],?\s?\[\[[^|\]]{1,32}\|@Year\]\]/gi, '@LMonth @DD, @Year');
// Identify surprise or 'Easter egg' diversions linking months to year or "year in" articles.
.ohc_regex(/\[\[\d{1,4}#[^|\]]+\|@Month\]\]/gi, "@LMonth");
// .ohc_regex(/@DD\s@Month,?\s?\[\[@yyyy \w[^|\]]{3,12}\|@Year\]\]/gi, '@DD @LMonth "@Year'"); //disable easter egg removal per request 5 November 2022
ohc_regex(/@Month\s@DD,?\s?\[\[@yyyy \w[^|\]]{3,12}\|@Year\]\]/gi, '@LMonth @DD, @Year');
// month and day piped
.ohc_regex(/@YYYY-\[\[@month[\s_]@day\|@MM-@DD\]\]/gi, "@YYYY-@MM-@DD");
.ohc_regex(/\[\[@month[\s_]@day\|([^\]]{1,30})\]\]/gi, "$1");
.ohc_regex(/\[\[@day(?:\s|_|@th )(?:of[\s_]|)?@month\|([^\]]{1,30})\]\]/gi, "$1");
// years piped
regex .replace(/\[\[\d{1,4}\|([^\]]{1,30})\]\]/gi, '"$1'");
}
function ohc_fix_common_errors(editor) {
editor
{
.ohc_regex(/(\d)<sup>@th<\/sup>/gi, '"$1th'");
// remove dashbot comment from dates
regex(/<!-- ?DASHBot ?-->/gi, '');
ohc_regex(/(\|\s*(?:date|year)\s*=)\s*c(?:irca|a\.)?\s?((?:@day |)@month @year)(?=[\s\n]*[<|}])/gi, '$1c. $2'); //add space
//common cs1 errors
regex(/(\|\s*(?:date|year)\s*=)\s*(1[7-9]\d|20[0-1])\?(?=[\s\n]*[<|}])/gi, '$1c. $20');
regex(/(\|\s*(?:date|year)\s*=\s*(1[7-9])\d{2})[-–](\d{2})(?=[\s\n]*[<|}])/gi, '$1–$2$3');
// regex(/(\|\s*(?:date|year)\s*=\s*(20)[0-1]\d)[-–]([0-2]\d)(?=[\s\n]*[<|}])/gi, '$1–$2$3');
regex(/(\|\s*(?:date|year)\s*=\s*)@YYYY\s*[-–/]\s*@YYYY(?=[\s\n]*[<|}])/gi, '$1@YYYY1–@YYYY2'); //common cs1 error
regex(/(\|\s*(?:date)\s*=)\s*s(pring|ummer),?\s*((?:1[7-9]\d|20[0-1])\d)(?=[\s\n]*[<|}])/gi, '$1S$2 $3'); //common cs1 error
regex(/(\|\s*(?:date)\s*=)\s*a(utumn),?\s*((?:1[7-9]\d|20[0-1])\d)(?=[\s\n]*[<|}])/gi, '$1A$2 $3'); //common cs1 error
regex(/(\|\s*(?:date)\s*=)\s*f(all),?\s*((?:1[7-9]\d|20[0-1])\d)(?=[\s\n]*[<|}])/gi, '$1F$2 $3'); //common cs1 error
regex(/(\|\s*(?:date)\s*=)\s*w(inter),?\s*((?:1[7-9]\d|20[0-1])\d)(?=[\s\n]*[<|}])/gi, '$1W$2 $3'); //common cs1 error
ohc_regex(/(\|\s*access-?date\s*=)\s*(@month @year)(?=[\s\n]*[<|}])/gi, '$11 $2'); //common cs1 error
// ohc_regex(/(\|\s*date\s*=\s*)@year\?(?=[\s\n]*[<|}])/gi, '$1@Year'); //common cs1 error
// ohc_regex(/(\|\s*(?:date|year)\s*=)\s*@year\?(?=[\s\n]*[<|}])/gi, '$1c. @Year'); //common cs1 error
// ohc_regex(/(\|\s*(?:date|year)\s*=)\s*(@month @year)\?(?=[\s\n]*[<|}])/gi, '$1c. $2'); //common cs1 error
ohc_regex(/(\|\s*access-?date\s*=)\s*@month @day, (1[7-9]\d{2}|2000)(?=[\s\n]*[<|}])/gi, '$1'); //rem access date before Wikipedia (January 2001)
ohc_regex(/(\|\s*access-?date\s*=)\s*@day @month.? (1[7-9]\d{2}|2000)(?=[\s\n]*[<|}])/gi, '$1'); //rem access date before Wikipedia (January 2001)
ohc_regex(/(\|\s*access-?date\s*=)\s*31( (?:April|June|September|November) @year)(?=[\s\n]*[<|}])/gi, '$130$2'); //rem nonsense access date (short months)
ohc_regex(/(\|\s*access-?date\s*=)\s*29( February (?:200[1235679]|201[1345789]))(?=[\s\n]*[<|}])/gi, '$128$2'); //rem nonsense access date 29 Feb (non-leap year)
ohc_regex(/(\|\s*access-?date\s*=)\s*(?:3[01])( February @yyyy)(?=[\s\n]*[<|}])/gi, '$128$2'); //rem nonsense access dates February
regex(/(\|\s*access-?date\s*=)\s*(\d{4})(?=[\s\n]*[<|}])/gi, ''); //common cs1 error
//month+day+year pseudo-ISO dates
ohc_regex(/(\|\s*(?:publication|archive|access|air|)-?date\s*=\s*@dd)-@Mon-@YYYY/gi, "$1 @FullMonth @YYYY");
ohc_regex(/(\|\s*(?:publication|archive|access|air|)-?date\s*=\s*)@YYYY-@DD-@Mon/gi, "$1 @DD @FullMonth @YYYY");
// remove dashbot comment from dates
regex(/(\|\s*(?:date|year)\s*=)\s*(?:(?:date |)unknown|(?:not? |non-|un)date[ds])(?=[\s\n]*[<|}])/gi, '$1n.d.'); //common cs1 error
.replace(/<!-- ?DASHBot ?-->/gi, '')
regex(/(\|\s*(?:date|year)\s*=)\s*n\.?d(?=[\s\n]*[<|}])/gi, '$1n.d.'); //common cs1 error
regex .ohc_regex(/(\|\s*)year(?:date|year)\s*=)\s*)c(?=n:irca|a\.)?d\.s?((?:@day |)@month @year)(?=[\s\n]*[<|}])/gi, '"$1date1c. $2'"); //common cs1add errorspace
// common cs1 errors
// remove parasitic metadata - days of the week/descriptives
ohc_regex .replace(/(\|\s*(?:publication|archive|access|airdate|year)-?date\s*=)\s*)(?:1[^|}7-9]*\Dd|)@Day\s+@Month\s+@YYYY((?:20[a0-z1]\b|)\s?)[^|}]*(?=[\s\n]*[<|}])/gi, "$1@Day1c. @Month @YYYY$220"); //rem negate "<", "hyphens" "dashes" 26/6/2020
ohc_regex .replace(/(\|\s*(?:publication|archive|access|airdate|year)-?date\s*=\s*)[^|}]*@Month\s+@Day,\s+@YYYY((?:1[a7-z9]\b|)\s?d{2})[^|}-–]*(\d{2})(?=[\s\n]*[<|}])/gi, "$1@Month @Day, @YYYY1–$2$3"); //rem negate "<", "hyphens" "dashes" 26/6/2020
// ohc_regex.replace(/(\|\s*(?:date|year)\s*=\s*(20)(?:[^|}–<0-1]*\D|d)@Day\s+@Month\s+@YYYY ?– ?@Day\s+@Month\s+@YYYY[^|}-–<]*([0-2]\d)(?=[\s\n]*[<|}])/gi, "$1@Day1 @Mon1 @Year1 – @Day2 @Mon2 @Year21–$2$3");
// .ohc_regex(/(\|\s*(?:date|year)\s*=\s*)@YYYY\s*[^|}-–</]*@Month\s+*@Day,YYNN(?=[\s+\n]*[<|}])/gi, "$1@YYYYYYYY1–@YYYY2") ?–// ?@Monthcommon @Day,cs1 error(/(\|\s*(?:date|year)\s*=\s*)@YYYY\s*[^|}-–</]\s*@YYYY(?=[\s\n]*[<|}])/gi, "$1@Mon1 YYYY1–@Day1,YYYY2") @Year1//common –cs1 @@Mon2 Day2, @Year2");error
// regex .replace(/(\|\s*author(?:date)\s*=)\s*)s(?:postedpring|publishedummer),?\s*((?: by1[7-9]\bd| on\b|)20[\s:0-1])\d)(?=[\ws\n]*[<|}])/gi, "$11S$2 $3"); // common cs1 error
// regex .replace(/(\|\s*(?:date|archive-?date|access-?date|author|year)\s*=)\s*)a(utumn),?:accessed|retrieved|entered|posted|published|\s*((?:last 1[7-9]\d|20[0-1])updated?|©\d)(?: by\b| on\b|)=[\s:\n]*(?=\w[<|}])/gi, "$11A$2 $3"); // common cs1 error
regex .replace(/(\|\s*(?:author|first|lastdate)\s*=)\s*f(all),?\s*((?:by1[7-9]\bd|on20[0-1])\bd)(?=[\s:\n]*(?=\w[<|}])/gi, "$11F$2 $3"); // common cs1 error
regex .replace(/(\|\s*(?:date|archive-?date|access-?date|author|first|last)\s*=)\s*)w(inter),?:\s*((?:Mon|Tues|Wednes|Thurs1[7-9]\d|Fri|Satur|Sun20[0-1])day,?\d)(?=[\s\n]*[<|}])/gi, "$11W$2 $3"); // common cs1 error
regex .replace(/(\|\s*(?:date|archive-?date|access-?date|author|first|last)\s*=)\s*(Spring|Summer|Autumn|Fall|Winter)[-–](S(?:Monpring|Tues?ummer)|WedAutumn|Thur?Fall|Fri|SatWinter)[\.,] ?\s/gi, "$1$2–$3 "); //<!-- remcommon "Sun"cs1 - false positives -->error
.ohc_regex(/(\|\s*access-?date\s*=)\s*(@month @year)(?=[\s\n]*[<|}])/gi, "$11 $2") //common cs1 error
//.ohc_regex(/(\|\s*date\s*=\s*)@year\?(?=[\s\n]*[<|}])/gi, "$1@Year") // common cs1 error
//.ohc_regex(/(\|\s*(?:date|year)\s*=)\s*@year\?(?=[\s\n]*[<|}])/gi, "$1c. @Year") // common cs1 error
//.ohc_regex(/(\|\s*(?:date|year)\s*=)\s*(@month @year)\?(?=[\s\n]*[<|}])/gi, "$1c. $2") // common cs1 error
.ohc_regex(/(\|\s*access-?date\s*=)\s*@month @day, (1[7-9]\d{2}|2000)(?=[\s\n]*[<|}])/gi, "$1") // rem access date before Wikipedia (January 2001)
.ohc_regex(/(\|\s*access-?date\s*=)\s*@day @month.? (1[7-9]\d{2}|2000)(?=[\s\n]*[<|}])/gi, "$1") // rem access date before Wikipedia (January 2001)
.ohc_regex(/(\|\s*access-?date\s*=)\s*31( (?:April|June|September|November) @year)(?=[\s\n]*[<|}])/gi, "$130$2") // rem nonsense access date (short months)
.ohc_regex(/(\|\s*access-?date\s*=)\s*29( February (?:200[1235679]|201[1345789]))(?=[\s\n]*[<|}])/gi, "$128$2") // rem nonsense access date 29 Feb (non-leap year)
.ohc_regex(/(\|\s*access-?date\s*=)\s*(?:3[01])( February @yyyy)(?=[\s\n]*[<|}])/gi, "$128$2") // rem nonsense access dates February
.replace(/(\|\s*access-?date\s*=)\s*(\d{4})(?=[\s\n]*[<|}])/gi, '') // common cs1 error
// month+day+year pseudo-ISO dates
// remove deprecated parameters (|day= and |month)
.ohc_regex(/(\|\s*)day(?:\s*=\s*publication|archive|access|air|)@DD -?\| ?month(?:date\s*=\s*)@Month ?\| ?year(?:\s*=\s*dd)-@Mon-@YYYY(?=[|}\s])/gi, '"$1date=@Day1 @MonthFullMonth @Year'YYYY");
.ohc_regex(/(\|\s*)year(?:\s*=\s*)@YYYY ?\publication|archive|access|air| ?month(?:\s*=\s*)@Month -?\| ?day(?:date\s*=\s*)@YYYY-@DD(?=[|}\s])-@Mon/gi, '"$1date=1 @MonthDD @Day,FullMonth @Year'YYYY");
// typos
ohc_regex(/(date *= *)@Day @Month ?@th/gi, '$1@Day @Month');
ohc_regex(/(date *= *)@Day @Month\w(?= \d{3,4})/gi, '$1@Day @Month');
ohc_regex .replace(/(\|\s*(?:date |year)\s*= )\s*(?:[12](?\d|30:date |31) )unknown|(Jan?:not? |Febrnon-|un)date[\w ds]?[aur]{3,4}\w{0,2})(?= (?:1[6-9]\d|20s\n]*[01<|}])\d\b)/gi, '"$1$2uary'1n.d."); // common cs1 error
.replace(/(\|\s*(?:date|year)\s*=)\s*n\.?d(?=[\s\n]*[<|}])/gi, "$1n.d.") // common cs1 error
ohc_regex(/(date *= *(?:[12]?\d|30|31) )J[anu]{3,5}r\w{0,2}(?= (?:1[6-9]\d|20[01])\d\b)/gi, '$1January');
ohc_regex .replace(/(date \|\s*)year(\s*= \s*)(?:[12]?=n\.?d) )Febua?r\w{0,2}.)(?= (?:1[6-9]\d|20s\n]*[01<|}])\d\b)/gi, '"$1February'1date$2"); // common cs1 error
ohc_regex(/(date *= *(?:[12]?\d|30|31) )M\w{2,3}ch(?= (?:1[6-9]\d|20[01])\d\b)/gi, '$1March');
ohc_regex(/(date *= *(?:[12]?\d|30) )A[bpv\[]\w{2,3}l\w?(?= (?:1[6-9]\d|20[01])\d\b)/gi, '$1April');
ohc_regex(/(date *= *(?:[12]?\d|30|31) )Ma[tui](?= (?:1[6-9]\d|20[01])\d\b)/gi, '$1May');
ohc_regex(/(date *= *(?:[12]?\d|30) )J\wn\w(?= (?:1[6-9]\d|20[01])\d\b)/gi, '$1June');
ohc_regex(/(date *= *(?:[12]?\d|30) )J\w{1,2}e(?= (?:1[6-9]\d|20[01])\d\b)/gi, '$1June');
ohc_regex(/(date *= *(?:[12]?\d|30|31) )Jul\w{1,2}(?= (?:1[6-9]\d|20[01])\d\b)/gi, '$1July');
ohc_regex(/(date *= *(?:[12]?\d|30|31) )A[oug]{2,3}\w{1,4}t(?:\w|us)?(?= (?:1[6-9]\d|20[01])\d\b)/gi, '$1August');
ohc_regex(/(date *= *(?:[12]?\d|30|31) )(Sept|Nov|Dec)\w{2,4}b[er]{1,2}\w?(?= (?:1[6-9]\d|20[01])\d\b)/gi, '$1$2ember');
ohc_regex(/(date *= *(?:[12]?\d|30) )S\w{0,2}p[ \[]?\w{2,5}[er]{2,3}\w?(?= (?:1[6-9]\d|20[01])\d\b)/gi, '$1September');
ohc_regex(/(date *= *(?:[12]?\d|30|31) )O\w{0,2}t\w{1,3}[er]{2,3}\w?(?= (?:1[6-9]\d|20[01])\d\b)/gi, '$1October');
ohc_regex(/(date *= *(?:[12]?\d|30) )[MN]\w{1,2}[bv] ?\w{1,3}b[er]{1,2}\w?(?= (?:1[6-9]\d|20[01])\d\b)/gi, '$1November');
ohc_regex(/(date *= *(?:[12]?\d|30|31) )D[ie]?[cs] ?\w{1,4}b[er]{1,2}\w?(?= (?:1[6-9]\d|20[01])\d\b)/gi, '$1December');
// remove parasitic metadata - days of the week/descriptives
ohc_regex(/(date *= *)@Month\w(?=(?: (?:[12]?\d|30|31),?|) (?:1[6-9]\d|20[01])\d\b)/gi, '$1@Month'); //rem stray digit at the end of year string
.ohc_regex(/(\|\s*(?:publication|archive|access|air|)-?date\s*=\s*)(?:[^|}\d]*|)@Day\s+@Month\s+@YYYY((?:[a-z]\b|)\s?)(?=[\s\n]*[<|}])/gi, "$1@Day @Month @YYYY$2") // rem negate "<", "hyphens" "dashes" 26/6/2020
.ohc_regex(/(\|\s*(?:publication|archive|access|air|)-?date \s*= \s*)(Jan|Febr)[\w ]?[aur]{3,4^|}]*@Month\w{0s+@Day,2}\s+@YYYY(?=(?: (?:[12a-z]?\db|30|31),\s?|) (?:1=[6-9]\d|20s\n]*[01<|}])\d\b)/gi, '"$1@Month @Day, @YYYY$2uary'2"); // rem negate "<", "hyphens" "dashes" 26/6/2020
//.ohc_regex(/(\|\s*date \s*= \s*)J[anu]{3,5}r\w{0,2}(?=(?: (?:[12^|}–<]?*\dD|30|31),@Day\s+@Month\s+@YYYY ?|)– (?:1@Day\s+@Month\s+@YYYY[6-9^|}–<]*(?=[\d|20s\n]*[01<|}])\d\b)/gi, '"$1January'1@Day1 @Mon1 @Year1 – @Day2 @Mon2 @Year2");
//.ohc_regex(/(\|\s*date \s*= \s*)Febua?r[^|}–<]*@Month\w{0s+@Day,2}(?=(\s+@YYYY ?:– (?:[12]?\d)@Month @Day,?|) @YYYY[^|}–<]*(?:1=[6-9]\d|20s\n]*[01<|}])\d\b)/gi, '"$1February'1@Mon1 @Day1, @Year1 – @@Mon2 Day2, @Year2");
ohc_regex //.replace(/(date \|\s*author\s*= \s*)M\w{2,3}ch(?=:posted|published)(?: (?:[12]?by\db|30 on\b|31),?|) (?:1[6-9]\d|20[01s:])(?=\d\bw)/gi, '"$1March'1");
//.replace(/(\|\s*(?:date|archive-?date|access-?date|author|year)\s*=\s*)(?:accessed|retrieved|entered|posted|published|(?:last |)updated?|©)(?: by\b| on\b|)[\s:]*(?=\w)/gi, "$1")
ohc_regex(/(date *= *)A[bpv\[]\w{2,3}l\w?(?=(?: (?:[12]?\d|30),?|) (?:1[6-9]\d|20[01])\d\b)/gi, '$1April');
ohc_regex .replace(/(date \|\s*= *)Ma[tui](?=(?: (?:[12]?\dauthor|30first|31last),?|\s*=\s*) (?:1[6-9]by\db|20on\b)[01\s:])*(?=\d\bw)/gi, '"$1May'1");
.replace(/(\|\s*(?:date|archive-?date|access-?date|author|first|last)\s*=\s*)(?:(?:Mon|Tues|Wednes|Thurs|Fri|Satur|Sun)day,?)\s/gi, "$1")
ohc_regex(/(date *= *)J\wn\w(?=(?: (?:[12]?\d|30),?|) (?:1[6-9]\d|20[01])\d\b)/gi, '$1June');
.replace(/(\|\s*(?:date|archive-?date|access-?date|author|first|last)\s*=\s*)(?:Mon|Tues?|Wed|Thur?|Fri|Sat)[\.,]?\s/gi, "$1") // rem "Sun" - false positives
ohc_regex(/(date *= *)J\w{1,2}e(?=(?: (?:[12]?\d|30),?|) (?:1[6-9]\d|20[01])\d\b)/gi, '$1June');
ohc_regex(/(date *= *)Jul\w{1,2}(?=(?: (?:[12]?\d|30|31),?|) (?:1[6-9]\d|20[01])\d\b)/gi, '$1July');
ohc_regex(/(date *= *)A[oug]{2,3}\w{1,4}t(?:\w|us)?(?=(?: (?:[12]?\d|30|31),?|) (?:1[6-9]\d|20[01])\d\b)/gi, '$1August');
ohc_regex(/(date *= *)(Sept|Nov|Dec)\w{2,4}b[er]{1,2}\w?(?=(?: (?:[12]?\d|30|31),?|) (?:1[6-9]\d|20[01])\d\b)/gi, '$1$2ember');
ohc_regex(/(date *= *)S\w{0,2}p[ \[]?\w{2,5}[er]{2,3}\w?(?=(?: (?:[12]?\d|30),?|) (?:1[6-9]\d|20[01])\d\b)/gi, '$1September');
ohc_regex(/(date *= *)O\w{0,2}t\w{1,3}[er]{2,3}\w?(?=(?: (?:[12]?\d|30|31),?|) (?:1[6-9]\d|20[01])\d\b)/gi, '$1October');
ohc_regex(/(date *= *)[MN]\w{1,2}[bv] ?\w{1,3}b[er]{1,2}\w?(?=(?: (?:[12]?\d|30),?|) (?:1[6-9]\d|20[01])\d\b)/gi, '$1November');
ohc_regex(/(date *= *)D[ie]?[cs] ?\w{1,4}b[er]{1,2}\w?(?=(?: (?:[12]?\d|30|31),?|) (?:1[6-9]\d|20[01])\d\b)/gi, '$1December');
// remove deprecated parameters (|day= and |month)
//insert comma to separate date from army unit
.ohc_regex(/(\|\s*)day(?:\s*=\s*)@DD ?\| ?month(?:\s*=\s*)@Month ?\| ?year(?:\s*=\s*)@YYYY(?=[|}\s])/gi, "$1date=@Day @Month @Year")
ohc_regex(/@FullMonth ((?:the |)\d\d*@th (?:Air(?:borne|)|Arm(?:ou?red|y)|Artillery|Battalion|Brigade|Co(?:mpan|)y|Division|Fleet|Group|Infantry|Land|Panzer|Regiment|Squadron|Sqn)\b)/g, "@Month, $1");
.ohc_regex(/(\|\s*)year(?:\s*=\s*)@YYYY ?\| ?month(?:\s*=\s*)@Month ?\| ?day(?:\s*=\s*)@DD(?=[|}\s])/gi, "$1date=@Month @Day, @Year")
// typos
// remove parasitic metadata - time
.ohc_regex(/(date *= *)@Day @Month ?@th/gi, "$1@Day @Month")
ohc_regex(/(\|\s*\w*date\s*=\s*@yyyy-@mm-@dd)\s?(?:T[0-2]\d:[0-5]\d:[0-5]\d(?:\s*| |)(?:GMT\s*|UTC\s*|[A-Z]{1,2}[DS]T\s*|Z))(?=\s*[|}])/g, "$1");
.ohc_regex(/(\|\s*\w*date\s *=\s *)@monthDay @day,? @yyyy)Month\s?w(?:,?= [0-2]?\d[\.:][0-5]\d(?:\s*| )(?:[apAP][mM]\s*|)(?:GMT\s*|UTC\s*|[A-Z]{13,24}[DS]T\s*|))(?=\|)/ggi, "$1@Day @Month");
ohc_regex(/(\|\s*\w*date\s*=\s*@day @month,? @yyyy)\s?(?:,? [0-2]?\d[\.:][0-5]\d(?:\s*| )(?:[apAP][mM]\s*|)(?:GMT\s*|UTC\s*|[A-Z]{1,2}[DS]T\s*|))(?=\|)/g, "$1");
ohc_regex(/(\|\s*\w*date\s*=\s*\w[\w\s]+@month @day,? @yyyy)\s?(?:,? [0-2]?\d[\.:][0-5]\d(?:\s*| )(?:[apAP][mM]\s*|)(?:GMT\s*|UTC\s*|[A-Z]{1,2}[DS]T\s*|))(?=\|)/g, "$1");
ohc_regex(/(\|\s*\w*date\s*=\s*\w[\w\s]+@day @month,? @yyyy)\s?(?:,? [0-2]?\d[\.:][0-5]\d(?:\s*| )(?:[apAP][mM]\s*|)(?:GMT\s*|UTC\s*|[A-Z]{1,2}[DS]T\s*|))(?=\|)/g, "$1");
ohc_regex(/(\|\s*\w*date\s*=[^:|}]*)\s?(?:T?[0-2]\d:[0-5]\d:[0-5]\d(?:\s*| |)(?:GMT\s*|UTC\s*|[A-Z]{1,2}[DS]T\s*|Z))/g, "$1");
.ohc_regex(/(date *= *(?:[12]?\d|30|31) )(Jan|Febr)[\w ]?[aur]{3,4}\w{0,2}(?= (?:1[6-9]\d|20[01])\d\b)/gi, "$1$2uary")
// add back spaces or comma or remove other single artefact after date string
.ohc_regex(/(\|\s*(?:publication|archive|access|air|)-?date\s *=\s *)(?:on [12]?\d|30|31)@Day\s )J[anu]{3,25}@Monthr\sw{0,2}@YYYY(?= (?:1[^a6-z{}9]?(?=\s*[d|}\n20[01])\d\b)/gi, "$1@Day @Month @YYYY$21January");
.ohc_regex(/(\|\sdate *= *(?:publication|archive|access|air|)-[12]?date\s*=\s*d)(?:on |)@MonthFebua?r\sw{0,2}@Day,(?\s{,2}@YYYY= (?:1[^a6-z{}9]?(?=\s*d|20[|}\n01])\d\b)/gi, "$1@Month @Day, @YYYY$21February");
.ohc_regex(/(date *= *(?:[12]?\d|30|31) )M\w{2,3}ch(?= (?:1[6-9]\d|20[01])\d\b)/gi, "$1March")
//long-hand palliative for observed failure to insert spaces
.ohc_regex(/(\|\s*(?:archive|access|air)-?date\s *=\s *)(?:on |)([0-212]?\d|30|31)\s*(January|February|March|April|May|June|July|August|September|October|November|December )A[bpv\s*[]\w{2,3}l\w?(?= (?:191[6-9]\d|20[0-101])\d\s?)[^|{}\s<>]*(?=\s*[|}]b)/gi, "$1$2 $3 $41April");
// .ohc_regex(/(\|\s*(?:publication|)-?date\s *=\s *)(?:on |)@Day\s*@Month\s*@YYYY([a-z12]?\s?d|\s?30|31)\w* )Ma[^|{}<>tui]*(?= (?:1[6-9]\d|}20[01])\d\b)/gi, "$1@Day @Month @YYYY$21May");
// .ohc_regex(/(\|\s*(?:publication|)-?date\s *=\s *)(?:on |)@Month\s*@Day,\s*@YYYY([a-z12]?\s?d|\s?30) )J\wn\w*[^|{}<>]*(?= (?:1[6-9]\d|}20[01])\d\b)/gi, "$1@Month @Day, @YYYY$21June");
.ohc_regex(/(date *= *(?:[12]?\d|30) )J\w{1,2}e(?= (?:1[6-9]\d|20[01])\d\b)/gi, "$1June")
.ohc_regex(/(date *= *(?:[12]?\d|30|31) )Jul\w{1,2}(?= (?:1[6-9]\d|20[01])\d\b)/gi, "$1July")
.ohc_regex(/(date *= *(?:[12]?\d|30|31) )A[oug]{2,3}\w{1,4}t(?:\w|us)?(?= (?:1[6-9]\d|20[01])\d\b)/gi, "$1August")
.ohc_regex(/(date *= *(?:[12]?\d|30|31) )(Sept|Nov|Dec)\w{2,4}b[er]{1,2}\w?(?= (?:1[6-9]\d|20[01])\d\b)/gi, "$1$2ember")
.ohc_regex(/(date *= *(?:[12]?\d|30) )S\w{0,2}p[ \[]?\w{2,5}[er]{2,3}\w?(?= (?:1[6-9]\d|20[01])\d\b)/gi, "$1September")
.ohc_regex(/(date *= *(?:[12]?\d|30|31) )O\w{0,2}t\w{1,3}[er]{2,3}\w?(?= (?:1[6-9]\d|20[01])\d\b)/gi, "$1October")
.ohc_regex(/(date *= *(?:[12]?\d|30) )[MN]\w{1,2}[bv] ?\w{1,3}b[er]{1,2}\w?(?= (?:1[6-9]\d|20[01])\d\b)/gi, "$1November")
.ohc_regex(/(date *= *(?:[12]?\d|30|31) )D[ie]?[cs] ?\w{1,4}b[er]{1,2}\w?(?= (?:1[6-9]\d|20[01])\d\b)/gi, "$1December")
.ohc_regex(/(date *= *)@Month\w(?=(?: (?:[12]?\d|30|31),?|) (?:1[6-9]\d|20[01])\d\b)/gi, "$1@Month") //rem stray digit at the end of year string
//remove extraneous bracket //from Batty
ohc_regex(/{{(\s*[Cc]it(?:e|ation))([^}]+)(\s*\|\s*(?:archive-?|access-?|publication-?)?date\s*=\s*)([\w\s-]+)\](?=\s*[\|}<])/gi, '{{$1$2$3$4');
.ohc_regex(/(date *= *)(Jan|Febr)[\w ]?[aur]{3,4}\w{0,2}(?=(?: (?:[12]?\d|30|31),?|) (?:1[6-9]\d|20[01])\d\b)/gi, "$1$2uary")
//fix bda template redirect
.ohc_regex(/(date *= *)J[anu]{3,5}r\w{0,2}(?=(?: (?:[12]?\d|30|31),?|) (?:1[6-9]\d|20[01])\d\b)/gi, "$1January")
// regex(/\{\{bda\|([^}]+)\}\}/gi, '{{birth date and age|$1}}');
.ohc_regex(/(date *= *)Febua?r\w{0,2}(?=(?: (?:[12]?\d),?|) (?:1[6-9]\d|20[01])\d\b)/gi, "$1February")
// regex(/\{\{dda\|([^}]+)\}\}/gi, '{{death date and age|$1}}');
.ohc_regex(/(date *= *)M\w{2,3}ch(?=(?: (?:[12]?\d|30|31),?|) (?:1[6-9]\d|20[01])\d\b)/gi, "$1March")
.ohc_regex(/(date *= *)A[bpv\[]\w{2,3}l\w?(?=(?: (?:[12]?\d|30),?|) (?:1[6-9]\d|20[01])\d\b)/gi, "$1April")
.ohc_regex(/(date *= *)Ma[tui](?=(?: (?:[12]?\d|30|31),?|) (?:1[6-9]\d|20[01])\d\b)/gi, "$1May")
.ohc_regex(/(date *= *)J\wn\w(?=(?: (?:[12]?\d|30),?|) (?:1[6-9]\d|20[01])\d\b)/gi, "$1June")
.ohc_regex(/(date *= *)J\w{1,2}e(?=(?: (?:[12]?\d|30),?|) (?:1[6-9]\d|20[01])\d\b)/gi, "$1June")
.ohc_regex(/(date *= *)Jul\w{1,2}(?=(?: (?:[12]?\d|30|31),?|) (?:1[6-9]\d|20[01])\d\b)/gi, "$1July")
.ohc_regex(/(date *= *)A[oug]{2,3}\w{1,4}t(?:\w|us)?(?=(?: (?:[12]?\d|30|31),?|) (?:1[6-9]\d|20[01])\d\b)/gi, "$1August")
.ohc_regex(/(date *= *)(Sept|Nov|Dec)\w{2,4}b[er]{1,2}\w?(?=(?: (?:[12]?\d|30|31),?|) (?:1[6-9]\d|20[01])\d\b)/gi, "$1$2ember")
.ohc_regex(/(date *= *)S\w{0,2}p[ \[]?\w{2,5}[er]{2,3}\w?(?=(?: (?:[12]?\d|30),?|) (?:1[6-9]\d|20[01])\d\b)/gi, "$1September")
.ohc_regex(/(date *= *)O\w{0,2}t\w{1,3}[er]{2,3}\w?(?=(?: (?:[12]?\d|30|31),?|) (?:1[6-9]\d|20[01])\d\b)/gi, "$1October")
.ohc_regex(/(date *= *)[MN]\w{1,2}[bv] ?\w{1,3}b[er]{1,2}\w?(?=(?: (?:[12]?\d|30),?|) (?:1[6-9]\d|20[01])\d\b)/gi, "$1November")
.ohc_regex(/(date *= *)D[ie]?[cs] ?\w{1,4}b[er]{1,2}\w?(?=(?: (?:[12]?\d|30|31),?|) (?:1[6-9]\d|20[01])\d\b)/gi, "$1December")
// insert comma to separate date from army unit
//zap redundant {{date}}, {{accessdate}} {{retrieved}}, {{monthname}} and {{#dateformat}}
.ohc_regex(/@FullMonth ((?:the |)\d\d*@th (?:Air(?:borne|)|Arm(?:ou?red|y)|Artillery|Battalion|Brigade|Co(?:mpan|)y|Division|Fleet|Group|Infantry|Land|Panzer|Regiment|Squadron|Sqn)\b)/g, "@Month, $1")
// regex(/({{(?:end|start)[-–]date)\|df=y(?:es|)/gi, "$1"); //rem deprecated parameter - disabled: doesn't work here, so ejected to the formatting script
regex(/{{#formatdate:([^}]+)}}/gi, "$1");
regex(/\{\{#dateformat:([^}\|]+)(?:\|dmy|\|mdy)?\}\}/gi, '$1');
// ohc_regex(/(date[ ]*=[ ]*)\{\{(?:Start|End) ?date(?:\|df=y(?:es|)|)\|@YYYY\|@MM\|@DD(?:\|df=y(?:es|)|)\}\}/gi, '$1@Month @DD, @YYYY'); //stripping start/end template notes inside "|date=" parameter (line 72)
ohc_regex(/{{#formatdate:@YYYY-@MM-@DD(?:\|(?:[dmy]{3}|iso)|)}}/gi, "@Day @Month @YYYY");
ohc_regex(/\{\{date\|@YYYY-@MM-@DD\}\}/gi, "@Day @Month @YYYY");
ohc_regex(/\{\{date\|(@DD[\-\s]@Mon|@Mon[\-\s]@DD)\}\}/gi, "@Day @Month");
regex(/\{\{date\|([^}\|]+)(?:\|l?(?:[dmy]{3}|iso|none|link))?\}\}/gi, '$1');
ohc_regex(/[ ]*\{\{accessdate\|@YYYY-@MM-@DD[ ]*\}\}/gi, " Retrieved @YYYY-@MM-@DD");
ohc_regex(/[ ]*\{\{retrieved[ ]*\|[ ]accessdate=([\-\w, ]*)\}\}/gi, " Retrieved $1");
// ohc_regex(/(date[ ]*=[ ]*|\w{2,}[ ]*)\{\{(?:start|end).date[^|}]*(?:\|df=y(?:es|)|)\|@YYYY(?:\|df=y(?:es|)|)\}\}/gi, '$1@YYYY'); //stripping start/end template (disabling to placate Pigsonthewing)
// ohc_regex(/\{\{(?:Start|End) date(?:\|df=y(?:es|)|)\|@YYYY\|@MM\}\}/gi, '@Month @YYYY') //stripping start/end template notes
// ohc_regex(/<!--(?:Use)? \{\{(?:Start|End) date\|@YYYY\|@MM\|@DD\}\} -->/gi, ''); //stripping start/end template notes
ohc_regex(/(\{\{MONTHNAME\|@MM\}\})/gi, "@Month")
// remove parasitic metadata - time
//expand one and two-digit years in ranges
.ohc_regex(/(\|\s*\w*date\s*=\s*@yyyy-@mm-@dd)\s?(?:T[0-2]\d:[0-5]\d:[0-5]\d(?:\s*| |)(?:GMT\s*|UTC\s*|[A-Z]{1,2}[DS]T\s*|Z))(?=\s*[|}])/g, "$1")
regex(/(\()@Month @YYYY[-–]@Month @YYNN(\))/gi, '$1@Month1 @YYYY1 – @Month2 @YYYY2$2');
.ohc_regex(/(\|\s*\w*date\s*=\s*@month @day,? @yyyy)\s?(?:,? [0-2]?\d[\.:][0-5]\d(?:\s*| )(?:[apAP][mM]\s*|)(?:GMT\s*|UTC\s*|[A-Z]{1,2}[DS]T\s*|))(?=\|)/g, "$1")
regex(/(\(1[789])(\d)(1)[-–]([2-9]\))/gi, '$1$2$3–$2$4');
.ohc_regex(/(\|\s*\w*date\s*=\s*@day @month,? @yyyy)\s?(?:,? [0-2]?\d[\.:][0-5]\d(?:\s*| )(?:[apAP][mM]\s*|)(?:GMT\s*|UTC\s*|[A-Z]{1,2}[DS]T\s*|))(?=\|)/g, "$1")
regex(/(\(1[789])(\d)(2)[-–]([3-9]\))/gi, '$1$2$3–$2$4');
.ohc_regex(/(\|\s*\w*date\s*=\s*\w[\w\s]+@month @day,? @yyyy)\s?(?:,? [0-2]?\d[\.:][0-5]\d(?:\s*| )(?:[apAP][mM]\s*|)(?:GMT\s*|UTC\s*|[A-Z]{1,2}[DS]T\s*|))(?=\|)/g, "$1")
regex(/(\(1[789])(\d)(3)[-–]([4-9]\))/gi, '$1$2$3–$2$4');
.ohc_regex(/(\|\s*\w*date\s*=\s*\w[\w\s]+@day @month,? @yyyy)\s?(?:,? [0-2]?\d[\.:][0-5]\d(?:\s*| )(?:[apAP][mM]\s*|)(?:GMT\s*|UTC\s*|[A-Z]{1,2}[DS]T\s*|))(?=\|)/g, "$1")
regex(/(\(1[789])(\d)(4)[-–]([5-9]\))/gi, '$1$2$3–$2$4');
.ohc_regex(/(\|\s*\w*date\s*=[^:|}]*)\s?(?:T?[0-2]\d:[0-5]\d:[0-5]\d(?:\s*| |)(?:GMT\s*|UTC\s*|[A-Z]{1,2}[DS]T\s*|Z))/g, "$1")
regex(/(\(1[789])(\d)(5)[-–]([6-9]\))/gi, '$1$2$3–$2$4');
regex(/(\(1[789])(\d)(6)[-–]([7-9]\))/gi, '$1$2$3–$2$4');
regex(/(\(1[789])(\d)(7)[-–]([8-9]\))/gi, '$1$2$3–$2$4');
regex(/(\(1[789])(\d)(8)[-–](9\))/gi, '$1$2$3–$2$4');
regex(/(\(20)([01])(1)[-–]([2-9]\))/gi, '$1$2$3–$2$4');
regex(/(\(20)([01])(2)[-–]([3-9]\))/gi, '$1$2$3–$2$4');
regex(/(\(20)([01])(3)[-–]([4-9]\))/gi, '$1$2$3–$2$4');
regex(/(\(20)([01])(4)[-–]([5-9]\))/gi, '$1$2$3–$2$4');
regex(/(\(20)([01])(5)[-–]([6-9]\))/gi, '$1$2$3–$2$4');
regex(/(\(20)([01])(6)[-–]([7-9]\))/gi, '$1$2$3–$2$4');
regex(/(\(20)([01])(7)[-–]([8-9]\))/gi, '$1$2$3–$2$4');
regex(/(\(20)([01])(8)[-–](9\))/gi, '$1$2$3–$2$4');
// add back spaces or comma or remove other single artefact after date string
//remove unlinked ordinal date formats
// .ohc_regex(/(\Wthe |\s*(?:publication|archive|access|air|)@DD@th-?date\s*=\s*)(?:\sofon |)@Day\s{,2}@Month\s{,? 2}@YYYY [^a-z{}]?(concert|edition?=\s*[|show|performance}\n])/gi, '"$1$2 of @Day @LMonthMonth @YYYY'$2");
// .ohc_regex(/(\Wthe|\s*(?:publication|archive|access|air|)-?date\s*=\s*)(?:on |)@Month \s{,2}@DD@th?Day,?\s{,2}@YYYY [^a-z{}]?(concert?=\s*[|edition|show|performance}\n])/gi, '"$1$2 of @LMonthMonth @Day, @YYYY'$2");
// ohc_regex(/(\Wthe |)@DD@th?(?:\sof|)\s@Month (concert|edition|show|performance)/gi, '$1$2 of @Day @LMonth');
// ohc_regex(/(\Wthe |)@Month @DD@th? (concert|edition|show|performance)/gi, '$1$2 of @LMonth @Day');
// long-hand palliative for observed failure to insert spaces
ohc_regex(/(\W)@DD@th?, @DD@th?((?:[ ]| )(?:and|&|to|or)(?:[ ]| ))@DD@th?(?:\sof\s?)?([ ]| )@Month(?=\W)/gi, '$1@Day1, @Day2$2@Day3$3@LMonth');
.ohc_regex(/(\|\s*(?:archive|access|air)-?date\s*=\s*)(?:on |)([0-2]?\d|30|31)\s*(January|February|March|April|May|June|July|August|September|October|November|December)\s*((?:19\d|20[0-1])\d\s?)[^|{}\s<>]*(?=\s*[|}])/gi, "$1$2 $3 $4")
ohc_regex(/(\W)@DD@th?((?:[ ]| )(?:and|&|to|or)(?:[ ]| ))@DD@th?(?:\sof\s?|)([ ]| )@Month(?=\W)/gi, '$1@Day1$2@Day2$3@LMonth');
ohc_regex(/(\W)the @DD@th(?:\sof|)\s@Month,? @YYYY(?=\W\D)/g, '$1@Day @LMonth @YYYY');
ohc_regex(/(\W)the @DD@th(?:\sof|)\s@Month(?=\W\D)/g, '$1@Day @LMonth');
ohc_regex(/(\W)@Day@th?(?:\sof|)([ _]| |{{(?:break|nbsp)}})@Month(?=[^|\]\w])/gi, '$1@Day$2@LMonth');
ohc_regex(/(\W)@Month\s(?:the\s)?@DD@th?,(?:\sthe\s)?(?: | )@DD@th?(\s(?:and|&|to|or)(?:[ _]| ))(?:the\s)?@DD@th?(?=[^|\]\w])/gi, '$1@LMonth @Day1, @Day2$2@Day3');
ohc_regex(/(\W)(@month)\s(@day)((?:,\s@day){0,6}),?(\/|\s?[-–]\s?|\s(?:and|&|to|or)\s+?)@Day@th?(?:,?(?:[ _]| )|\sof\s)?(\d{3,4}\W\D)/gi, '$1$2 $3$4$5@Day, $6');
ohc_regex(/(\W)(@month)\s(@day)((?:,\s@day){0,6}),?(\/|\s?[-–]\s?|\s(?:and|&|to|or)\s+?)@Day@th?(?=\W\D)/gi, '$1$2 $3$4$5@Day');
ohc_regex(/(\W)@Month([ _]| |{{(?:break|nbsp)}})(?:the\s)?@DD@th?,? @Year/gi, '$1@LMonth$2@Day, @Year');
ohc_regex(/(\W)@Month @Day(?:\sof|,|)([ _]| |{{(?:break|nbsp)}})@Year(?=[^|\]\w])/gi, '$1@Month @Day,$2@Year');
// remove extraneous bracket //from Batty
// consolidating/amalgamating date fields
.ohc_regex(/{{(\|[ ]s*date[ Cc]*=it(?:e|ation))([ ^}]*@day+)(\s*\|[ ]*month=[ ]\s*(@month?:archive-?|access-?|publication-?)?date\s*=\|[ ]*year=[ ]s*)(@yyyy[ \w\s-]*+)\](?=\s*[\|}\s<])/gi, "{{$1 $2 $3$4");
ohc_regex(/(\|[ ]*date[ ]*=[ ]*@day.?@month)\s*\|[ ]*year=[ ]*(@yyyy[ ]*)(?=[|}\s])/gi, "$1 $2");
ohc_regex(/(\|[ ]*date[ ]*=[ ]*@month.?@day)\s*\|[ ]*year=[ ]*(@yyyy[ ]*)(?=[|}\s])/gi, "$1 $2");
// fix bda template redirect
// eliminating dates and time placed in author parameter
//.replace(/\{\{bda\|([^}]+)\}\}/gi, "{{birth date and age|$1}}")
//removing artefacts from Indian news sites (TNN Aug 30, 2012, 05.46AM)
//.replace(/\{\{dda\|([^}]+)\}\}/gi, "{{death date and age|$1}}")
ohc_regex(/(\|\s*author\s*=\s*(?:[A-Z]{2,3}\b))(?:[^|}]*)\d{4}, [\d\.:]{4,5}( |)[AP]M IST(?=[ ]*\|)/g, '$1$2');
// ohc_regex(/(\|\s*author=(?:[^\[\]|{}]*))(TNN|PTI) @day @month @yyyy, [\d\.:]{4,5}( |)[AP]M IST(?=[ ]*\|)/g, '$1$2');
// zap redundant {{date}}, {{accessdate}} {{retrieved}}, {{monthname}} and {{#dateformat}}
ohc_regex(/(\|\s*author\s*=\s*)@month @day,? @yyyy\s?(?:,? [0-2]?\d[\.:][0-5]\d(?:\s*| )(?:[apAP][mM]\s*|)(?:GMT\s*|UTC\s*|[A-Z]{1,2}[DS]T\s*|)|)(?=\|)/g, "$1");
//.replace(/({{(?:end|start)[-–]date)\|df=y(?:es|)/gi, "$1") // rem deprecated parameter - disabled: doesn't work here, so ejected to the formatting script
ohc_regex(/(\|\s*author\s*=\s*)@day @month,? @yyyy\s?(?:,? [0-2]?\d[\.:][0-5]\d(?:\s*| )(?:[apAP][mM]\s*|)(?:GMT\s*|UTC\s*|[A-Z]{1,2}[DS]T\s*|)|)(?=\|)/g, "$1");
.ohc_regex(/(\|\s*author\s*=\s*\w[\w\s]+){{#formatdate:@month YYYY-@day,? MM-@yyyyDD(?:[^\[\]|{}]*)(?=[|}])}/ggi, "$1@Day @Month @YYYY");
.replace(/{{#formatdate:([^}]+)}}/gi, "$1")
ohc_regex(/(\|\s*author\s*=\s*\w[\w\s]+)@day @month,? @yyyy(?:[^\[\]|{}]*)(?=[|}])/g, "$1");
ohc_regex .replace(/(\|{\s*author\s*=\s*(?{#dateformat:\w([^}\w\s|]+)(?:\|dmy|\|mdy)@dd-@mm-@yyyy?\}\}/gi, "$1");
//.ohc_regex(/(date[ ]*=[ ]*)\{\{(?:Start|End) ?date(?:\|df=y(?:es|)|)\|@YYYY\|@MM\|@DD(?:\|df=y(?:es|)|)\}\}/gi, "$1@Month @DD, @YYYY") // stripping start/end template notes inside "|date=" parameter (line 72)
ohc_regex(/(\|\s*author\s*=\s*(?:\w[\w\s]+)?)@YYYY-@MM-@DD ?/gi, "$1");
.ohc_regex(/{{#formatdate:@YYYY-@MM-@DD(?:\|(?:[dmy]{3}|iso)|)}}/gi, "@Day @Month @YYYY")
regex(/(\|\s*(?:date|archive-?date|access-?date|author)\s*=\s*(?:\w[\w\s]+)?)[0-2]\d:[0-5]\d(?:[ ]| )?(?:[ap]m|[ap]\.m\.|)(?: ?(?:[A-Z]{1,2}T|UTC)[\.,]?|)/gi, "$1");
// .ohc_regex(/(\|\s*author(?:archive|access|air)-?date\s*=\s*(?:\w[{\w{date\s]+)}\}(?)=\s*[0-2|}]\d[\.:][0-5]\d(?:[\.:][0-5]\d|)/gi, "$1"); //let'sremove {{date}} template without seeparameters laterthat ifinappropriately wereturn needcrrent thisdate
.ohc_regex(/\{\{date\|@YYYY-@MM-@DD\}\}/gi, "@YYYY-@MM-@DD")
.ohc_regex(/\{\{date\|@YYYY\/@MM\/@DD\}\}/gi, "@YYYY-@MM-@DD") //remove {{date}} template while rectifying slash dates within the template
.ohc_regex(/\{\{date\|(@DD[\-\s]@Mon|@Mon[\-\s]@DD)\}\}/gi, "@Day @Month")
.replace(/\{\{date\|([^}\|]+)(?:\|l?(?:[dmy]{3}|iso|none|link))?\}\}/gi, "$1")
.ohc_regex(/[ ]*\{\{accessdate\|@YYYY-@MM-@DD[ ]*\}\}/gi, " Retrieved @YYYY-@MM-@DD")
.ohc_regex(/[ ]*\{\{retrieved[ ]*\|[ ]accessdate=([\-\w, ]*)\}\}/gi, " Retrieved $1")
//.ohc_regex(/(date[ ]*=[ ]*|\w{2,}[ ]*)\{\{(?:start|end).date[^|}]*(?:\|df=y(?:es|)|)\|@YYYY(?:\|df=y(?:es|)|)\}\}/gi, "$1@YYYY") // stripping start/end template (disabling to placate Pigsonthewing)
//.ohc_regex(/\{\{(?:Start|End) date(?:\|df=y(?:es|)|)\|@YYYY\|@MM\}\}/gi, "@Month @YYYY") // tripping start/end template notes
//.ohc_regex(/<!--(?:Use)? \{\{(?:Start|End) date\|@YYYY\|@MM\|@DD\}\} -->/gi, '') // stripping start/end template notes
.ohc_regex(/(\{\{MONTHNAME\|@MM\}\})/gi, "@Month")
// expand one and two-digit years in ranges
// eliminating mm-dd-yyyy dates
.replace(/(\()@Month @YYYY[-–]@Month @YYNN(\))/gi, "$1@Month1 @YYYY1 – @Month2 @YYYY2$2")
ohc_regex(/(\|\s*(?:publication|archive|access|air|)-?date\s*=\s*)@MM[-–\/\.=\s](1[3-9]|2\d|3[01])[-–\/\.=\s]@YYYY/gi, "$1@Month $2, @YYYY");
ohc_regex .replace(/(\|\s*(?:publication|archive|access|air|1[789])-?date(\s*=\s*d)(1)@Mon[-–\/\.=\s](1[32-9]|2\d|3[01])[-–\/\.=\s]@YYYY)/gi, "$1@Month $2, @YYYY$3–$2$4");
.replace(/(\(1[789])(\d)(2)[-–]([3-9]\))/gi, "$1$2$3–$2$4")
ohc_regex(/[ ](?:Accessed|Retrieved)(?:(?: online|) on|:?)[ ]@MM[-–\/\.=\s](1[3-9]|2\d|3[01])[-–\/\.=\s]@YYYY(?=\D)/gi, " Retrieved @Month $1, @YYYY");
.replace(/(\(1[789])(\d)(3)[-–]([4-9]\))/gi, "$1$2$3–$2$4")
// ohc_regex(/[ ](?:Accessed|Retrieved)(?:(?: online|) on|:?)[ ]@YYYY,? @Month @DD(?=\D)/gi, " Retrieved @Day @Month @YYYY");
.replace(/(\(1[789])(\d)(4)[-–]([5-9]\))/gi, "$1$2$3–$2$4")
.replace(/(\(1[789])(\d)(5)[-–]([6-9]\))/gi, "$1$2$3–$2$4")
.replace(/(\(1[789])(\d)(6)[-–]([7-9]\))/gi, "$1$2$3–$2$4")
.replace(/(\(1[789])(\d)(7)[-–]([8-9]\))/gi, "$1$2$3–$2$4")
.replace(/(\(1[789])(\d)(8)[-–](9\))/gi, "$1$2$3–$2$4")
.replace(/(\(20)([01])(1)[-–]([2-9]\))/gi, "$1$2$3–$2$4")
.replace(/(\(20)([01])(2)[-–]([3-9]\))/gi, "$1$2$3–$2$4")
.replace(/(\(20)([01])(3)[-–]([4-9]\))/gi, "$1$2$3–$2$4")
.replace(/(\(20)([01])(4)[-–]([5-9]\))/gi, "$1$2$3–$2$4")
.replace(/(\(20)([01])(5)[-–]([6-9]\))/gi, "$1$2$3–$2$4")
.replace(/(\(20)([01])(6)[-–]([7-9]\))/gi, "$1$2$3–$2$4")
.replace(/(\(20)([01])(7)[-–]([8-9]\))/gi, "$1$2$3–$2$4")
.replace(/(\(20)([01])(8)[-–](9\))/gi, "$1$2$3–$2$4")
.ohc_regex(/([ =|]\W)@Mon[-–]DD@th?, @DD@th?(1(?:[3-9 ]|2\d )(?:and|3&|to|or)(?:[01 ]| ))@DD@th?(?:\sof\s?)?([-– ]| )@YYYYMonth(?=[^-–\d/]W)/gi, "$1@MonDay1, @Day2$2, @YYYYDay3$3@LMonth");
.ohc_regex(/(\W)@DD@th?((?:[ =|]| )@Mon\/(1?:and|&|to|or)(?:[3-9 ]|2 ))@DD@th?(?:\dsof\s?|3)([01 ]| )\/@YYYYMonth(?=[^-–\d/]W)/gi, "$1@Mon Day1$2, @YYYYDay2$3@LMonth");
.ohc_regex(/([\W)the =|])@Mon\.DD@th(1[3-9]|2?:\dsof|3[01])\.s@Month,? @YYYY(?=[^-–\d/]W\D)/gig, "$1@MonDay $2,@LMonth @YYYY");
.ohc_regex(/([\W)the =|])@Mon DD@th(1[3-9]|2?:\dsof|3[01]) \s@YYYYMonth(?=[^-–\d/]W\D)/gig, "$1@Mon $2,Day @YYYYLMonth");
.ohc_regex(/([ =|]\W)@MM[-–]Day@th?(?:\sof|)(1[3-9 _]|2\d |3[01]{{(?:break|nbsp)}})[-–]@YYYYMonth(?=[^-–|\d/]\w])/gi, "$1@Mon Day$2, @YYYYLMonth");
.ohc_regex(/([\W)@Month\s(?:the\s)?@DD@th?,(?:\sthe\s)?(?: =|] )@MMDD@th?(\/s(1[3-9]?:and|2\d&|3to|or)(?:[01 _]| ))(?:the\/s)?@YYYYDD@th?(?=[^-–|\d/]\w])/gi, "$1@MonLMonth $2@Day1, @YYYYDay2$2@Day3");
.ohc_regex(/([ =|]\W)(@MMmonth)\.s(1@day)((?:,\s@day){0,6}),?(\/|\s?[3-9–]\s?|2\ds(?:and|3[01]&|to|or)\.s+?)@YYYYDay@th?(?=:,?(?:[^-– _]| )|\sof\s)?(\d/]{3,4}\W\D)/gi, "$1@Mon $2, $3$4$5@YYYYDay, $6");
.ohc_regex(/([ =|]\W)(@MM month)\s(1@day)((?:,\s@day){0,6}),?(\/|\s?[3-9–]\s?|2\ds(?:and|3[01]&|to|or)\s+?) @YYYYDay@th?(?=[^-–\d/]W\D)/gi, "$1@Mon $2, $3$4$5@YYYYDay");
.ohc_regex(/(\W)@Month([ _]| |{{(?:break|nbsp)}})(?:the\s)?@DD@th?,? @Year/gi, "$1@LMonth$2@Day, @Year")
.ohc_regex(/(\W)@Month @Day(?:\sof|,|)([ _]| |{{(?:break|nbsp)}})@Year(?=[^|\]\w])/gi, "$1@Month @Day,$2@Year")
// consolidating/amalgamating date fields
// eliminating dd-mm-yyyy dates (assumed default)
.ohc_regex(/(\|\s[ ]*(?:publication|archive|access|air|)-?date\s[ ]*=[ ]*@day)\s*)@DD[-–\/\.|[ ]*month=[ ]*(@month)\s*\|[ ]*year=[ ]*(@MMyyyy[-–\/\. ]*)(?=[|}\s]@YYYY)/gi, "$1@Day @Month$2 @YYYY$3");
.ohc_regex(/(\|\s[ ]*(?:publication|archive|access|air|)-?date\s[ ]*=\s[ ]*)@DD[-–\/\day.=?@month)\s*\|[ ]*year=[ ]*(@Monyyyy[-–\/\. ]*)(?=[|}\s]@YYYY)/gi, "$1@Day @Month @YYYY$2");
.ohc_regex(/(\|[ ](?:Accessed|Retrieved)(?:(?:*date[ online|) on|:?)]*=[ ]*@DD[-–\/\month.=?@day)\s*\|[ ]*year=[ ]*(@MMyyyy[-–\/\.=\s ]@YYYY*)(?=[|}\Ds])/gi, "$1 Retrieved @Day @Month @YYYY$2");
ohc_regex(/[ ](?:Accessed|Retrieved)(?:(?: online|) on|:?)[ ]@YYYY,? @Month @DD(?=\D)/gi, " Retrieved @Day @Month @YYYY");
ohc_regex(/([ =|])@DD[-–]@Mon[-–]@YYYY(?=[^-–\d/])/gi, "$1@Day @Month @YYYY");
ohc_regex(/([ =|])@DD\/@Mon\/@YYYY(?=[^-–\d/])/gi, "$1@Day @Month @YYYY");
ohc_regex(/([ =|])@DD\.@Mon\.@YYYY(?=[^-–\d/])/gi, "$1@Day @Month @YYYY");
ohc_regex(/([ =|])@DD @Mon @YYYY(?=[^-–\d/])/gi, "$1@Day @Month @YYYY");
ohc_regex(/([ =|])@DD[-–]@MM[-–]@YYYY(?=[^-–\d/])/gi, "$1@Day @Month @YYYY");
ohc_regex(/([ =|])@DD\/@MM\/@YYYY(?=[^-–\d/])/gi, "$1@Day @Month @YYYY");
ohc_regex(/([ =|])@DD\.@MM\.@YYYY(?=[^-–\d/])/gi, "$1@Day @Month @YYYY");
ohc_regex(/([ =|])@DD @MM @YYYY(?=[^-–\d/])/gi, "$1@Day @Month @YYYY");
ohc_regex(/(\|\s*(?:publication|archive|access|air|)-?date\s*=\s*)@DD[-–\/\.=\s]@Month[-–\/\.=\s]@YYNN(?=\s*[|}\n])/gi, '$1@Day @Month @YYYY');
// eliminating dates and time placed in author parameter
//convert yyyy-dd-mm to yyyy-mm-dd
// removing artefacts from Indian news sites (TNN Aug 30, 2012, 05.46AM)
ohc_regex(/{{(\s*[Cc]it(?:e|ation))([^}]+)(\s*\|\s*(?:publication|archive|access|air|)-?date\s*=\s*(?:1[0-9]|20)\d{2})[-/\.=\s](1[3-9]|2\d|3[01])[-/\.=\s](0?\d|1[0-2])(\s*[\|}<])/gi, '{{$1$2$3-$5-$4$6'); //from Batty
.ohc_regex(/(\|\s*author\s*=\s*(?:[A-Z]{2,3}\b))(?:[^|}]*)\d{4}, [\d\.:]{4,5}( |)[AP]M IST(?=[ ]*\|)/g, "$1$2")
//.ohc_regex(/(\|\s*author=(?:[^\[\]|{}]*))(TNN|PTI) @day @month @yyyy, [\d\.:]{4,5}( |)[AP]M IST(?=[ ]*\|)/g, "$1$2")
.ohc_regex(/(\|\s*author\s*=\s*)@month @day,? @yyyy\s?(?:,? [0-2]?\d[\.:][0-5]\d(?:\s*| )(?:[apAP][mM]\s*|)(?:GMT\s*|UTC\s*|[A-Z]{1,2}[DS]T\s*|)|)(?=\|)/g, "$1")
// eliminating other errant formats
.ohc_regex(/(\|(?:[\w ]s*)dateauthor\s*=\s*)@day @month,? @yyyy\s?(?:,? [0-2]?\d[\.:][0-5]\d(?:\s*|30|31 ) @Month \2,(? @YYYY:[apAP][mM]\s*|)(?=:GMT\s*[|UTC\s*|[A-Z]{1,2}[DS]T\s*|)|)(?=\|)/gig, "$1$2 @Month @YYYY"); //repeated digits
.ohc_regex(/(\|\s*(?:publication|archive|access|air|)-?dateauthor\s*=\s*\w[\w\s]+)@Daymonth @day,?@Month ?200@yyyy(?:[01]^\d)[^\s]|{}]?*)(?=\s*[|}])/gig, "$1@Day @Month 20$2");
.ohc_regex(/(\|\s*(?:publication|archive|access|air|)-?dateauthor\s*=\s*\w[\w\s]+)@Monthday ?@Daymonth,? ?200@yyyy(?:[01]^\d)[^\s]|{}]?*)(?=\s*[|}])/gig, "$1@Month @Day, 20$2");
.ohc_regex(/(\|\s*author\s*=\s*(?:\w[\w\s]+)?)@dd-@mm-@yyyy/gi, "$1")
.ohc_regex(/(\|\s*author\s*=\s*(?:\w[\w\s]+)?)@YYYY-@MM-@DD ?/gi, "$1")
.replace(/(\|\s*(?:date|archive-?date|access-?date|author)\s*=\s*(?:\w[\w\s]+)?)[0-2]\d:[0-5]\d(?:[ ]| )?(?:[ap]m|[ap]\.m\.|)(?: ?(?:[A-Z]{1,2}T|UTC)[\.,]?|)/gi, "$1")
//.ohc_regex(/(\|\s*author\s*=\s*(?:\w[\w\s]+)?)\s*[0-2]\d[\.:][0-5]\d(?:[\.:][0-5]\d|)/gi, "$1") //let's see later if we need this
// eliminating mm-dd-yyyy dates
ohc_regex(/([ ]\()@DD-@MM-@YYYY(\)\W)/gi, '$1@Day @Month @YYYY$2');
.ohc_regex(/([ ]\|\s*(?:publication|archive|access|air|)@DD-?date\s*=\s*)@MonthMM[-@YYYY–\/\.=\s](1[3-9]|2\d|3[01])[-–\W)/\.=\s]@YYYY/gi, '"$1@Day @Month @YYYY$2', @YYYY");
.ohc_regex(/(\|\s*(?:[\w ]*publication|archive|access|air|)-?date\s*=\s*)@Month, @DD, @YYYY(?Mon[-–\/\.=\s*](1[3-9]|}2\d|3[01])[-–\/\.=\s]@YYYY/gi, "$1@Day @Month $2, @YYYY");
.ohc_regex(/[ ](\?:Accessed|Retrieved)(?:(?: online|) on|:?)[\w ]*)date@MM[-–\s*/\.=\s*](1[3-9]|2\d|3[01])@DD[-–\/\.,=\s] @Month,? @YYYY(?=\s*[|}]D)/gi, "$1@Day Retrieved @Month $1, @YYYY");
//.ohc_regex(/[ ](\?:Accessed|Retrieved)(?:(?:[\w ]*online|)date\s*=\s* on|:?)[ ]@YYYY,? @Month @DD(?=\s*[|}]D)/gi, "$1 Retrieved @Day @Month @YYYY");
ohc_regex(/(\|(?:[\w ]*)date\s*=\s*)@YYYY,? @DD @Month(?=\s*[|}])/gi, "$1@Day @Month @YYYY");
ohc_regex(/[ ]\(@YYYY,? @Month @DD\)/gi, " (@Day @Month @YYYY)");
ohc_regex(/[ ]\(@YYYY @MM @DD\)/gi, " (@Day @Month @YYYY)");
ohc_regex(/[ ]\(@YYYY, @DD @Month\)/gi, " (@Day @Month @YYYY)");
ohc_regex(/(\|(?:[\w ]*)date\s*=\s*)@YYYY,? @Month(?=\s*[|}])/gi, "$1@Month @YYYY");
ohc_regex(/[ ]\(@YYYY, @Month\)/gi, " (@Month @YYYY)");
ohc_regex(/[ ]\(@Mon@YYYY\)/gi, " (@Mon @YYYY)");
.ohc_regex(/([ =|])@Mon[-–](1[3-9]|2\d|3[01])[-–]@YYYY(?=[^-–\d/])/gi, "$1@Mon $2, @YYYY")
//CS1 errors ISO-like dates (too few or too many digits)
.ohc_regex(/(date\s*[ =\s*|])(?:@Mon\[\[)?@YYYY/(?:\]\]1[–—‐3-9]|2\[\[d|3[–—‐01])@MM[\-–—‐]/@DD(?:\]\])?YYYY(?=[^-–\s*[|}d/])/gi, "$1@Mon $2, @YYYY-@ZM-@ZD"); //ndashes and emdashes
.ohc_regex(/(\[ =|])@Mon\s*access.(1[3-?date9]|2\s*=d|3[01])\s*.@YYYY-0[–—]@DD(?=\s*[|}^-–\d/])/gi, "");$1@Mon //rem$2, nonsense access date@YYYY")
.ohc_regex(/(\|(?:[\w =|]*)date\s*=\s*)@YYYYMon (1[3-–—9]@MM|2\d|3[-–—01]) @DDYYYY(?=\s*[|}^-–\d/])/gi, "$1@Mon $2, @YYYY-@ZM-@ZD"); //ndashes and emdashes
// .ohc_regex(/(\[ =|])@MM[-–](?:1[3-9]|2\w d|3[01]*)date\s*=\s*)@YYYY[\-–—‐–]@MMYYYY(?=[^-–\s*[|}d/])/gi, "$1@MonthMon $2, @YYYY"); //transform "yyyy-mm" to "month year"
.ohc_regex(/(<ref[^> =|]*>[^<]+?)@MM\/(1[3-9]|2\s\(d|3[01])\/@YYYY[–—]@MM[–—]@DD(?=[^-–\w\d/%,<][^<]*?<\/ref>)/gi, "$1@Mon $2@Day @Month, @YYYY$3");
.ohc_regex(/(<ref[^> =|]*>[^<]+?)([\s@MM\.(])@YYYY1[3-9]@MM|2\d|3[-]([1-901])\.@YYYY(?=[^-–\w\d/%,<][^<]*?<\/ref>)/gi, "$1@Mon $2$3 @Month, @YYYY$4");
.ohc_regex(/([ =|])@MM (1[3-9]|2\d|3[01]) @YYYY(?=[^-–\d/])/gi, "$1@Mon $2, @YYYY")
// eliminating dd-mm-yyyy dates (assumed default)
// spaces and commas between month and year
.ohc_regex(/@Month(?:,?\|\s+of*(?:publication|archive|access|air|)(-?date\s| *=\s*)@YYYY(?DD[-–\/\.=\D)s]@MM[-–\/\.=\s]@YYYY/gi, "@LMonth$1@Day @Month @YYYY");
.ohc_regex(/(\|\s*(?:publication|archive|access|air|)-?date\s*=\s*)@DD[-–\/\.=\s]@Mon[-–\/\.=\s]@YYYY/gi, "$1@Day @Month @YYYY")
.ohc_regex(/[ ](?:Accessed|Retrieved)(?:(?: online|) on|:?)[ ]@DD[-–\/\.=\s]@MM[-–\/\.=\s]@YYYY(?=\D)/gi, " Retrieved @Day @Month @YYYY")
.ohc_regex(/[ ](?:Accessed|Retrieved)(?:(?: online|) on|:?)[ ]@YYYY,? @Month @DD(?=\D)/gi, " Retrieved @Day @Month @YYYY")
.ohc_regex(/([ =|])@DD[-–]@Mon[-–]@YYYY(?=[^-–\d/])/gi, "$1@Day @Month @YYYY")
.ohc_regex(/([ =|])@DD\/@Mon\/@YYYY(?=[^-–\d/])/gi, "$1@Day @Month @YYYY")
.ohc_regex(/([ =|])@DD\.@Mon\.@YYYY(?=[^-–\d/])/gi, "$1@Day @Month @YYYY")
.ohc_regex(/([ =|])@DD @Mon @YYYY(?=[^-–\d/])/gi, "$1@Day @Month @YYYY")
.ohc_regex(/([ =|])@DD[-–]@MM[-–]@YYYY(?=[^-–\d/])/gi, "$1@Day @Month @YYYY")
.ohc_regex(/([ =|])@DD\/@MM\/@YYYY(?=[^-–\d/])/gi, "$1@Day @Month @YYYY")
.ohc_regex(/([ =|])@DD\.@MM\.@YYYY(?=[^-–\d/])/gi, "$1@Day @Month @YYYY")
.ohc_regex(/([ =|])@DD @MM @YYYY(?=[^-–\d/])/gi, "$1@Day @Month @YYYY")
.ohc_regex(/(\|\s*(?:publication|archive|access|air|)-?date\s*=\s*)@DD[-–\/\.=\s]@Month[-–\/\.=\s]@YYNN(?=\s*[|}\n])/gi, "$1@Day @Month @YYYY")
//convert yyyy-dd-mm to yyyy-mm-dd
// fix month names (capitalize, remove dots)
.ohc_regex(/{{(\s*[Cc]it(?:e|ation))([^}]+)(\s*\|\s*(?:publication|archive|access|air|)-?date\s*=\s*(?:1[0-9]|20)\d{2})[-/\.=\s](1[3-9]|2\d|3[01])[-/\.=\s](0?\d|1[0-2])(\s*[\|}<])/gi, "{{$1$2$3-$5-$4$6") // from Batty
ohc_regex(/(\W)@DD\s@FullMonth(\s+|\s*,)/gi, "$1@Day @FullMonth$2");
ohc_regex(/(\W)@DD\s@Mon(\s+|\s*,)/gi, "$1@Day @Mon$2");
ohc_regex(/(\W)@FullMonth\s@DD(\s+|\s*,)/gi, "$1@FullMonth @Day$2");
ohc_regex(/(\W)@Mon\s@DD(\s+|\s*,)/gi, "$1@Mon @Day$2");
regex(/(\d(?:st|nd|rd|th) )C(entur(?:ies|y))(?=[ ]*(=|BC|AD|CE))/g, '$1c$2');
// regex(/(\d(?:st|nd|rd|th) )C(entur(?:ies|y))(?![ \-][A-Z]\w*|''|")/g, '$1c$2');
//spaces andeliminating commasother - in dateerrant formats
.ohc_regex(/(\D\W\|(?:[?\[?@dd)[w ]+(@month*)(date\]s*=\]s*)?([ 0-2]*,[ ]*(\[?\[?@yyyy(\sADd|\sBC|\sCE|\sBCE30|31) @Month \]2,? @YYYY(?=\s*[|}]?\W\D)/gi, "$1 $2$3 $4@Month @YYYY"); //repeated digits
.ohc_regex(/(\D|\W\[s*(?:publication|archive|access|air|)-?date\[?s*=\s*)(@month)[Day ]+(?@dd)Month ?200(\[01]?\]?d)(?:[ ^\s|}]*,[ ]*)?(\[?=\s*[?@yyyy(\sAD|\sBC|\sCE|\sBCE|)\}]?\]?\W\D)/gi, "$1$2@Day $3$4,@Month 20$52");
.ohc_regex(/(\D|\W\[s*(?\[:publication|archive|access|air|)-?date\s*=\s*)(@month)[Month ]+(?@dd)Day,? ?200(\[01]?\]?d)[ ^\s|}]+?(\[?=\s*[?@yyyy(\sAD|\sBC|\sCE|\sBCE|)\}]?\]?\W\D)/gi, "$1$2@Month $3$4@Day, 20$52");
.ohc_regex(/(@month)[ ]\(?:, | of )@DD-@MM-@YYYY(@yyyy\w)\W)/gi, "$1@Day @Month @YYYY$2"); //repeat after delinking
.ohc_regex(/([ ]\()@DD-@Month-@YYYY(\)\W)/gi, "$1@Day @Month @YYYY$2")
.ohc_regex(/(\|(?:[\w ]*)date\s*=\s*)@Month, @DD, @YYYY(?=\s*[|}])/gi, "$1@Day @Month @YYYY")
.ohc_regex(/(\|(?:[\w ]*)date\s*=\s*)@DD[\.,] @Month,? @YYYY(?=\s*[|}])/gi, "$1@Day @Month @YYYY")
.ohc_regex(/(\|(?:[\w ]*)date\s*=\s*)@YYYY,? @Month @DD(?=\s*[|}])/gi, "$1@Day @Month @YYYY")
.ohc_regex(/(\|(?:[\w ]*)date\s*=\s*)@YYYY,? @DD @Month(?=\s*[|}])/gi, "$1@Day @Month @YYYY")
.ohc_regex(/[ ]\(@YYYY,? @Month @DD\)/gi, " (@Day @Month @YYYY)")
.ohc_regex(/[ ]\(@YYYY @MM @DD\)/gi, " (@Day @Month @YYYY)")
.ohc_regex(/[ ]\(@YYYY, @DD @Month\)/gi, " (@Day @Month @YYYY)")
.ohc_regex(/(\|(?:[\w ]*)date\s*=\s*)@YYYY,? @Month(?=\s*[|}])/gi, "$1@Month @YYYY")
.ohc_regex(/[ ]\(@YYYY, @Month\)/gi, " (@Month @YYYY)")
.ohc_regex(/[ ]\(@Mon@YYYY\)/gi, " (@Mon @YYYY)")
// CS1 errors ISO-like dates (too few or too many digits)
// spaces and commas - md-md and dm-dm date ranges
.ohc_regex(/(date\Ds*=\Ws*)@Month\s@DD( |?:\s[\[)?@YYYY(?:\]\][-–—–—‐]\[\[|&[mn–—‐]dash;)@MM[\-–—‐]@DD(?: |\s]\])?@Month\s@DD(?=\W\Ds*[|}])/gi, "$1@LMonth1 YYYY-@Day1$2– ZM-@LMonth2 @Day2ZD"); //ndashes and emdashes
.ohc_regex(/(\D\W)@Month|\s@DD(?:[*access-–—]|&[mn]dash;)(?: |date\s*=)?@Month\s*@YYYY-0[–—]@DD(?=\W\Ds*[|}])/gi, "$1@LMonth1") @Day1//rem –nonsense @LMonth2access @Day2");date
.ohc_regex(/(\D|(?:[\Ww ]*)@DDdate\s@Month( |*=\s*)(?:@YYYY[-–—]|&@MM[mn-–—]dash;)(?: |\s)?@DD\s@Month(?=\W\Ds*[|}])/gi, "$1@Day1 YYYY-@LMonth1$2– @Day2 ZM-@LMonth2ZD"); //ndashes and emdashes
//.ohc_regex(/(\D\W)@DD\s@Month|(?:[-–—]|&[mn\w ]dash;*)(?: |date\s*=\s*)?@DDYYYY[\s-–—‐]@MonthMM(?=\W\Ds*[|}])/gi, "$1@Day1Month @LMonth1YYYY") –//transform @Day2"yyyy-mm" to @LMonth2");month year"
.ohc_regex(/(<ref[^>]*>[^<]+?)([\s\(])@YYYY[–—]@MM[–—]@DD([^-\w\/%,<][^<]*?<\/ref>)/gi, "$1$2@Day @Month @YYYY$3")
.ohc_regex(/(<ref[^>]*>[^<]+?)([\s\(])@YYYY[-]@MM[-]([1-9])([^-\w\/%,<][^<]*?<\/ref>)/gi, "$1$2$3 @Month @YYYY$4")
// spaces and commas -between d-dmmonth and md-d date rangesyear
.ohc_regex(/(\D\W)@Month(\s| )@DD@th?(?:(,?:|\s*| +of|)[-–](?:\s*| |))@DD@th?YYYY(?=\W\D)/gi, "@LMonth$1@LMonth1$2@Day1–@Day2YYYY");
ohc_regex(/(\D\W)@DD@th?(?:(?:\s*| |)[-–](?:\s*| |))@DD@th?(\s| )@Month(?=\W\D)/gi, "$1@Day1–@Day2$2@LMonth1");
// fix month names (capitalize, remove dots)
//reformat dmy-dmy and mdy-mdy (birth-death ranges)
// .ohc_regex(/(\D\W)@DD\s@Month,? @YearFullMonth( |\s)(?:(?:[-–—]|&[mn]dash;)(?: +|\s)?)@DD\s@Month*,? @Year(?=\D\W)/gi, "$1@Day1Day @LMonth1 @Year1FullMonth$2– @Day2 @LMonth2 @Year22");
// .ohc_regex(/(\D\W)@MonthDD\s@DD,? @YearMon( |\s)(?:(?:[-–—]|&[mn]dash;)(?: +|\s)?)@Month\s@DD*,? @Year(?=\D\W)/gi, "$1@LMonth1Day @Day1, @Year1Mon$2– @LMonth2 @Day2, @Year22");
// .ohc_regex(/(\D\W)@DDFullMonth\s@Month,? @YearDD(?:,?(?:[-–—]|&[mn]dash;)(?: |\s)?)@DD+|\s@Month*,? @Year(?=\D\W)/gi, "$1@Day1FullMonth @LMonth1 @Year1 – @Day2 @LMonth2 @Year2Day$2");
// .ohc_regex(/(\D\W)@MonthMon\s@DD,? @Year(?:,?(?:[-–—]|&[mn]dash;)(?: |\s)?)@Month+|\s@DD*,? @Year(?=\D\W)/gi, "$1@LMonth1Mon @Day1, @Year1 – @LMonth2 @Day2, @Year2Day$2");
.replace(/(\d(?:st|nd|rd|th) )C(entur(?:ies|y))(?=[ ]*(=|BC|AD|CE))/g, "$1c$2")
//.replace(/(\d(?:st|nd|rd|th) )C(entur(?:ies|y))(?![ \-][A-Z]\w*|''|")/g, "$1c$2")
//spaces and commas - in date formats
//nbsp in publication archive & access dates
// .ohc_regex(/(\|D\sW\[?\[?@dd)[ ]+(@month)(\]\])?[ ]*,[ ]*(\[?:publication\[?@yyyy(\sAD|archive\sBC|access\sCE|air\sBCE|)-\]?date\s*=]?\s*@dd) (@monthW\D)/gi, '"$1 $2'$3 $4");
// .ohc_regex(/(\|D\s*(W\[?:publication|archive|access|air|)-?date\s*=\s*[?)@Month @DD(,@month)[ ]+(@yyyy|dd)(\]?=\]?)(?:[ ]*,[ ]*)(\[?\[?@yyyy(\sAD|}\sBC|\sCE|\sBCE|)\]?\]?\W\D)/gi, '"$1@Month $2' $3$4, $5");
.ohc_regex(/(\D\W\[?\[?)(@month)[ ]+(@dd)(\]?\]?)[ ]+(\[?\[?@yyyy(\sAD|\sBC|\sCE|\sBCE|)\]?\]?\W\D)/gi, "$1$2 $3$4, $5")
.ohc_regex(/(@month)(?:, | of )(@yyyy\w)/gi, "$1 $2") //repeat after delinking
// spaces and commas between month and year (again)
ohc_regex(/@Month(?:,\s+|\s+of\s+)@YYYY(\w)/gi, "@LMonth @YYYY$1");
// spaces and commas - md-md and dm-dm date ranges
.ohc_regex(/(\D\W)@Month\s@DD( |\s)(?:[-–—]|&[mn]dash;)(?: |\s)?@Month\s@DD(?=\W\D)/gi, "$1@LMonth1 @Day1$2– @LMonth2 @Day2")
.ohc_regex(/(\D\W)@Month\s@DD(?:[-–—]|&[mn]dash;)(?: |\s)?@Month\s@DD(?=\W\D)/gi, "$1@LMonth1 @Day1 – @LMonth2 @Day2")
.ohc_regex(/(\D\W)@DD\s@Month( |\s)(?:[-–—]|&[mn]dash;)(?: |\s)?@DD\s@Month(?=\W\D)/gi, "$1@Day1 @LMonth1$2– @Day2 @LMonth2")
.ohc_regex(/(\D\W)@DD\s@Month(?:[-–—]|&[mn]dash;)(?: |\s)?@DD\s@Month(?=\W\D)/gi, "$1@Day1 @LMonth1 – @Day2 @LMonth2")
// spaces and commas - d-dm and md-d date ranges
.ohc_regex(/(\D\W)@Month(\s| )@DD@th?(?:(?:\s*| |)[-–](?:\s*| |))@DD@th?(?=\W\D)/gi, "$1@LMonth1$2@Day1–@Day2")
.ohc_regex(/(\D\W)@DD@th?(?:(?:\s*| |)[-–](?:\s*| |))@DD@th?(\s| )@Month(?=\W\D)/gi, "$1@Day1–@Day2$2@LMonth1")
// spaces and commas between month and year (again)
.ohc_regex(/@Month(?:,\s+|\s+of\s+)@YYYY(\w)/gi, "@LMonth @YYYY$1");
}
/// ISO to long format
function ohc_ISO_to_dmy_in_citations(editor) {
editor
{
// ISO dates within single citation
.ohc_regex(/(\|\s*(?:publication|archive|access|air|designation\d?_|)-?date\s*=\s*)@YYYY[-–]@MM[-–]@DD(?=\W\D)/gi, "$1@Day @Month @YYYY"); //regex which converts ymd to dmy or mdy throughout (within citation templates)
// .ohc_regex(/(\|\s*(?:publication|)-?date\s*=\s*)@YYYY[-–]@MM[-–]@DD(?=\W\D)/gi, "$1@Day @Month @YYYY");
}
function ohc_ISO_to_mdy_in_citations(editor) {
editor
{
// ISO dates within single citation
.ohc_regex(/(\|\s*(?:publication|archive|access|air|designation\d?_|)-?date\s*=\s*)@YYYY[-–]@MM[-–]@DD(?=\W\D)/gi, "$1@Month @Day, @YYYY"); //regex which converts ymd to dmy or mdy throughout (within citation templates)
// .ohc_regex(/(\|\s*(?:publication|)-?date\s*=\s*)@YYYY[-–]@MM[-–]@DD(?=\W\D)/gi, "$1@Month @Day, @YYYY");
}
function ohc_ISO_to_dmy_in_references(editor) {
editor
{
// multiple calls for multiple dates within single citation
.ohc_regex(/(<ref[^>]*>[^<]+?)([\s\(])@YYYY[-–]@MM[-–]@DD([^-\w\/%,<][^<]*?<\/ref>)/gi, "$1$2@Day @Month @YYYY$3");
// .ohc_regex(/(<ref[^>]*>[^<]+?)([\s\(])@YYYY[-–]@MM[-–]@DD([^-\w\/%,<][^<]*?<\/ref>)/gi, "$1$2@Day @Month @YYYY$3");
ohc_regex(/(<ref[^>]*>[^<]+?)([\s\(])@YYYY[-–]@MM[-–]@DD(<\/ref>)/gi, "$1$2@Day @Month @YYYY$3");
}
function ohc_ISO_to_mdy_in_references(editor) {
editor
{
// multiple calls for multiple dates within single citation
.ohc_regex(/(<ref[^>]*>[^<]+?)([\s\(])@YYYY[-–]@MM[-–]@DD([^-\w\/%,<][^<]*?<\/ref>)/gi, "$1$2@Month @Day, @YYYY$3");
// .ohc_regex(/(<ref[^>]*>[^<]+?)([\s\(])@YYYY[-–]@MM[-–]@DD([^-\w\/%,<][^<]*?<\/ref>)/gi, "$1$2@Month @Day, @YYYY$3");
ohc_regex(/(<ref[^>]*>[^<]+?)([\s\(])@YYYY[-–]@MM[-–]@DD(<\/ref>)/gi, "$1$2@Month @Day, @YYYY$3");
}
// currently unused
function ohc_ISO_to_dmy_anywhere(editor) {
editor
{
// multiple calls for multiple dates within single citation
.ohc_regex(/([^-\w/])@YYYY[-–]@MM[-–]@DD([^-\w/])/gi, '"$1@Day @Month @YYYY$2'");
.ohc_regex(/([^-\w/])@YYYY[-–]@MM[-–]@DD([^-\w/])/gi, '"$1@Day @Month @YYYY$2'");
.ohc_regex(/([^-\w/])@YYYY[-–]@MM[-–]@DD([^-\w/])/gi, '"$1@Day @Month @YYYY$2'");
}
// currently unused
function ohc_ISO_to_mdy_anywhere(editor) {
editor
{
// multiple calls for multiple dates within single citation
.ohc_regex(/([^-\w/])@YYYY[-–]@MM[-–]@DD([^-\w/])/gi, '"$1@Month @Day, @YYYY$2'");
.ohc_regex(/([^-\w/])@YYYY[-–]@MM[-–]@DD([^-\w/])/gi, '"$1@Month @Day, @YYYY$2'");
.ohc_regex(/([^-\w/])@YYYY[-–]@MM[-–]@DD([^-\w/])/gi, '"$1@Month @Day, @YYYY$2'");
}
function ohc_delink_ISO_to_dmy(editor) {
ohc_ISO_to_dmy_in_citations(editor);
{
ohc_ISO_to_dmy_in_references(editor);
ohc_ISO_to_dmy_in_citations();
ohc_ISO_to_dmy_in_references();
editor
regex(/([^\w\/\-%,])@YYYY-@MM-@DD(<\s?\/ref.*?>)/g, '$1@Day @Month @Year$2');
ohc_regex .replace(/([^\|w\/\|[ -%,]*)@YYYY[-–]@MM[-–]@DD([ ]*<\|s?\|/ref.*?>)/gig, '"$1{{dts|format=dmy|@YYYY|Day @MM|Month @DD}}Year$2'"); //dts template for sortable tables
.ohc_regex(/(\{\{dts|\|format=[ ]*)mdy@YYYY[-–]@MM[-–]@DD([ ]*\|\|)/gi, '"$1dmy1{{dts|'format=dmy|@YYYY|@MM|@DD}}$2"); //flip dts template formatsfor sortable tables
.ohc_regex(/(\{\{dts\|format=)mdy\|/gi, "$1dmy|"); //flip dts template formats
}
function ohc_delink_ISO_to_mdy(editor) {
ohc_ISO_to_mdy_in_citations(editor);
{
ohc_ISO_to_mdy_in_references(editor);
ohc_ISO_to_mdy_in_citations();
ohc_ISO_to_mdy_in_references();
editor
regex(/([^\w\/\-%,])@YYYY-@MM-@DD(<\s?\/ref.*?>)/g, '$1@Month @Day, @Year$2');
.replace(/([^\w\/\-%,])@YYYY-@MM-@DD(<\s?\/ref.*?>)/g, "$1@Month @Day, @Year$2") .ohc_regex(/(\|\|[ ]*)@YYYY[-–]@MM[-–]@DD([ ]*\|\|)/gi, '"$1{{dts|@YYYY|@MM|@DD}}$2'"); // dts template for sortable tables (mdy is default)
.ohc_regex(/(\{\{dts\|)format=(?:mdy|dmy|) ?\|/gi, '"$1'"); // flip dts template formats
}
function ohc_delink_year_in_X(editor) {
editor
{
//.ohc_regex(/\{\{(?:avyear|by|baseball\syear|fy|ly|mlby|mlb\syear|scy|sdy)\|(@year)\}\}/gi, "$1"); // disabled 3/5/21 discussion at https://en.wikipedia.org/w/index.php?title=Wikipedia_talk:WikiProject_Baseball&oldid=1021203365#Links_to_baseball_year_articles_in_infobox?
//.ohc_regex(/\{\{(?:avyear|by|baseball\syear|fy|ly|mlby|mlb\syear|scy|sdy)\|@year\|(@year)\}\}/gi, "$1");
.ohc_regex(/\[\[@yyyy\sin\s[^|\]]+\|((?:(?:@day |)@month |)@yyyy)\]\]/gi, '"$1'");
regex .replace(/\[\[(?:\d{4}[-–]\d{2} in English football)\|((?:(?:@Day |)@Month |)@YYYY)\]\]/gi, '"$1'");
regex .replace(/\[\[\d{4} Major League Baseball season\|(\d{4})(\sseason)?\]\]/gi, '"$1$2'");
}
// format parameter must be 'dmy' or 'mdy'
function ohc_fix_dts_template(editor, format) {
editor
{
// dts - format=dmy in this case (per D12000)
// per {{dts}} doc, remove the obsolete link=off param
regex .replace(/(\{\{dts[^}]*)(?:\|link=off)/gi, '"$1'");
.ohc_regex(/(\{\{dts\s*\|\s*@year\s*\|\s*@month\s*\|\s*@day\s*\|\s*format=)(?:dmy|mdy)(\}\})/gi, '"$1'"+format+'"$2'");
.ohc_regex(/(\{\{dts\s*\|\s*format=)(?:dmy|mdy)(\s*\|\s*@year\s*\|\s*@month\s*\|\s*@day\s*\}\})/gi, '"$1'"+format+'"$2'");
.ohc_regex(/(\{\{dts\s*\|\s*@year\s*\|\s*@month\s*\|\s*@day\s*)(\}\})/gi, '"$1|format='"+format+'"$2'");
// stripping – {{dts}} serves no purpose inside date parameters
.ohc_regex(/(\|(?:[\w ]*)date\s*=\s*)\{\{dts\s*\|\s*format=(?:dmy|mdy)\s*\|\s*([|}]*)\}\}(?=\s*[|}])/gi, "$1$2");
.ohc_regex(/(\|(?:[\w ]*)date\s*=\s*)\{\{dts\s*\|\s*([|}]*)(?:\|\s*format=(?:dmy|mdy)\s*|)\}\}(?=\s*[|}])/gi, "$1$2");
.ohc_regex(/(\|(?:[\w ]*)date\s*=\s*)\{\{dts\s*\|\s*format=(?:dmy|mdy)\s*\|\s*@YYYY(\s*\|\s*|-)@MM(\s*\|\s*|-)@DD\s*\}\}(?=\s*[|}])/gi, "$1@YYYY-@MM-@DD ");
.ohc_regex(/(\|(?:[\w ]*)date\s*=\s*)\{\{dts\s*\|\s*@YYYY(\s*\|\s*|-)@MM(\s*\|\s*|-)@DD\s*\|\s*format=(?:dmy|mdy)\s*\}\}(?=\s*[|}])/gi, "$1@YYYY-@MM-@DD ");
}
// format parameter must be 'dmy' or 'mdy'
function ohc_fix_gr_template(editor, format) {
editor
{
// GR - date formatting parameter
// per {GR} doc, insert date formatting param
regex .replace(/(\{\{GR\|\d\d?)(?!\|date)/gi, '"$1|dateform='" + format);
}
function ohc_dates_to_dmy(editor) {
editor
{
regex .replace(/\|df=[mdy]{3}(?:-all|)(?=\s*[|}])/gi, '');
regex .replace(/\|format=mdy/gi, '"|format=dmy'");
//change start and end templates; vgrelease new v=2 or mdy is default
regex(/(\{\{(?:start date|end date)[^|}]*\|)df=ye?s?\|([^}]*df=ye?s?)/gi, '$1$2');
regex(/(\{\{vgrelease new[^|}]*\|)(?:v=1\||)([A-Z]{2,3}\|)/g, '$1v=2|$2');
ohc_regex(/(\|\s*(?:begin|end|first|last)\s*=\s*)@YYYY[-–]@MM[-–]@DD(?=\W\D)/gi, "$1@Day @Month @YYYY"); //spotted at [[Template:Infobox recurring event]]
//change birth and death templates
regex(/(\{\{(?:(?:Birth|Death) date(?: and age|)|launch|release|start)[^}]*\|)m(f=ye?s?)/gi, '$1d$2'); // substitute df for mf
regex(/(\{\{(?:(?:Birth|Death) date(?: and age|)|launch|release|start|film ?date|Wayback)[\|\d]+)(\}\})/gi, '$1|df=y$2'); //insert df parameter
regex(/(\{\{(?:(?:Birth|Death) date(?: and age|)|launch|release|start|film ?date|Wayback)[\|\d]+\|)df=ye?s?\|([^}]*df=ye?s?)/gi, '$1$2'); //put date format parameter at the end
regex(/(\{\{(?:start date|end date)\|)df=ye?s?\|((?:1[789]|20)\d{2}\}\})/gi, '$1$2'); //date format parameter not needed – year only
// change start and end templates; vgrelease new v=2 or mdy is default
//convert date ranges (md,d,d-dy to d,d,d-dmy; md,d,d-d to d,d,d-dm; md,d,d to d,d,dm)
.replace(/(\{\{(?:start date|end date)[^|}]*\|)df=ye?s?\|([^}]*df=ye?s?)/gi, "$1$2")
ohc_regex(/(\D\W)@Month((?:\s@day?,?){1,6}),?(\/|\s?(?:[-–]|–)\s?|(?:[ _]| )(?:and|&|to|or)(?:[ _]| )+?)@Day,?\s(?:of\s)?(@yyyy\W\D)/gi, "$1$2$3@Day @LMonth $4");
.replace(/(\{\{vgrelease new[^|}]*\|)(?:v=1\||)([A-Z]{2,3}\|)/g, "$1v=2|$2")
ohc_regex(/(\D\W)@Month((?:\s@day?,?){1,6}),?(\/|\s?(?:[-–]|–)\s?|(?:[ _]| )(?:and|&|to|or)(?:[ _]| )+?)@Day(?=\W\D)/gi, "$1$2$3@Day @LMonth");
.ohc_regex(/(\|\s*(?:begin|end|first|last)\s*=\s*)@YYYY[-–]@MM[-–]@DD(?=\W\D)/gi, "$1@Day @Month @YYYY") // spotted at [[Template:Infobox recurring event]]
// change birth and death templates
// ohc_regex(/(\D\W)@Month((?:\s@day?,?){1,6}) @Day(?=\W\D)/gi, "$1$2 @Day @LMonth"); //disabling as unlikely and ungrammatical constructions causing false positives
.replace(/(\{\{(?:(?:Birth|Death|Disappeared) date(?: and (?:given |)age|)|launch|release|start)[^}]*\|)m(f=ye?s?)/gi, "$1d$2") // substitute df for mf
.replace(/(\{\{(?:(?:Birth|Death|Disappeared) date(?: and (?:given |)age|)|launch|release|start|film ?date|Wayback)[\|\d]+)(\}\})/gi, "$1|df=y$2") // insert df parameter
.replace(/(\{\{(?:(?:Birth|Death|Disappeared) date(?: and (?:given |)age|)|launch|release|start|film ?date|Wayback)[\|\d]+\|)df=ye?s?\|([^}]*df=ye?s?)/gi, "$1$2") // put date format parameter at the end
.replace(/(\{\{(?:start date|end date)\|)df=ye?s?\|((?:1[789]|20)\d{2}\}\})/gi, "$1$2") // date format parameter not needed – year only
//' convert date ranges (md,d,d-dy to d,d,d-dmy; md,'d,d-d to 'd,d,d-dm; md,d,d dmto d,'d,dm)
.ohc_regex(/(\D\W)@Month ((?:\s@Dayday?,?){1,6}),?(\/|\s?(?:[-–]|–)\s?|(?:[ @Month_]| )(?:and|&|to|or)(?:[ _]| )+?)@Day,?\s(?=[,:of\.]s)?(@yyyy\W\D)/gi, "$1$2$3@Day1Day @LMonth1,LMonth @Day2 @LMonth2$4");
.ohc_regex(/(\D\W)@Month((?:\s@day?,?){1,6}),?(\/|\s?(?:[-–]|–)\s?|(?:[ _]| )(?:and|&|to|or)(?:[ _]| )+?)@Day(?=\W\D)/gi, "$1$2$3@Day @LMonth")
//.ohc_regex(/(\D\W)@Month((?:\s@day?,?){1,6}) @Day(?=\W\D)/gi, "$1$2 @Day @LMonth") //disabling as unlikely and ungrammatical constructions causing false positives
//convert simple mdy dates to dmy
ohc_regex(/(p(?:g?\.?|age) ?\d+|p(?:p\.?|ages) ?\d+[-–]\d+), @Month((?:\s@day?,?){1,6}) @Day(?=\W\D)/gi, "$1. $2 @Day @LMonth");
ohc_regex(/(\D\W)@Month\s@Day,?\s@Year(\s?(?:AD|BC|CE|BCE)\W\D)/gi, "$1@Day @LMonth @Year$2");
ohc_regex(/(\|\s*term_(?:end|start)\d\s*=\s*|\D\W)@Month\s@Day,?\s@YYYY(?=\W\D)/gi, "$1@Day @LMonth @Year");
ohc_regex(/(\|\s*term_(?:end|start)\d\s*=\s*|\D\W)@Month\s@Day(?=\W\D)/gi, "$1@Day @LMonth");
//'md, md,' to 'dm, dm,'
//Month+day_number " 7th March" -> "7 March"
.ohc_regex(/(\D\W)@Month @Day\s, @Month\s @YYYYDay(?=[,\.]\W\D)/gi, "$1@DayDay1 @LMonth1, @LMonthDay2 @YearLMonth2");
ohc_regex(/(\D\W)@Day\s@Month(?=\W\D)/gi, "$1@Day @LMonth");
ohc_regex(/(\D\W)@Month\s@Day,?\s@Year(?=\W\D)/gi, "$1@Day @LMonth @Year");
//convert simple mdy dates to dmy
//dates with embedded nbsp
.ohc_regex(/(p(?:g?\D\W.?|age)@Month([ _]| )(?\d{1,2},+|p(?: p\.?| ages) ?\d+[-–]\d{1+),2} @Month((?:\s(@day?:and|&|to|or)(,?:[ _]| ))\d{1,26}) @Day(?=[^|\]W\w]D)/gi, '"$1$3. $2 @LMonthDay '@LMonth");
.ohc_regex(/(\D\W)@Month([ _]| |{{(?:break|nbsp)}})\s@Day,?\s@Year([ _]| |{{\s?(?:breakAD|nbspBC|CE|BCE)}})@YYYY(?=[^|\]W\w]D)/gi, '"$1@Day$2 @Month$3LMonth @Year'$2");
.ohc_regex(/(\|\s*term_(?:end|start)\d\s*=\s*|\D\W)@Month\s@Day,?\s@YYYY(?=\W\D)/gi, "$1@Day @LMonth @Year")
.ohc_regex(/(\|\s*term_(?:end|start)\d\s*=\s*|\D\W)@Month\s@Day(?=\W\D)/gi, "$1@Day @LMonth")
//Month+day_number " 7th March" -> "7 March"
//remove comma
.ohc_regex(/(\D\W)@Day\s@Month,\s?@YearYYYY(?=\W\D)/gi, "$1@Day @LMonth @Year");
.ohc_regex(/(\D\W)@Day\s@Month(?=\W\D)/gi, "$1@Day @LMonth")
.ohc_regex(/(\D\W)@Month\s@Day,?\s@Year(?=\W\D)/gi, "$1@Day @LMonth @Year")
//dates with embedded nbsp
// remove "the" from "on the dd month"
.ohc_regex(/(on\D\W)@Month([ _]|by )the(\d{1,2},(?: @Day| )\d{1,2}(?:\s@Month(?=:and|&|to|or)(?:[ ,_]| ))\d{1,2})(?=[^|\.]\w])/gi, "$1@Day $3$2@LMonth ");
.ohc_regex(/(\D\W)@Month([ _]| |{{(?:break|nbsp)}})@Day,([ _]| |{{(?:break|nbsp)}})@YYYY(?=[^|\]\w])/gi, "$1@Day$2@Month$3@Year")
//remove space from date range conversioncomma
.ohc_regex(/(\D \W) @Day(\/|s@Month,\s?@Year(?:[-–]|–)=\W\s?|(?:[ _]| )(?:and|&|to|or)(?:[ _]| )+?D)/gi, "$1@Day$2 @LMonth @Year");
// remove "the" from "on the dd month"
.ohc_regex(/(on |by )the @Day\s@Month(?=[ ,\)\.])/gi, "$1@Day @LMonth")
//remove space from date range conversion
.ohc_regex(/(\D ) @Day(\/|\s?(?:[-–]|–)\s?|(?:[ _]| )(?:and|&|to|or)(?:[ _]| )+?)/gi, "$1@Day$2");
}
function ohc_dates_to_mdy(editor) {
editor
{
// change birth and death templates – mf=y is the default; vgrelease new v=2 or mdy is default
regex .replace(/\|df=[mdy]{3}(?:-all|)(?=\s*[|}])/gi, '');
regex .replace(/\|df=y(?:es|)(?=[|}\s])/gi, '');
regex .replace(/(mf=y(?:es|)\|[^}]*\|)(?:mf=y(?:es|)\|)/gi, '"$1'");
regex .replace(/(\{\{vgrelease new[^|}]*\|)(?:v=2\||)([A-Z]{2,3}\|)/g, '"$1$2'");
.ohc_regex(/(\|\s*(?:begin|end|first|last)\s*=\s*)@YYYY[-–]@MM[-–]@DD(?=\W\D)/gi, "$1@Month @Day, @YYYY");
// convert date ranges (d,d,d-dmy to md,d,d-dy; d,d,d-dm to md,d,d-d; dm,d,d to md,d,d)
.ohc_regex(/(\D\W)@Day((?:, @day){0,5})(\/|\s?(?:[-–]|–)\s?|\s(?:and|&|to|or)\s+?)@Day\s@Month,? @YYYY(?=\W\D)/gi, "$1@LMonth @Day1$2$3@Day2, @YYYY");
.ohc_regex(/(\D\W)@Day((?:, @day){0,5})(\/|\s?(?:[-–]|–)\s?|\s(?:and|&|to|or)\s+?)@Day\s@Month(?=\W\D)/gi, "$1@LMonth @Day1$2$3@Day2");
// .ohc_regex(/(\D\W)@Day((?:, @day){0,5})\s@Month,? @YYYY(?=\W\D)/gi, "$1@LMonth @Day1$2, @YYYY"); // disabling as unlikely and ungrammatical constructions causing false positives
// .ohc_regex(/(\D\W)@Day((?:, @day){0,5})\s@Month(?=\W\D)/gi, "$1@LMonth @Day1$2"); // disabling as unlikely and ungrammatical constructions causing false positives
// 'dm, dm,' to 'md, md,'
.ohc_regex(/(\D\W)@Day @Month, @Day @Month(?=[,\.]?\W\D)/gi, "$1@LMonth1 @Day1, @LMonth2 @Day2");
// convert simple dmy dates to mdy
.ohc_regex(/(p(?:g?\.?|age) ?\d+|p(?:p\.?|ages) ?\d+[-–]\d+), @Month((?:\s@day?,?){1,6}) @Day(?=\W\D)/gi, "$1. @LMonth $2 @Day");
.ohc_regex(/(\D\W)@Day(\s| )@Month,?(\s| )@Year(?=\W\D)/gi, "$1@LMonth$2@Day,$3@Year");
.ohc_regex(/(\|\s*term_(?:end|start)\d\s*=\s*|\D\W)@Day[ ]+@Month,?\s@YYYY(?=\W\D)/gi, "$1@LMonth @Day, @Year");
.ohc_regex(/(\|\s*term_(?:end|start)\d\s*=\s*|\D\W)@Day[ ]+@Month(?=\W\D)/gi, "$1@LMonth @Day");
// Month+day_number "March 7th" -> "March 7"
.ohc_regex(/(\D\W)@Month\s@Day@th?,?\s@YYYY(?=\W\D)/gi, "$1@LMonth @Day, @YYYY");
.ohc_regex(/(\D\W)@Day@th?(\s| )@Month(\s| )@YYYY(?=\W\D)/gi, "$1@LMonth$2@Day,$3@YYYY");
.ohc_regex(/(\D\W)@Month(\s| )@Day(?=\W\D)/gi, "$1@LMonth$2@Day");
.ohc_regex(/(\D\W)@Day@th?(\s| )@Month([,\.])(?=\W\D)/gi, "$1@LMonth$2@Day$3");
// add comma where missing
.ohc_regex(/(\D\W)@Month\s@Day,?\s@YYYY,?(?=\s@yyyy\W\Dw)/gi, "$1@LMonth @Day, @YYYY,");
//rem superfluous comma where applicable
// rem superfluous comma where applicable
ohc_regex(/(\D[^\w\/])@Month\s@ZD,,(?=\W\D|\b)/gi, "$1@LMonth @Day,");
.ohc_regex(/(\D[^\w\/])@Month\s@ZD,,(?=\W\D|\b)/gi, "$1@LMonth @Day,");
}
function ohc_fix_dmy_redundancies(editor) {
editor
{
// month-range redundancies (repeating month names)
.ohc_regex(/([\D]@dd)@th? @Month[ ]{1,2}((?:to|and|-|–)[ ]{1,2}@dd)@th? @Month/, "$1 $2 @LMonth", function(d1, d2) {
if (d1.m == d2.m) return true;
return false;
});
}
//not currently used
function ohc_fix_mdy_redundancies(editor) {
editor
{
// month-range redundancies (repeating month names)
.ohc_regex(/(@Month[ ]{1,2}@dd)@th? (to|and|-|–)[ ]{1,2}@Month[ ]{1,2}@DD@th?/, "$1 $2 @LDay", function(d1, d2) {
if (d1.m == d2.m) return true;
return false;
});
}
function ohc_expand_ref_dates(editor) {
editor
{
.ohc_regex(/(\|\s*(?:publication|archive|access|air|)-?date\s*=\s*)@Month @YYYY(?=\s*[|}])/gi, "$1@FullMonth @YYYY");
.ohc_regex(/(\|\s*(?:publication|archive|access|air|)-?date\s*=\s*)@Day @Month @YYYY(?=\s*[|}])/gi, "$1@Day @FullMonth @YYYY");
.ohc_regex(/(\|\s*(?:publication|archive|access|air|)-?date\s*=\s*)@Month @Day, @YYYY(?=\s*[|}])/gi, "$1@FullMonth @Day, @YYYY");
.ohc_regex(/(\|\s*(?:publication|archive|access|air|)-?date\s*=\s*)((?:[01-2]?\d|30|31) |)@Month @YYYY ?(?:-|–|–) ?((?:[01-3]?\d|30|31) |)@Month @YYYY(?=\s*[|}])/gi, "$1$2 @FullMonth1 @YYYY1 – $3@FullMonth2 @YYYY2");
.ohc_regex(/(\|\s*(?:publication|archive|access|air|)-?date\s*=\s*)@Month @Day(, (?:19|20)\d\d) ?(?:-|–|–) ?@Month @Day, @YYYY(?=\s*[|}])/gi, "$1@FullMonth1 @Day1$2 – @FullMonth2 @Day2, @YYYY");
.ohc_regex(/(\|\s*(?:publication|archive|access|air|)-?date\s*=\s*)@Day @Month,?( (?:19|20)\d\d) ?(?:-|–|–) ?@Day @Month @YYYY(?=\s*[|}])/gi, "$1@Day1 @FullMonth1$2 – @Day2 @FullMonth2 @YYYY");
.ohc_regex(/(\|\s*(?:publication|archive|access|air|)-?date\s*=\s*)@Month,?( (?:19|20)\d\d) ?(?:-|–|–) ?@Month,? @YYYY(?=\s*[|}])/gi, "$1@FullMonth1$2 – @FullMonth2 @YYYY");
.ohc_regex(/(\|\s*(?:publication|archive|access|air|)-?date\s*=\s*)((?:19|20)\d\d) ?(?:-|–|–) ?@Month @YYYY(?=\s*[|}])/gi, "$1@$2 – @FullMonth @YYYY");
//commenting out 3 lines- unexplained error 30 May 2014
// ohc_regex(/(<ref[^>]*>(?:[^<]+?[\s\(]|))@Month @YYYY(?=(?:[^-\w\/%,<][^<]*?|)<\/ref>)/gi, "$1@FullMonth @YYYY");
// ohc_regex(/(<ref[^>]*>(?:[^<]+?[\s\(]|))@Day @Month @YYYY(?=(?:[^-\w\/%,<][^<]*?|)<\/ref>)/gi, "$1@Day @FullMonth @YYYY");
// ohc_regex(/(<ref[^>]*>(?:[^<]+?[\s\(]|))@Month @Day, @YYYY(?=(?:[^-\w\/%,<][^<]*?|)<\/ref>)/gi, "$1@FullMonth @Day, @YYYY");
.ohc_regex(/(<ref[^>]*>(?:[^<]+?[\s\(]|))((?:[01-2]?\d|30|31) |)@Month @YYYY ?(?:-|–|–) ?((?:[01-3]?\d|30|31) |)@Month @YYYY(?=(?:[^-\w\/%,<][^<]*?|)<\/ref>)/gi, "$1$2@FullMonth1 @YYYY1 – $3@FullMonth2 @YYYY2");
.ohc_regex(/(<ref[^>]*>(?:[^<]+?[\s\(]|))@Month @Day(, (?:19|20)\d\d) ?(?:-|–|–) ?@Month @Day, @YYYY(?=(?:[^-\w\/%,<][^<]*?|)<\/ref>)/gi, "$1@FullMonth1 @Day1$2 – @FullMonth2 @Day2, @YYYY");
.ohc_regex(/(<ref[^>]*>(?:[^<]+?[\s\(]|))@Day @Month,?( (?:19|20)\d\d) ?(?:-|–|–) ?@Day @Month @YYYY(?=(?:[^-\w\/%,<][^<]*?|)<\/ref>)/gi, "$1@Day1 @FullMonth1$2 – @Day2 @FullMonth2 @YYYY");
.ohc_regex(/(<ref[^>]*>(?:[^<]+?[\s\(]|))@Month,?( (?:19|20)\d\d) ?(?:-|–|–) ?@Month,? @YYYY(?=(?:[^-\w\/%,<][^<]*?|)<\/ref>)/gi, "$1@FullMonth1$2 – @FullMonth2 @YYYY");
.ohc_regex(/(<ref[^>]*>(?:[^<]+?[\s\(]|))((?:19|20)\d\d) ?(?:-|–|–) ?@Month @YYYY(?=(?:[^-\w\/%,<][^<]*?|)<\/ref>)/gi, "$1$2 – @FullMonth @YYYY");
}
function ohc_expand_all_dates(editor) {
editor
{
.ohc_regex(/([^-\w/])@Month @YYYY(?=[^-\w/])/gi, '"$1@FullMonth @YYYY'");
.ohc_regex(/([^-\w/])@Day @Month @YYYY(?=[^-\w/])/gi, '"$1@Day @FullMonth @YYYY'");
.ohc_regex(/([^-\w/])@Month @Day, @YYYY(?=[^-\w/])/gi, '"$1@FullMonth @Day, @YYYY'");
.ohc_regex(/([^-\w/])((?:[01-2]?\d|30|31) |)@Month @YYYY ?(?:-|–|–) ?((?:[01-3]?\d|30|31) |)@Month @YYYY(?=[^-\w/])/gi, "$1$2@FullMonth1 @YYYY1 – $3@FullMonth2 @YYYY2");
.ohc_regex(/([^-\w/])@Month @Day(, (?:19|20)\d\d) ?(?:-|–|–) ?@Month @Day, @YYYY(?=[^-\w/])/gi, "$1@FullMonth1 @Day1$2 – @FullMonth2 @Day2, @YYYY");
.ohc_regex(/([^-\w/])@Day @Month,?( (?:19|20)\d\d) ?(?:-|–|–) ?@Day @Month @YYYY(?=[^-\w/])/gi, "$1@Day1 @FullMonth1$2 – @Day2 @FullMonth2 @YYYY");
.ohc_regex(/([^-\w/])@Month,?( (?:19|20)\d\d) ?(?:-|–|–) ?@Month,? @YYYY(?=[^-\w/])/gi, "$1@FullMonth1$2 – @FullMonth2 @YYYY");
.ohc_regex(/([^-\w/])((?:19|20)\d\d) ?(?:-|–|–) ?@Month @YYYY(?=[^-\w/])/gi, "$1$2 – @FullMonth @YYYY");
.ohc_regex(/([ ]\(|\|\s*)@Day @Month @YYYY(?=\)\W|\s*[|\n])/gi, "$1@Day @FullMonth @YYYY");
.ohc_regex(/([ ]\(|\|\s*)@Month @Day,? @YYYY(?=\)\W|\s*[|\n])/gi, "$1@FullMonth @Day, @YYYY");
.ohc_regex(/([ ]\((?:c\. |))@Month @YYYY ?(?:-|–| ) ?@Day @Month @YYYY(?=\)\W)/gi, "$1@FullMonth1 @YYYY1 – @Day @FullMonth2 @YYYY2");
.ohc_regex(/([ ]\((?:c\. |))@Month @YYYY ?(?:-|–| ) ?@Month @YYYY(?=\)\W)/gi, "$1@FullMonth1 @YYYY1 – @FullMonth2 @YYYY2");
.ohc_regex(/([ ]\((?:c\. |))@YYYY ?(?:-|–| ) ?@Month @YYYY(?=\)\W)/gi, "$1@YYYY1 – @FullMonth @YYYY2");
.ohc_regex(/([ ]\((?:c\. |))@Month ?(?:-|–| ) ?@Month @YYYY(?=\)\W)/gi, "$1@FullMonth1 – @FullMonth2 @YYYY");
.ohc_regex(/([ ]\((?:c\. |))@Month @YYYY(?=\)\W)/gi, "$1@FullMonth @YYYY");
}
function ohc_abbrev_ref_dates(editor) {
editor
{
.ohc_regex(/(\|\s*(?:publication|archive|access|air|)-?date\s*=\s*)@Day @Month @YYYY(?=\s*[|}])/gi, "$1@Day @Mon @YYYY");
.ohc_regex(/(<ref[^>]*>(?:[^<]+?[\s\(]|))([12]?\d|30|31) (Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)(?:r?uary|ch|il|[ey]|ust|(?:t?em|o)ber)( (?:19\d|20[01])\d)(?=(?:[^-\w\/%,<][^<]*?|)<\/ref>)/gi, "$1$2 $3$4");
.ohc_regex(/([ ]\()@Day @Month @YYYY([^-\w\/])/gi, "$1@Day @Mon @YYYY$2");
.ohc_regex(/(\|\s*(?:publication|archive|access|air|)-?date\s*=\s*)@Month @Day, @YYYY(?=\s*[|}])/gi, "$1@Mon @Day, @YYYY");
.ohc_regex(/(<ref[^>]*>(?:[^<]+?[\s\(]|))(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)(?:r?uary|ch|il|[ey]|ust|(?:t?em|o)ber) ([12]?\d|30|31),( (?:19\d|20[01])\d)(?=(?:[^-\w\/%,<][^<]*?|)<\/ref>)/gi, "$1$2 $3,$4");
.ohc_regex(/([^-\w\/])@Month @Day, @YYYY([^-\w\/])/gi, '"$1@Mon @Day, @YYYY$2'");
}
//not currently used
function ohc_abbrev_all_dates(editor) {
editor
{
.ohc_regex(/([^-\w/])@Day @Month @YYYY(?=[^-\w/])/gi, '"$1@Day @Mon @YYYY'");
.ohc_regex(/([^-\w/])@Month @Day, @YYYY(?=[^-\w/])/gi, '"$1@Mon @Day, @YYYY'");
}
//not currently used
function ohc_dmy_publication_dates(editor) {
editor
{
.ohc_regex(/(\|\s*(?:publication|archive|access|air|)-?date\s*=\s*)@Month @Day,? @YYYY/gi, "$1@Day @Month @YYYY"); // conversion of dates in references outside of the protection loop (eg for quotations etc.)
.ohc_regex(/(\|\s*(?:publication|archive|access|air|)-?date\s*=\s*)(?:\[\[)?@YYYY(?:\]\][-–]\[\[|[-–])@MM[-–]@DD(?:\]\])?(?=\s*[|}])/gi, "$1@Day @Month @YYYY");
//replace ISO dates (within parentheses) only within refs
// replace ISO dates (within parentheses) only within refs
ohc_regex(/(<ref[^>]*>[^<]+?)([ ]\()@YYYY-@MM-@DD(\))(\W[^<]*?<\/ref>)/gi, "$1$2@Day @Month @YYYY$3$4");
.ohc_regex(/(<ref[^>]*>[^<]+?)([ ]\()@YYYY-@MM-@DD(\))(\W[^<]*?<\/ref>)/gi, "$1$2@Day @Month @YYYY$3$4");
}
function ohc_mdy_publication_dates(editor) {
editor
{
.ohc_regex(/(\|\s*(?:publication|archive|access|air|)-?date\s*=\s*)@Day @Month @YYYY/gi, "$1@Month @Day, @YYYY"); // conversion of dates in references outside of the protection loop (eg for quotations etc.)
.ohc_regex(/(\|\s*(?:publication|archive|access|air|)-?date\s*=\s*)(?:\[\[)?@YYYY(?:\]\][-–]\[\[|[-–])@MM[-–]@DD(?:\]\])?(?=\s*[|}])/gi, "$1@Month @Day, @YYYY");
//replace ISO dates (within parentheses) only within refs
// replace ISO dates (within parentheses) only within refs
ohc_regex(/(<ref[^>]*>[^<]+?)([ ]\()@YYYY-@MM-@DD(\))(\W[^<]*?<\/ref>)/gi, "$1$2@Month @Day, @YYYY$3$4");
.ohc_regex(/(<ref[^>]*>[^<]+?)([ ]\()@YYYY-@MM-@DD(\))(\W[^<]*?<\/ref>)/gi, "$1$2@Month @Day, @YYYY$3$4");
}
function ohc_Bigendian_ref_datesohc_refs_to_yyyymmdd(editor) {
editor
// Add a tag to the summary box
// Add a tag to the summary box
regex(/(\{\{use (?:mdy|dmy) dates)(?:\|cs1-dates=\w{1,2}|)(\|[^\}\|]+\}\})/gi, '$1|cs1-dates=y$2');
.ohc_regex(/(\|\s*(?:archive|access)-?date\s*=\s*)@Day @Month @YYYY/gi, "$1@YYYY-@MM-@DD") // conversion of dmy dates to ymd within citation templates
.ohc_regex(/(\|\s*(?:archive|access)-?date\s*=\s*)@Month @Day, @YYYY/gi, "$1@YYYY-@MM-@DD") // conversion of mdy dates to ymd within citation templates
.replace(/(\{\{use (?:mdy|dmy) dates)(?:\|cs1-dates=\w{1,2}|)(\s*\|date=[^\}\|]+)(?=\}\})/gi, "$1$2|cs1-dates=ly");
}
// this function modified 2019-03-27 from [[Special:Permalink/846525463]]
// format parameter must be 'dmy' or 'mdy'
function ohc_use_dates_template(editor, format) {
{
var txt = document.editform.wpTextbox1;
// current month-year
var currentDate = new Date();
var curryear = currentDate.getFullYear();
var myMonths = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
var curryyyymm = myMonths[currmonth] + '" '" + curryear;
// step 1: normalize redirect template names to canonical template names 'Use dmy dates' or 'Use mdy dates' according to 'format' argument
editor
// rename redirects 'dmy', 'mdy', 'usedmydates', 'usemdydates' ('usedmydates' and 'usemdydates' are not currently listed as redirects but might be encountered?)
.replace(/\{\{ *(?:use(?:dmy|mdy)dates|dmy|mdy) *([\|\}])/gi, "{{Use " + format + " dates$1")
// rename redirects 'usedmy', 'usemdy', 'use dmy', 'use mdy' to canonical form
.replace(/\{\{ *use *(?:dmy|mdy) *([\|\}])/gi, "{{Use " + format + " dates$1")
// strip leading / trailing whitespace from 'use xxx dates'
// step 1: normalize redirect template names to canonical template names 'Use dmy dates' or 'Use mdy dates' according to 'format' argument
.replace(/\{\{ *use (?:dmy|mdy) dates *([\|\}])/gi, "{{Use " + format + " dates$1");
// rename redirects 'dmy', 'mdy', 'usedmydates', 'usemdydates' ('usedmydates' and 'usemdydates' are not currently listed as redirects but might be encountered?)
regex(/\{\{ *(?:use(?:dmy|mdy)dates|dmy|mdy) *([\|\}])/gi, '{{Use ' + format + ' dates$1');
// rename redirects 'usedmy', 'usemdy', 'use dmy', 'use mdy' to canonical form
regex(/\{\{ *use *(?:dmy|mdy) *([\|\}])/gi, '{{Use ' + format + ' dates$1');
// strip leading / trailing whitespace from 'use xxx dates'
regex(/\{\{ *use (?:dmy|mdy) dates *([\|\}])/gi, '{{Use ' + format + ' dates$1');
// step 2: look for a canonical template name (the above might not have had anthing to work on) ; if found continue, write new template else
var rxpdd = new RegExp("{{Use " + format + " dates", "gi"); // here we search for canonical form {{use xxx dates}} that has current date
var dflagfoundorigtext = txteditor.value.searchget(rxpdd);
var dflagfound = origtext.search(rxpdd);
if (dflagfound === -1) {
txt.valuevar dflagtxt = '"{{Use '" + format + '" dates|date='" + curryyyymm + '"}}\r\n' + txt.value"; // not found so insert new template at topwithin ofhead wikitextmatter
// Strategy: line by line
return; // and done
// Strip comments and outside whitespace
// If the line begins with {{ or is blank
// If it has balanced {{ and }} and ends with }}, and has no content outside braces
// If it starts with short description prepend to result
// Else append to result
// Else if it has one more {{ than }} and starts with {{Multiple issues or a redirect
// Append to result
// Keep reading lines and append until a line that has the matching }}
// Otherwise insert the flag text before any trailing blank lines or comment-only lines
var lines = origtext.split(/\r*\n/);
var result= "";
var nesting = 0;
var inmulti = false;
for (let i = 0; i < lines.length; i++) {
var line = lines[i];
var linenosp = line.replaceAll(/<!--.*?-->/g, "").replaceAll(/".*?"/g, '""').replaceAll(/\s+/g, "");
var openbrct = linenosp.includes("{{") ? linenosp.match(/\{\{/g).length : 0;
var closebrct = linenosp.includes("}}") ? linenosp.match(/}}/g).length : 0;
var hascontent = !linenosp.startsWith("{{") || !linenosp.endsWith("}}") || linenosp.search(/}}[^{]+?\{\{/) >= 0;
nesting += openbrct - closebrct;
inmulti |= (nesting > 0 && linenosp.search(/\{\{((multiple)?issues|mi)(\||$)/i) >= 0); // Several redirects in use; extend this list?
// The following are circumstances where we want to transfer the line now. If nesting ever goes negative something is badly wrong.
if (linenosp.length === 0 ||
(nesting === 0 && (!hascontent || inmulti)) || // If nesting goes to 0 when inmulti, this line closes the multi
(nesting > 0 && inmulti)) {
// Hoist Short Description, unless it is preceded on the same line by other text
if (i > 0 && linenosp.search(/^\{\{shortdesc/i) === 0 && !inmulti) {
result = line + "\r\n" + result;
} else {
result += line + "\r\n";
}
if (nesting === 0) {
inmulti = false;
}
} else {
// Detected end of preceding templates
// You might think that we should add a trailing newline if there was one in the original, but the source editor adds one unconditionally
editor.set((result.includes("\r\n") ? result.replace(/\r\n((\r\n)*)$/, "\r\n" + dflagtxt + "$1") : dflagtxt) + lines.slice(i).join("\r\n"));
return;
}
}
// Somehow there is no content, only hatnotes and stuff
editor.set(result + dflagtxt);
return; // and done
}
// step 3: rewrite existing canonical templates; add or refresh |date= to current month year; preserve |cs1-dates= as is
editor
regex(/(\{\{use (?:dmy|mdy) dates)\| *date *=[^\|]*\| *cs1\-dates *= *([^\|\}]*?) *\}\}/gi, '$1|date=' + curryyyymm + '|cs1-dates=$2}}'); // with |date= followed by |cs1-dates=
regex .replace(/(\{\{use (?:dmy|mdy) dates)\| *date *=[^\|]*\| *cs1\-dates *= *([^\|\}]*?) *\| *date *=[^\}]*\}\}/gi, '"$1|date='" + curryyyymm + '"|cs1-dates=$2}}'"); // with |cs1-datesdate= followed by |datecs1-dates=
regex .replace(/(\{\{use (?:dmy|mdy) dates)\| *datecs1\-dates *= *([^\|\}]*?) *\| *date *=[^\}]*\}\}/gi, '"$1|date='" + curryyyymm + '"|cs1-dates=$2}}'"); // with |cs1-dates= followed by |date=
regex .replace(/(\{\{use (?:dmy|mdy) dates)\| *cs1\-datesdate *= *([^\|\}]*?) \}\}/gi, '"$1|date='" + curryyyymm + '|cs1-dates=$2"}}'"); // with |cs1-datesdate=
regex .replace(/(\{\{use (?:dmy|mdy) dates)\| *cs1\-dates *= *([^\|\}]*?) \}\}/gi, '"$1|date='" + curryyyymm + '"|cs1-dates=$2}}'"); // no parameters so addwith |date=curryyyymm cs1-dates
.replace(/(\{\{use (?:dmy|mdy) dates)\}\}/gi, "$1|date=" + curryyyymm + "}}") // no parameters so add |date=curryyyymm
.replace(/(\{\{[\t_ ]*use[\t_ ]+(?:dmy|mdy)[\t_ ]+dates[^{}]*\}\})([\r\n\t ]*)(\{\{[\t ]*short description[^{}]*\}\})/gi, "$3$2$1"); // repositioning "short description" template at the top
}
var linkmap = [];
function ohc_protect_dates(editor) {
{
// protects dates within links, quotes, etc
// the sensitive part is stored and replaced with a unique identifier,
// which is later replaced with the stored part.
var protect_function = function(s, begin, replace, end) {
linkmap.push(replace);
return begin + "⍌"+(linkmap.length-1)+"⍍" + end;
};
//\|x=
regex(/(<timeline>)([\s\S]*?)(<\/timeline>)/gi, protect_function);
regex(/(<math>)([\s\S]*?)(<\/math>)/gi, protect_function);
regex(/((?:{(?:Wikimedia |)Commons ?|C ?))(Cat(?:egory|))\|[^{}*](})/gi, protect_function);
regex(/(<ref)([^>]+)(>)/gi, protect_function);
regex(/((?:Category|Image|File):)([^|\]]*)([|\]])/gi, protect_function);
regex(/(\{(?:See ?also|Main))(\|[^}]*)(\})/gi, protect_function);
regex(/(\{\{(?:double ?|external ?|wide ?)image\s?\|)([^}]+)(\})/gi, protect_function);
regex(/(\{\{(?:harvnb|r|wikisource)\|)([^}]+)(\})/gi, protect_function);
regex(/(\[(?:https?:|ftp:))([^\]]*)(\])/gi, protect_function);
regex(/(>[ ]*(?:https?:|ftp:))([^< >\]]*)([ ]*<)/gi, protect_function);
// regex(/(https?:|ftp:)([^\s\]]*)([\s\]])/gi, protect_function);
regex(/(<blockquote>)([\s\S]*?)(<\/blockquote>)/gi, protect_function);
regex(/(<noinclude>)([\s\S]*?)(<\/noinclude>)/gi, protect_function);
regex(/(<gallery)([\s\S]*?)(<\/gallery>)/gi, protect_function);
regex(/(<poem>)([\s\S]*?)(<\/poem>)/gi, protect_function);
regex(/(\{[^\{]{0,6}(?:quot[^|]{1,7}\s?|sic)\|)([^}]+)(\})/gi, protect_function);
regex(/((?:image\d?|image_skyline|image[ _]___location\d?|image[ _]name|image[ _]file|img|map\d|pic)\s*=)([^|}]*)([|}])/gi, protect_function);
regex(/([\|\{]\s*(?:file(?:name\d?|)|image\d?|image ___location\d?|img|pic|Cover|(?:trans-?|)title|quote|chapter|journal|url|archiveurl|work|doi|club|at|volume|reporter)\s*=)([^|\}⍍]*)([|}])/gi, protect_function);
regex(/([\|\{]\s*(?:file(?:name\d?|)|image\d?|image ___location\d?|img|pic|Cover|(?:trans-?|)title|quote|chapter|journal|url|archiveurl|work|doi|club|at|volume|reporter)\s*=)([^|\}⍍]*)([|}])/gi, protect_function);
regex(/([\|\{]\s*(?:season)\s*=)(\s*\[\[[^\]]*\]\]\s*)([|}])/gi, protect_function);
regex(/([\|\{]\s*(?:[xy])\s*=)(\s*[^\|]+\s*)(\|)/gi, protect_function);
regex(/(\{\{navsource\|)([^}]+)(\})/gi, protect_function);
regex(/(\{\{(?:singlechart)\|)([^}]+)(\})/gi, protect_function);
regex(/(\{\{(?:defaultsort|graph):)([^}]+)(\})/gi, protect_function);
regex(/(["“])([^"”\n]*)(["”])/gi, protect_function);
regex(/(.)(\(\{\{by\|[12]\d{3}\}\}[-–]\{\{by\|)([12]\d{3}[ ]*\}\}\))/gi, protect_function);
regex(/(.)(\(\{\{by\|[12]\d{3}\}\}(?:[-–]present|))(\))/gi, protect_function);
editor
//retraining redirects containing a date
// \|x=
regex(/(\[\[)(?:September 3 Society)(\]\]|\|)/gi, '$1Jiusan Society$2');
.replace(/(<timeline>)([\s\S]*?)(<\/timeline>)/gi, protect_function)
regex(/(\[\[)(?:June 4th incident)(\]\]|\|)/gi, '$1Tiananmen Square protests of 1989$2');
.replace(/(<!--)([^<\{\}]*?)(-->)/gi, protect_function)
regex(/(\[\[)(?:5@th? October (?:\(Serbia\)|overthrow))(\]\]|\|)/gi, '$1Overthrow of Slobodan Milošević$2');
.replace(/(<math>)([\s\S]*?)(<\/math>)/gi, protect_function)
regex(/(\[\[)(?:October 5@th?(?: \(Serbia\)| overthrow|, 2000))(\]\]|\|)/gi, '$1Overthrow of Slobodan Milošević$2');
.replace(/((?:{(?:Wikimedia |)Commons ?|C ?))(Cat(?:egory|))\|[^{}*](})/gi, protect_function)
.replace(/(<ref)([^>]+)(>)/gi, protect_function)
.replace(/((?:Category|Image|File):)([^|\]]*)([|\]])/gi, protect_function)
.replace(/(\{(?:See ?also|Main))(\|[^}]*)(\})/gi, protect_function)
.replace(/(\{\{(?:double ?|external ?|wide ?)image\s?\|)([^}]+)(\})/gi, protect_function)
.replace(/(\{\{(?:Single chart|harvnb|r|wikisource)\|)([^}]+)(\})/gi, protect_function)
.replace(/(\{\{(?:About-distinguish-text)\s*\|)([^}]+)(\}\})/gi, protect_function)
.replace(/(\{\{(?:Canadian federal by-election))([^}]+)(\}\})/gi, protect_function)
.replace(/(\[(?:https?:|ftp:))([^\]]*)(\])/gi, protect_function)
//protect alternate meanings of 'may' and 'march' (note: not case insensitive)
// ohc_regex .replace(/(>[^\w ])*(@day,?\s{0,3}may:https?:|ftp:))([^< >\w]]*)([^\d ]*<)/ggi, protect_function); //disabled 26 May – not case senstitve: false negatives in converting dates in May
.replace(/(\|\s*archive-?url\s*=\s*https?:|ftp:)([^\s\|]*)(\s?\|)/gi, protect_function) //repurposed unused line to protect archive url links (archive.today)
ohc_regex(/([^\w])(march\s@day)(\s(?:mile|kilomet|met))/g, protect_function);
.replace(/(<blockquote>)([\s\S]*?)(<\/blockquote>)/gi, protect_function)
.replace(/(<noinclude>)([\s\S]*?)(<\/noinclude>)/gi, protect_function)
.replace(/(<gallery)([\s\S]*?)(<\/gallery>)/gi, protect_function)
.replace(/(<poem>)([\s\S]*?)(<\/poem>)/gi, protect_function)
.replace(/(\{[^\{]{0,6}(?:quot[^|]{1,7}\s?|sic)\|)([^}]+)(\})/gi, protect_function)
.replace(/((?:image\d?|image_skyline|image[ _]___location\d?|image[ _]name|image[ _]file|img|map\d|pic)\s*=)([^|}]*)([|}])/gi, protect_function)
.replace(/([\|\{]\s*(?:file(?:name\d?|)|image\d?|image ___location\d?|img|pic|Cover|(?:trans-?|)title|quote|chapter|journal|url|archiveurl|work|doi|club|at|volume|reporter)\s*=)([^|\}⍍]*)([|}])/gi, protect_function)
.replace(/([\|\{]\s*(?:file(?:name\d?|)|image\d?|image ___location\d?|img|pic|Cover|(?:trans-?|)title|quote|chapter|journal|url|archiveurl|work|doi|club|at|volume|reporter)\s*=)([^|\}⍍]*)([|}])/gi, protect_function)
.replace(/([\|\{]\s*(?:season)\s*=)(\s*\[\[[^\]]*\]\]\s*)([|}])/gi, protect_function)
.replace(/([\|\{]\s*(?:[xy])\s*=)(\s*[^\|]+\s*)(\|)/gi, protect_function)
.replace(/(\{\{navsource\|)([^}]+)(\})/gi, protect_function)
.replace(/(\{\{merge(?:[^}]+))([^}]+)(\})/gi, protect_function)
.replace(/(\{\{(?:singlechart)\|)([^}]+)(\})/gi, protect_function)
.replace(/(\{\{(?:defaultsort|graph):)([^}]+)(\})/gi, protect_function)
.replace(/(["“])([^"”\n]*)(["”])/gi, protect_function)
.replace(/(.)(\(\{\{by\|[12]\d{3}\}\}[-–]\{\{by\|)([12]\d{3}[ ]*\}\}\))/gi, protect_function)
.replace(/(.)(\(\{\{by\|[12]\d{3}\}\}(?:[-–]present|))(\))/gi, protect_function)
.replace(/(\[\[)(4AD)(\]\]|\|)/gi, protect_function)
//protect allretraining linksredirects containing a date and some text
ohc_regex .replace(/(\[\[)(\s*\w[^\]\|\n]+?@day[^\]\|\n]+?@fullmonth[^\]\|\n]*:September 3 Society)(\]\]|\|)/gi, protect_function"$1Jiusan Society$2");
.replace(/(\[\[)(?:June 4th incident)(\]\]|\|)/gi, "$11989 Tiananmen Square protests and massacre$2")
ohc_regex(/(\[\[)([^\]\|\n]*?@day[^\]\|\n]+?@fullmonth(?:,? @year|) \D[^\]\|\n]+\w\s*)(\]\]|\|)/gi, protect_function);
.replace(/(\[\[)(?:5@th? October (?:\(Serbia\)|overthrow))(\]\]|\|)/gi, "$1Overthrow of Slobodan Milošević$2")
ohc_regex(/(\[\[)(\s*\w[^\]\|\n]+?@fullmonth[^\]\|\n]+?@day[^\]\|\n]*)(\|)/gi, protect_function);
ohc_regex .replace(/(\[\[)([^\]\|\n]*?:October 5@fullmonth[^\]\|\n]+th?@day(?:, @year|) \D[^\](Serbia\)|\n]+\w\s* overthrow|, 2000))(\]\]|\|)/gi, protect_function"$1Overthrow of Slobodan Milošević$2");
// protect alternate meanings of 'may' and 'march' (note: not case insensitive)
//protects certain dates
regex //.ohc_regex(/(\[^\[w])(4AD@day,?\s{0,3}may)([^\sw][^\Sd])/gig, protect_function); //disabled 26 May – not case senstitve: false negatives in converting dates in May
regex .ohc_regex(/([^\s\Sw])(March march\s@day)(\s(?:8mile|14kilomet|met) Alliance)([\s\S])/gig, protect_function);
regex(/([\s\S])(23rd March 1931: Shaheed)([\s\S])/gi, protect_function);
regex(/([\s\S])(Long March [1-7])([\s\S])/gi, protect_function);
regex(/([\s\S])(Bombay March 12)([\s\S])/gi, protect_function);
regex(/([\s\S])(movement 2 June)([\s\S])/gi, protect_function);
regex(/([\s\S])(6th\sof October City)([\s\S])/gi, protect_function);
regex(/([\s\S])(Party Workers' Liberation Front 30th of May)([\s\S])/gi, protect_function);
regex(/([\s\S])(4th\sof August regime)([\s\S])/gi, protect_function);
regex(/([\s\S])(19th\sof April movement)([\s\S])/gi, protect_function);
regex(/([\s\S])(June 4th incident)([\s\S])/gi, protect_function);
regex(/([\s\S])(The Battle Of Marston Moor \(July 2nd,? 1644\))([\s\S])/gi, protect_function);
regex(/([\s\S])(Night of January 16th)([\s\S])/gi, protect_function);
regex(/([\s\S])(Observance of 5th November Act)([\s\S])/gi, protect_function);
regex(/(\[\[)(13 May incident)(\|)/gi, protect_function);
regex(/(\'\'\')(22nd\sof May)(\'\'\')/gi, protect_function);
regex(/(\[\[)(22nd\sof May \(film\))([|\]\'])/gi, protect_function);
regex(/(\[\[)(July 12, 2007, Baghdad airstrike)(\|)/gi, protect_function);
regex(/(\[\[)(November 1828)(\]\])/gi, protect_function);
regex(/(.)(4th\sof July)(.)/gi, protect_function);
regex(/(\[\[)((?:2300|2000)\s?AD)(\]\])/gi, protect_function);
regex(/(\[\[)(29 February)(\]\])/gi, protect_function);
regex(/(\[\[)(February 29)(\]\])/gi, protect_function);
// protect all links containing a date and some text
// works names
// regex .ohc_regex(/(.\[\[)(protect string\s*\w[^\]\|\n]+?@day[^\]\|\n]+?@fullmonth[^\]\|\n]*)(.\]\]|\|)/gi, protect_function);
regex .ohc_regex(/(.\[\[)(11[^\/22]\/63|\n]*?@day[^\]\|\n]+?@fullmonth(?:,? @year|) \D[^\]\|\n]+\w\s*)(.\]\]|\|)/gi, protect_function);
regex .ohc_regex(/(.\[\[)(1\.1s*\.1994w[^\]\|\n]+?@fullmonth[^\]\|\n]+?@day[^\]\|\n]*)(.\|)/gi, protect_function);
regex .ohc_regex(/(\[\s\S][)(2[^\.13]\.61)|\n]*?@fullmonth[^\]\|\n]+?@day(?:, @year|) \D[^\]\|\n]+\w\s*)(\S]\]|\|)/gi, protect_function);
// regex(/(.)(4th of July, Asbury)(.)/gi, protect_function); //protected above globally
regex(/(.)(26 October 1993)(.)/gi, protect_function);
regex(/(\[\[|\'\')(June 1, 1974)(.)/gi, protect_function);
regex(/(\[\[|\'\')(July 15, 1972)(.)/gi, protect_function);
regex(/(\[\[|\'\')(August 1914)(.)/gi, protect_function);
ohc_regex(/(\[\[|\'\')(@fullmonth @dd@th? \((?:@yyyy |)film\)(?:\|@fullmonth @dd@th?|))([\s\S])/gi, protect_function);
ohc_regex(/(\[\[|\'\')(@dd@th? @fullmonth \((?:@yyyy |)film\)(?:\|@dd@th? @fullmonth|))([\s\S])/gi, protect_function);
// regex(/(Les Bains Douches 18)( December 1979)(.)/gi, protect_function);
regex(/(August)( 7, 4:15)(.)/gi, protect_function);
regex(/(In Concert, Zürich, October)( 28, 1979)(.)/gi, protect_function);
regex(/(CBGB OMFUG Masters: Live June)( 29, 2001)(.)/gi, protect_function);
ohc_regex(/(Live at [\w ]*,? [1-3]\d)( @fullmonth)(.)/gi, protect_function);
ohc_regex(/(Live at [\w ]*,? @fullmonth)( @dd)(.)/gi, protect_function);
ohc_regex(/(Bootmoon Series: [\w ]*[-–] @fullmonth)( @day, @YYYY)(.)/gi, protect_function);
// protects certain dates
regex(/(\W)((?:\d{3}|3[2-9]|[4-9]\d)\/\d dec(?:l\.?|))(\W)/gi, protect_function);
regex .replace(/(\W)((?:[\d{2,3}[)\/\d dec(?:l\.?|)4AD)( [\(s\d\d? oversS])/gi, protect_function);
.replace(/([\s\S])(March (?:8|14) Alliance)([\s\S])/gi, protect_function)
.replace(/([\s\S])(23rd March 1931: Shaheed)([\s\S])/gi, protect_function)
.replace(/([\s\S])(Long March [1-7])([\s\S])/gi, protect_function)
.replace(/([\s\S])(National September 11 Memorial & Museum)([\s\S])/gi, protect_function)
.replace(/([\s\S])(Queen Elizabeth II September 11th Garden)([\s\S])/gi, protect_function)
.replace(/([\s\S])(Bombay March 12)([\s\S])/gi, protect_function)
.replace(/([\s\S])(movement 2 June)([\s\S])/gi, protect_function)
.replace(/([\s\S])(6th\sof October City)([\s\S])/gi, protect_function)
.replace(/([\s\S])(Party Workers' Liberation Front 30th of May)([\s\S])/gi, protect_function)
.replace(/([\s\S])(4th\sof August regime)([\s\S])/gi, protect_function)
.replace(/([\s\S])(19th\sof April movement)([\s\S])/gi, protect_function)
.replace(/([\s\S])(June 4th (?:incident|museum))([\s\S])/gi, protect_function)
.replace(/([\s\S])(The Battle Of Marston Moor \(July 2nd,? 1644\))([\s\S])/gi, protect_function)
.replace(/([\s\S])(Night of January 16th)([\s\S])/gi, protect_function)
.replace(/([\s\S])(Observance of 5th November Act)([\s\S])/gi, protect_function)
.replace(/(\[\[)(13 May incident)(\|)/gi, protect_function)
.replace(/(\'\'\')(22nd\sof May)(\'\'\')/gi, protect_function)
.replace(/(\[\[)(22nd\sof May \(film\))([|\]\'])/gi, protect_function)
.replace(/(\[\[)(July 12, 2007, Baghdad airstrike)(\|)/gi, protect_function)
.replace(/(\[\[)(November 1828)(\]\])/gi, protect_function)
.replace(/(.)(4th\sof July)(.)/gi, protect_function)
.replace(/(\[\[)((?:2300|2000)\s?AD)(\]\])/gi, protect_function)
.replace(/(\[\[)(29 February)(\]\])/gi, protect_function)
.replace(/(\[\[)(February 29)(\]\])/gi, protect_function)
// works names
//.replace(/(.)(protect string)(.)/gi, protect_function)
.replace(/(.)(11\/22\/63)(.)/gi, protect_function)
.replace(/(.)(1\.1\.1994)(.)/gi, protect_function)
.replace(/([\s\S])(2\.13\.61)([\s\S])/gi, protect_function)
//.replace(/(.)(4th of July, Asbury)(.)/gi, protect_function) //protected above globally
.replace(/(.)(26 October 1993)(.)/gi, protect_function)
.replace(/(\[\[|\'\')(June 1, 1974)(.)/gi, protect_function)
.replace(/(\[\[|\'\')(July 15, 1972)(.)/gi, protect_function)
.replace(/(\[\[|\'\')(August 1914)(.)/gi, protect_function)
.ohc_regex(/(\[\[|\'\')(@fullmonth @dd@th? \((?:@yyyy |)film\)(?:\|@fullmonth @dd@th?|))([\s\S])/gi, protect_function)
.ohc_regex(/(\[\[|\'\')(@dd@th? @fullmonth \((?:@yyyy |)film\)(?:\|@dd@th? @fullmonth|))([\s\S])/gi, protect_function)
//.replace(/(Les Bains Douches 18)( December 1979)(.)/gi, protect_function)
.replace(/(August)( 7, 4:15)(.)/gi, protect_function)
.replace(/(In Concert, Zürich, October)( 28, 1979)(.)/gi, protect_function)
.replace(/(CBGB OMFUG Masters: Live June)( 29, 2001)(.)/gi, protect_function)
.ohc_regex(/(Live at [\w ]*,? [1-3]\d)( @fullmonth)(.)/gi, protect_function)
.ohc_regex(/(Live at [\w ]*,? @fullmonth)( @dd)(.)/gi, protect_function)
.ohc_regex(/(Bootmoon Series: [\w ]*[-–] @fullmonth)( @day, @YYYY)(.)/gi, protect_function)
// expressions and grammatical strings including modal "may"
//.replace(/(trappist-)(\d{1,3})( may )/g, protect_function) //prospective regex if the line below gives false positives
.replace(/(\W)((?:\d{1,3}) may )(\w\w+)/g, protect_function)
.replace(/(\W)((?:\d{3}|3[2-9]|[4-9]\d)\/\d dec(?:l\.?|))(\W)/gi, protect_function)
.replace(/(\W)((?:\d{2,3})\/\d dec(?:l\.?|))( \(\d\d? overs)/gi, protect_function);
}
var linkmap = [];
function ohc_protect_dates_ref(editor) {
{
// protects dates within links, quotes, etc
// the sensitive part is stored and replaced with a unique identifier,
// which is later replaced with the stored part.
var protect_function = function (s, begin, replace, end) {
linkmap.push(replace);
};
editor
regex(/(<ref\s?(?:>|name=[^>]+))([^<]+)(<\/ref>)/gi, protect_function);
regex .replace(/(<timelineref\s?(?:>|name=[^>]+))([\s\S^<]*?+)(<\/timelineref>)/gi, protect_function);
regex .replace(/(<mathtimeline>)([\s\S]*?)(<\/mathtimeline>)/gi, protect_function);
regex .replace(/(<math>)([\s\S]*?:{(?:Wikimedia |)Commons ?|C ?))(Cat(?:egory|))<\|[^{}*](}/math>)/gi, protect_function);
regex .replace(/((?:Category{(?:Wikimedia |Image)Commons ?|FileC ?):)([^|\]]*)Cat([?:egory|))\|[^{}*]](})/gi, protect_function);
regex .replace(/(\{(?:See ?alsoCategory|Image|MainFile):)(\|[^}|\]]*)([|\}]])/gi, protect_function);
regex .replace(/(\{\{(?:doubleSee ?also|external ?|wide ?Main)image\s?)(\|)([^}]+*)(\})/gi, protect_function);
regex .replace(/(\{\{(?:harvnbdouble ?|wikisourceexternal ?|wide ?)image\s?\|)([^}]+)(\})/gi, protect_function);
regex .replace(/(\[{\{(?:https?:harvnb|ftp:wikisource)\|)([^\]}]*+)(\]})/gi, protect_function);
regex .replace(/(>\[ ]*(?:https?:|ftp:))([^< >\]]*)([ \]*<)/gi, protect_function);
//regex .replace(/(>[ ]*(?:https?:|ftp:))([^\s< >\]]*)([\s\] ]*<)/gi, protect_function);
regex .replace(/(<blockquote>\|archive-?url=https?:|ftp:)([^\s\S|]*?)(<\/blockquote>|)/gi, protect_function); //repurposed unused line to protect archive url links (archive.today)
regex .replace(/(\{[^\{]{0,6}<blockquote>)(?:quot[^|]{1,7}\s?|sic)\|)([^}S]+*?)(<\}/blockquote>)/gi, protect_function);
regex .replace(/(\{[^\{]{0,6}(?:image\d?quot[^|image_skyline|image[ _]___location{1,7}\ds?|image[ _]name|image[ _]file|img|picsic)\s*=|)([^|}]*+)([|\}])/gi, protect_function);
regex .replace(/([\|\{]\s*(?:file(?:nameimage\d?|)image_skyline|image[ _]___location\d?|image[ ___location\d?_]name|image[ _]file|img|pic|Cover|title|quote|chapter|journal|url|archiveurl|work|doi|club|at|volume|reporter)\s*=)([^|\}⍍]*)([|}])/gi, protect_function);
regex .replace(/([\|\{]\s*(?:file(?:name\d?|)|image\d?|image ___location\d?|img|pic|Cover|title|quote|chapter|journal|url|archiveurl|work|doi|club|at|volume|reporter)\s*=)([^|\}⍍]*)([|}])/gi, protect_function);
regex .replace(/([\|\{]\s*(?:seasonfile(?:name\d?|)|image\d?|image ___location\d?|img|pic|Cover|title|quote|chapter|journal|url|archiveurl|work|doi|club|at|volume|reporter)\s*=)(\s*\[\[[^|\}⍍]]*\]\]\s*)([|}])/gi, protect_function);
regex .replace(/([\{|\{navsource]\|s*(?:season)\s*=)(\s*\[\[[^}\]+]*\]\]\s*)(\[|}])/gi, protect_function);
regex .replace(/(\{\{singlechartnavsource\|)([^}]+)(\})/gi, protect_function);
regex .replace(/(\{\{defaultsort:singlechart\|)([^}]+)(\})/gi, protect_function);
regex .replace(/([\s{\(>]"{defaultsort:)([^"\n}]*+)("\})/gi, protect_function);
regex .replace(/([\s\(>]“")([^”"\n]*)(”")/gi, protect_function);
regex .replace(/(.)(\(\{\{by\|[12]\d{3}s\}\}[-–(>]\{\{by\|“)([12]^”\d{3}[ n]*\}\}\)(”)/gi, protect_function);
regex .replace(/(.)(\(\{\{by\|[12]\d{3}\}\}(?:[-–]present\{\{by\|))([12]\d{3}[ ]*\}\}\))/gi, protect_function);
.replace(/(.)(\(\{\{by\|[12]\d{3}\}\}(?:[-–]present|))(\))/gi, protect_function)
// retraining redirects containing a date
regex .replace(/(\[\[)(?:September 3 Society)(\]\]|\|)/gi, '"$1Jiusan Society$2'");
regex .replace(/(\[\[)(?:June 4th incident)(\]\]|\|)/gi, '"$1Tiananmen Square protests of 1989$2'");
.ohc_regex(/(\[\[)(?:5@th? October (?:\(Serbia\)|overthrow))(\]\]|\|)/gi, '"$1Overthrow of Slobodan Milošević$2'");
.ohc_regex(/(\[\[)(?:October 5@th?(?: \(Serbia\)| overthrow|, 2000))(\]\]|\|)/gi, '"$1Overthrow of Slobodan Milošević$2'");
// protect alternate meanings of 'may' and 'march' (note: not case insensitive)
.ohc_regex(/([^\w])(@day,?\s{0,3}may)([^\w][^\d])/g, protect_function);
.ohc_regex(/([^\w])(march\s@day)(\s(?:mile|kilomet|met))/g, protect_function);
// protect all links containing a date and some text
.ohc_regex(/(\[\[)(\s*\w[^\]\|\n]+?@day[^\]\|\n]+?@fullmonth[^\]\|\n]*)(\]\]|\|)/gi, protect_function);
.ohc_regex(/(\[\[)([^\]\|\n]*?@day[^\]\|\n]+?@fullmonth(?:,? @year|) \D[^\]\|\n]+\w\s*)(\]\]|\|)/gi, protect_function);
.ohc_regex(/(\[\[)(\s*\w[^\]\|\n]+?@fullmonth[^\]\|\n]+?@day[^\]\|\n]*)(\|)/gi, protect_function);
.ohc_regex(/(\[\[)([^\]\|\n]*?@fullmonth[^\]\|\n]+?@day(?:, @year|) \D[^\]\|\n]+\w\s*)(\]\]|\|)/gi, protect_function);
// protects certain dates
regex .replace(/(\[\[)(4AD)([\s\S])/gi, protect_function);
regex .replace(/([\s\S])(March (?:8|14) Alliance)([\s\S])/gi, protect_function);
regex .replace(/([\s\S])(23rd March 1931: Shaheed)([\s\S])/gi, protect_function);
regex .replace(/([\s\S])(Long March [1-7])([\s\S])/gi, protect_function);
regex .replace(/([\s\S])(Bombay March 12)([\s\S])/gi, protect_function);
regex .replace(/([\s\S])(movement 2 June)([\s\S])/gi, protect_function);
regex .replace(/([\s\S])(6th\sof October City)([\s\S])/gi, protect_function);
regex .replace(/([\s\S])(Party Workers' Liberation Front 30th of May)([\s\S])/gi, protect_function);
regex .replace(/([\s\S])(4th\sof August regime)([\s\S])/gi, protect_function);
regex .replace(/([\s\S])(19th\sof April movement)([\s\S])/gi, protect_function);
regex .replace(/([\s\S])(June 4th incident)([\s\S])/gi, protect_function);
regex .replace(/([\s\S])(The Battle Of Marston Moor \(July 2nd,? 1644\))([\s\S])/gi, protect_function);
regex .replace(/([\s\S])(Night of January 16th)([\s\S])/gi, protect_function);
regex .replace(/([\s\S])(Observance of 5th November Act)([\s\S])/gi, protect_function);
regex .replace(/(\[\[)(13 May incident)(\|)/gi, protect_function);
regex .replace(/(\'\'\')(22nd\sof May)(\'\'\')/gi, protect_function);
regex .replace(/(\[\[)(22nd\sof May \(film\))([|\]\'])/gi, protect_function);
regex .replace(/(\[\[)(July 12, 2007, Baghdad airstrike)(\|)/gi, protect_function);
regex(/(\[\[)(November 1828)(\]\])/gi, protect_function);
regex(/(.)(4th\sof July)(.)/gi, protect_function);
regex(/(\[\[)((?:2300|2000)\s?AD)(\]\])/gi, protect_function);
regex(/(\[\[)(29 February)(\]\])/gi, protect_function);
regex(/(\[\[)(February 29)(\]\])/gi, protect_function);
.replace(/(\[\[)(November 1828)(\]\])/gi, protect_function)
// works names
//regex .replace(/(.)(protect4th\sof stringJuly)(.)/gi, protect_function);
regex .replace(/(.\[\[)(11(?:2300|2000)\/22\/63s?AD)(.\]\])/gi, protect_function);
regex .replace(/(.)(1\.1[\.1994[)(.29 February)(\]\])/gi, protect_function);
regex .replace(/(\[\s\S][)(2\.13\.61February 29)([\s]\S])/gi, protect_function);
//regex(/(.)(4th of July, Asbury)(.)/gi, protect_function); //protected above globally
regex(/(.)(26 October 1993)(.)/gi, protect_function);
regex(/(\[\[|\'\')(June 1, 1974)(.)/gi, protect_function);
regex(/(\[\[|\'\')(July 15, 1972)(.)/gi, protect_function);
regex(/(\[\[|\'\')(August 1914)(.)/gi, protect_function);
ohc_regex(/(\[\[|\'\')(@fullmonth @dd@th? \((?:@yyyy |)film\)(?:\|@fullmonth @dd@th?|))([\s\S])/gi, protect_function);
ohc_regex(/(\[\[|\'\')(@dd@th? @fullmonth \((?:@yyyy |)film\)(?:\|@dd@th? @fullmonth|))([\s\S])/gi, protect_function);
//regex(/(Les Bains Douches 18)( December 1979)(.)/gi, protect_function);
regex(/(August)( 7, 4:15)(.)/gi, protect_function);
regex(/(In Concert, Zürich, October)( 28, 1979)(.)/gi, protect_function);
regex(/(CBGB OMFUG Masters: Live June)( 29, 2001)(.)/gi, protect_function);
ohc_regex(/(Live at [\w ]*,? [1-3]\d)( @fullmonth)(.)/gi, protect_function);
ohc_regex(/(Live at [\w ]*,? @fullmonth)( @dd)(.)/gi, protect_function);
ohc_regex(/(Bootmoon Series: [\w ]*[-–] @fullmonth)( @day, @YYYY)(.)/gi, protect_function);
// works names
regex(/(\W)((?:\d{3}|3[2-9]|[4-9]\d)\/\d dec(?:l\.?|))(\W)/gi, protect_function);
regex( //.replace(\W)((?:\d{2,3})\/\d dec(?:l\.?|))(protect \string)(\d\d? overs.)/gi, protect_function);
.replace(/(.)(11\/22\/63)(.)/gi, protect_function)
.replace(/(.)(1\.1\.1994)(.)/gi, protect_function)
.replace(/([\s\S])(2\.13\.61)([\s\S])/gi, protect_function)
//.replace(/(.)(4th of July, Asbury)(.)/gi, protect_function) //protected above globally
.replace(/(.)(26 October 1993)(.)/gi, protect_function)
.replace(/(\[\[|\'\')(June 1, 1974)(.)/gi, protect_function)
.replace(/(\[\[|\'\')(July 15, 1972)(.)/gi, protect_function)
.replace(/(\[\[|\'\')(August 1914)(.)/gi, protect_function)
.ohc_regex(/(\[\[|\'\')(@fullmonth @dd@th? \((?:@yyyy |)film\)(?:\|@fullmonth @dd@th?|))([\s\S])/gi, protect_function)
.ohc_regex(/(\[\[|\'\')(@dd@th? @fullmonth \((?:@yyyy |)film\)(?:\|@dd@th? @fullmonth|))([\s\S])/gi, protect_function)
//.replace(/(Les Bains Douches 18)( December 1979)(.)/gi, protect_function)
.replace(/(August)( 7, 4:15)(.)/gi, protect_function)
.replace(/(In Concert, Zürich, October)( 28, 1979)(.)/gi, protect_function)
.replace(/(CBGB OMFUG Masters: Live June)( 29, 2001)(.)/gi, protect_function)
.ohc_regex(/(Live at [\w ]*,? [1-3]\d)( @fullmonth)(.)/gi, protect_function)
.ohc_regex(/(Live at [\w ]*,? @fullmonth)( @dd)(.)/gi, protect_function)
.ohc_regex(/(Bootmoon Series: [\w ]*[-–] @fullmonth)( @day, @YYYY)(.)/gi, protect_function)
.replace(/(\W)((?:\d{3}|3[2-9]|[4-9]\d)\/\d dec(?:l\.?|))(\W)/gi, protect_function)
.replace(/(\W)((?:\d{2,3})\/\d dec(?:l\.?|))( \(\d\d? overs)/gi, protect_function);
}
/** ------------------------------------------------------------------------ **/
function ohc_unprotect_dates()
/// DATE PROTECTION FOR SLASH modules
{
//unprotect all dates
var linkmap = [];
regex(/[♫]/g, '');
regex(/⍌([0-9]+)⍍/g, function (x, n) {
function ohc_protect_dates_slash(editor) {
var res = linkmap[n];
// protects dates within links, quotes, etc
res = res.replace(/⍌([0-9]+)⍍/g, function (x, n) {
// the sensitive part is stored and replaced with a unique identifier,
// which is later replaced with the stored part.
var protect_function = function (s, begin, replace, end) {
linkmap.push(replace);
return begin + "⍌" + (linkmap.length - 1) + "⍍" + end;
};
editor
.replace(/(<ref\s?(?:>|name=[^>]+))([^<]+)(<\/ref>)/gi, protect_function)
.replace(/(<timeline>)([\s\S]*?)(<\/timeline>)/gi, protect_function)
.replace(/(<math>)([\s\S]*?)(<\/math>)/gi, protect_function)
.replace(/((?:{(?:Wikimedia |)Commons ?|C ?))(Cat(?:egory|))\|[^{}*](})/gi, protect_function)
.replace(/((?:Category|Image|File):)([^|\]]*)([|\]])/gi, protect_function)
.replace(/(\{(?:See ?also|Main))(\|[^}]*)(\})/gi, protect_function)
.replace(/(\{\{(?:double ?|external ?|wide ?)image\s?\|)([^}]+)(\})/gi, protect_function)
.replace(/(\{\{(?:harvnb|wikisource)\|)([^}]+)(\})/gi, protect_function)
.replace(/(\[(?:https?:|ftp:))([^\]]*)(\])/gi, protect_function)
.replace(/(>[ ]*(?:https?:|ftp:))([^< >\]]*)([ ]*<)/gi, protect_function)
//.replace(/(https?:|ftp:)([^\s\]]*)([\s\]])/gi, protect_function)
.replace(/(<blockquote>)([\s\S]*?)(<\/blockquote>)/gi, protect_function)
.replace(/(\{[^\{]{0,6}(?:quot[^|]{1,7}\s?|sic)\|)([^}]+)(\})/gi, protect_function)
.replace(/((?:image\d?|image_skyline|image[ _]___location\d?|image[ _]name|image[ _]file|img|pic)\s*=)([^|}]*)([|}])/gi, protect_function)
.replace(/([\|\{]\s*(?:file(?:name\d?|)|image\d?|image ___location\d?|img|pic|Cover|title|quote|chapter|journal|url|archiveurl|work|doi|club|at|volume|reporter)\s*=)([^|\}⍍]*)([|}])/gi, protect_function)
.replace(/([\|\{]\s*(?:file(?:name\d?|)|image\d?|image ___location\d?|img|pic|Cover|title|quote|chapter|journal|url|archiveurl|work|doi|club|at|volume|reporter)\s*=)([^|\}⍍]*)([|}])/gi, protect_function)
.replace(/([\|\{]\s*(?:season)\s*=)(\s*\[\[[^\]]*\]\]\s*)([|}])/gi, protect_function)
.replace(/(\{\{navsource\|)([^}]+)(\})/gi, protect_function)
.replace(/(\{\{singlechart\|)([^}]+)(\})/gi, protect_function)
.replace(/(\{\{defaultsort:)([^}]+)(\})/gi, protect_function)
.replace(/([\s\(>]")([^"\n]*)(")/gi, protect_function)
.replace(/([\s\(>]“)([^”\n]*)(”)/gi, protect_function)
.replace(/(.)(\(\{\{by\|[12]\d{3}\}\}[-–]\{\{by\|)([12]\d{3}[ ]*\}\}\))/gi, protect_function)
.replace(/(.)(\(\{\{by\|[12]\d{3}\}\}(?:[-–]present|))(\))/gi, protect_function);
}
function ohc_unprotect_dates(editor) {
editor
//unprotect all dates
.replace(/[♫]/g, '')
.replace(/⍌([0-9]+)⍍/g, function (x, n) {
var res = linkmap[n];
res = res.replace(/⍌([0-9]+)⍍/g, function (x, n) {
var res = linkmap[n];
res = res.replace(/⍌([0-9]+)⍍/g, function (x, n) {
returnvar res = linkmap[n];
res = res.replace(/⍌([0-9]+)⍍/g, function (x, n) {
return linkmap[n];
});
return res;
});
return res;
return res;
});
return res;
});
}
function ohc_MOSNUM_edit_summary(editor) {
editor
{
.options({ minor: true })
//Add a tag to the summary box
.appendEditSummary("[[Wikipedia:MOSNUMscript|script]]-assisted date audit and style fixes per [[MOS:NUM]]")
setoptions(minor = 'true');
.clickDiff();
setreason('date formats per [[MOS:DATEFORMAT]] by [[WP:MOSNUMscript|script]]', 'append');
doaction('diff');
}
function ohc_bigendien_edit_summary(editor) {
// add a tag to the summary box
{
editor
//Add a tag to the summary box
setoptions .options({ minor: = 'true' });
setreason .appendEditSummary('"ymd ref dates', 'append'");
.clickDiff();
doaction('diff');
}
function ohc_expand_edit_summary(editor) {
// add a tag to the summary box
{
editor
//Add a tag to the summary box
setoptions .options({ minor: = 'true' });
setreason .appendEditSummary('"expand month names', 'append'");
.clickDiff();
doaction('diff');
}
function ohc_slash_edit_summary(editor) {
// add a tag to the summary box
{
editor
//Add a tag to the summary box
setoptions .options({ minor: = 'true' });
setreason .appendEditSummary('"resolved slash dates', 'append'");
.clickDiff();
doaction('diff');
}
function ohc_abbrev_edit_summary(editor) {
// add a tag to the summary box
{
editor
//Add a tag to the summary box
setoptions .options({ minor: = 'true' });
setreason .appendEditSummary('"abbrev month names', 'append'");
.clickDiff();
doaction('diff');
}
/** ------------------------------------------------------------------------ **/
/// CUSTOMIZATION POINTS
function ohc_customize_all_to_dmy(editor) { }
function ohc_customize_all_to_mdy(editor) { }
}
function ohc_customize_body_to_dmy(editor) { }
function ohc_customize_body_to_mdy(editor) { }
function ohc_customize_ISO_to_dmy(editor) { }
function ohc_customize_ISO_to_mdy(editor) { }
/** ------------------------------------------------------------------------ **/
function ohc_customize_all_to_mdy() {
function ohc_body_dates_to_dmy(editor) {
}
ohc_use_dates_template(editor, "dmy");
ohc_fix_common_errors(editor);
function ohc_customize_body_to_dmy() {
ohc_fix_dts_template(editor, "dmy");
ohc_fix_gr_template(editor, "dmy");
ohc_dates_to_dmy(editor);
ohc_remove_leading_zeroes(editor);
ohc_fix_dmy_redundancies(editor);
}
function ohc_customize_body_to_mdyohc_body_dates_to_mdy(editor) {
ohc_use_dates_template(editor, "mdy");
ohc_fix_common_errors(editor);
ohc_fix_dts_template(editor, "mdy");
ohc_fix_gr_template(editor, "mdy");
ohc_dates_to_mdy(editor);
ohc_remove_leading_zeroes(editor);
ohc_fix_mdy_redundancies(editor);
}
/** ------------------------------------------------------------------------ **/
function ohc_customize_ISO_to_dmy() {
function ohc_all_to_dmy_driver(editor) {
}
ohc_extend_editor(editor);
ohc_delink_dates(editor);
ohc_protect_dates(editor);
ohc_fix_unambiguous_dates(editor);
ohc_body_dates_to_dmy(editor);
ohc_delink_ISO_to_dmy(editor);
//ohc_delink_year_in_X(editor);
ohc_customize_all_to_dmy(editor);
ohc_ISO_to_dmy_in_citations(editor);
ohc_unprotect_dates(editor);
ohc_MOSNUM_edit_summary(editor);
function ohc_customize_ISO_to_mdy() {
}
function ohc_all_to_mdy_driver(editor) {
/** ------------------------------------------------------------------------ **/
ohc_extend_editor(editor);
/// DRIVER FUNCTIONS
ohc_delink_dates(editor);
function ohc_body_dates_to_dmy()
ohc_protect_dates(editor);
{
ohc_fix_unambiguous_dates(editor);
ohc_use_dates_template('dmy');
ohc_body_dates_to_mdy(editor);
ohc_delink_ISO_to_mdy(editor);
//ohc_delink_year_in_X(editor);
ohc_customize_all_to_mdy();
ohc_ISO_to_mdy_in_citations(editor);
ohc_unprotect_dates(editor);
ohc_MOSNUM_edit_summary(editor);
ohc_fix_common_errors();
ohc_fix_dts_template('dmy');
ohc_fix_gr_template('dmy');
ohc_dates_to_dmy();
ohc_remove_leading_zeroes();
ohc_fix_dmy_redundancies();
}
function ohc_body_dates_to_mdyohc_dmy_cs1_ly_driver(editor) {
ohc_extend_editor(editor);
{
ohc_use_dates_template('mdy');
ohc_delink_dates(editor);
ohc_fix_common_errors();
ohc_protect_dates(editor);
ohc_fix_dts_template('mdy');
ohc_fix_unambiguous_dates(editor);
ohc_fix_gr_template('mdy');
ohc_body_dates_to_dmy(editor);
ohc_dates_to_mdy();
ohc_delink_ISO_to_dmy(editor);
ohc_remove_leading_zeroes();
//ohc_delink_year_in_X(editor);
ohc_fix_mdy_redundancies();
ohc_customize_all_to_dmy(editor);
ohc_ISO_to_dmy_in_citations(editor);
ohc_unprotect_dates(editor);
ohc_refs_to_yyyymmdd(editor);
ohc_MOSNUM_edit_summary(editor);
}
function ohc_mdy_cs1_ly_driver(editor) {
/** ------------------------------------------------------------------------ **/
ohc_extend_editor(editor);
/// DRIVER FUNCTIONS
function ohc_all_to_dmy_driver(e)
{
e.preventDefault();
ohc_delink_dates();
ohc_protect_dates();
ohc_fix_unambiguous_dates();
ohc_body_dates_to_dmy();
ohc_delink_ISO_to_dmy();
ohc_delink_year_in_X();
ohc_customize_all_to_dmy();
ohc_ISO_to_dmy_in_citations();
ohc_unprotect_dates();
ohc_delink_dates(editor);
ohc_MOSNUM_edit_summary();
ohc_protect_dates(editor);
ohc_fix_unambiguous_dates(editor);
ohc_body_dates_to_mdy(editor);
ohc_delink_ISO_to_mdy(editor);
//ohc_delink_year_in_X(editor);
ohc_customize_all_to_mdy();
ohc_ISO_to_mdy_in_citations(editor);
ohc_unprotect_dates(editor);
ohc_refs_to_yyyymmdd(editor);
ohc_MOSNUM_edit_summary(editor);
}
function ohc_all_to_mdy_driverohc_bigendian_driver(eeditor) {
ohc_refs_to_yyyymmdd(editor);
{
e.preventDefault();
ohc_delink_dates();
ohc_protect_dates();
ohc_fix_unambiguous_dates();
ohc_body_dates_to_mdy();
ohc_delink_ISO_to_mdy();
ohc_delink_year_in_X();
ohc_customize_all_to_mdy();
ohc_ISO_to_mdy_in_citations();
ohc_unprotect_dates();
ohc_bigendien_edit_summary(editor);
ohc_MOSNUM_edit_summary();
}
function ohc_dmy_publication_dates_driver(eeditor) {
ohc_dmy_publication_dates(editor);
{
e.preventDefault();
// ohc_delink_dates();
ohc_protect_dates();
ohc_body_dates_to_dmy();
ohc_customize_body_to_dmy();
ohc_dmy_publication_dates();
ohc_unprotect_dates();
ohc_MOSNUM_edit_summary(editor);
}
function ohc_mdy_publication_dates_driver(eeditor) {
ohc_extend_editor(editor);
{
e.preventDefault();
// ohc_delink_dates();
ohc_protect_dates();
ohc_body_dates_to_mdy();
ohc_customize_body_to_mdy();
ohc_mdy_publication_dates();
ohc_unprotect_dates();
//ohc_delink_dates(editor);
ohc_MOSNUM_edit_summary();
ohc_protect_dates(editor);
ohc_body_dates_to_mdy(editor);
ohc_customize_body_to_mdy(editor);
ohc_mdy_publication_dates(editor);
ohc_unprotect_dates(editor);
ohc_MOSNUM_edit_summary(editor);
}
function ohc_body_to_dmy_driver(eeditor) {
ohc_extend_editor(editor);
{
e.preventDefault();
// ohc_delink_dates();
ohc_protect_dates_ref();
ohc_body_dates_to_dmy();
ohc_customize_body_to_dmy();
ohc_unprotect_dates();
//ohc_delink_dates(editor);
ohc_MOSNUM_edit_summary();
ohc_protect_dates_ref(editor);
ohc_body_dates_to_dmy(editor);
ohc_customize_body_to_dmy(editor);
ohc_unprotect_dates(editor);
ohc_MOSNUM_edit_summary(editor);
}
function ohc_body_to_mdy_driver(eeditor) {
ohc_extend_editor(editor);
{
e.preventDefault();
// ohc_delink_dates(editor);
ohc_protect_dates_ref(editor);
ohc_body_dates_to_mdy(editor);
ohc_customize_body_to_mdy(editor);
ohc_unprotect_dates(editor);
ohc_MOSNUM_edit_summary(editor);
}
function ohc_ISO_to_dmy_driver(eeditor) {
ohc_extend_editor(editor);
{
e.preventDefault();
ohc_protect_dates();
ohc_delink_ISO_to_dmy();
ohc_customize_ISO_to_dmy();
ohc_unprotect_dates();
ohc_protect_dates(editor);
// ohc_MOSNUM_edit_summary();
ohc_delink_ISO_to_dmy(editor);
ohc_customize_ISO_to_dmy(editor);
ohc_unprotect_dates(editor);
//ohc_MOSNUM_edit_summary(editor);
}
function ohc_ISO_to_mdy_driver(eeditor) {
ohc_extend_editor(editor);
e.preventDefault();
ohc_protect_dates();
ohc_delink_ISO_to_mdy();
ohc_customize_ISO_to_mdy();
ohc_unprotect_dates();
ohc_protect_dates(editor);
// ohc_MOSNUM_edit_summary();
ohc_delink_ISO_to_mdy(editor);
}
ohc_customize_ISO_to_mdy(editor);
ohc_unprotect_dates(editor);
//ohc_MOSNUM_edit_summary(editor);
function ohc_delink_year_in_X_driver(e)
{
e.preventDefault();
ohc_delink_year_in_X();
}
function ohc_Bigendian_ref_dates_driverohc_delink_year_in_X_driver(eeditor) {
ohc_extend_editor(editor);
{
e.preventDefault();
ohc_delink_year_in_X(editor);
// Add a tag to the summary box
ohc_Bigendian_ref_dates();
ohc_bigendien_edit_summary();
}
function ohc_expand_ref_dates_driver(eeditor) {
ohc_extend_editor(editor);
e.preventDefault();
ohc_expand_ref_dates();
ohc_expand_ref_dates(editor);
ohc_protect_dates();
ohc_protect_dates(editor);
ohc_unprotect_dates();
ohc_unprotect_dates(editor);
ohc_expand_edit_summary();
ohc_expand_edit_summary(editor);
}
function ohc_expand_all_dates_driver(eeditor) {
ohc_extend_editor(editor);
{
e.preventDefault();
ohc_expand_ref_dates(editor);
ohc_protect_dates(editor);
ohc_expand_all_dates(editor);
ohc_unprotect_dates(editor);
ohc_expand_edit_summary(editor);
}
function ohc_abbrev_ref_dates_driver(eeditor) {
ohc_extend_editor(editor);
{
e.preventDefault();
ohc_protect_dates(editor);
ohc_abbrev_ref_dates(editor);
ohc_unprotect_dates(editor);
ohc_slash_edit_summary(editor);
}
function ohc_UK_slash_dates_driver(eeditor) {
ohc_extend_editor(editor);
{
e.preventDefault();
ohc_expand_ref_dates(editor);
ohc_protect_dates_slash(editor);
ohc_UK_slash_dates_to_dmy();
ohc_UK_slash_dates_to_dmy(editor);
ohc_slash_edit_summary();
ohc_unprotect_dates(editor);
ohc_slash_edit_summary(editor);
}
function ohc_US_slash_dates_driver(eeditor) {
ohc_extend_editor(editor);
{
e.preventDefault();
ohc_expand_ref_dates(editor);
ohc_protect_dates_slash(editor);
ohc_US_slash_dates_to_mdy();
ohc_US_slash_dates_to_mdy(editor);
ohc_expand_edit_summary();
ohc_unprotect_dates(editor);
ohc_expand_edit_summary(editor);
}
|