typograf 7.4.4 → 7.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +15 -0
- package/LICENSE.md +1 -1
- package/dist/data/en-GB.d.ts +1 -0
- package/dist/data/it.d.ts +1 -0
- package/dist/htmlEntities/index.d.ts +7 -4
- package/dist/rules/common/nbsp/afterShortWord.d.ts +0 -1
- package/dist/rules/common/nbsp/afterShortWordByList.d.ts +4 -0
- package/dist/rules/common/nbsp/afterShortWordByList.test.d.ts +1 -0
- package/dist/typograf.all.js +64 -41
- package/dist/typograf.all.min.js +1 -1
- package/dist/typograf.es.mjs +63 -40
- package/dist/typograf.js +63 -40
- package/dist/typograf.min.js +1 -1
- package/dist/typograf.titles.js +1 -1
- package/dist/typograf.titles.json +1 -1
- package/dist/version.d.ts +1 -1
- package/docs/RULES.en-US.md +94 -93
- package/docs/RULES.ru.md +94 -93
- package/docs/RULES_SORTED.en-US.md +41 -40
- package/docs/RULES_SORTED.ru.md +41 -40
- package/docs/api_attrs.md +1 -1
- package/docs/api_entities.md +5 -5
- package/docs/api_fly.md +1 -1
- package/docs/api_localization.md +3 -3
- package/docs/api_nbsp.md +1 -1
- package/docs/api_optalign.md +1 -1
- package/docs/api_parts.md +1 -1
- package/docs/api_rules.md +2 -2
- package/docs/using.md +12 -3
- package/package.json +17 -17
package/dist/typograf.js
CHANGED
|
@@ -312,11 +312,13 @@
|
|
|
312
312
|
this.entitiesByName = {};
|
|
313
313
|
this.entitiesByNameEntity = {};
|
|
314
314
|
this.entitiesByDigitEntity = {};
|
|
315
|
+
this.entitiesByJsEntity = {};
|
|
315
316
|
this.entitiesByUtf = {};
|
|
316
317
|
this.entities.forEach(function (entity) {
|
|
317
318
|
_this.entitiesByName[entity.name] = entity;
|
|
318
|
-
_this.entitiesByNameEntity[entity.
|
|
319
|
-
_this.entitiesByDigitEntity[entity.
|
|
319
|
+
_this.entitiesByNameEntity[entity.type.name] = entity;
|
|
320
|
+
_this.entitiesByDigitEntity[entity.type.digit] = entity;
|
|
321
|
+
_this.entitiesByJsEntity[entity.type.js] = entity;
|
|
320
322
|
_this.entitiesByUtf[entity.utf] = entity;
|
|
321
323
|
});
|
|
322
324
|
this.invisibleEntities = this.prepareEntities(invisibleEntities);
|
|
@@ -326,9 +328,11 @@
|
|
|
326
328
|
*/
|
|
327
329
|
HtmlEntities.prototype.toUtf = function (context) {
|
|
328
330
|
var _this = this;
|
|
331
|
+
//  
|
|
329
332
|
if (context.text.search(/&#/) !== -1) {
|
|
330
333
|
context.text = this.decHexToUtf(context.text);
|
|
331
334
|
}
|
|
335
|
+
//
|
|
332
336
|
if (context.text.search(/&[a-z]/i) !== -1) {
|
|
333
337
|
// 2 - min length of entity without & and ;. Example: ⅅ
|
|
334
338
|
// 31 - max length of entity without & and ;. Example: ∳
|
|
@@ -337,6 +341,13 @@
|
|
|
337
341
|
return entity ? entity.utf : key;
|
|
338
342
|
});
|
|
339
343
|
}
|
|
344
|
+
// \u00a0
|
|
345
|
+
if (context.text.search(/\\u[\da-f]/i) !== -1) {
|
|
346
|
+
context.text = context.text.replace(/\\u[\da-f]{4};/gi, function (key) {
|
|
347
|
+
var entity = _this.entitiesByJsEntity[key.toLowerCase()];
|
|
348
|
+
return entity ? entity.utf : key;
|
|
349
|
+
});
|
|
350
|
+
}
|
|
340
351
|
};
|
|
341
352
|
/**
|
|
342
353
|
* Entities in decimal or hexadecimal form to UTF-8.
|
|
@@ -356,38 +367,34 @@
|
|
|
356
367
|
HtmlEntities.prototype.restore = function (context) {
|
|
357
368
|
var params = context.prefs.htmlEntity;
|
|
358
369
|
var type = params.type;
|
|
370
|
+
if (type === 'default') {
|
|
371
|
+
return;
|
|
372
|
+
}
|
|
359
373
|
var entities = this.entities;
|
|
360
|
-
if (
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
entities = entities.concat(this.prepareListParam(params.list));
|
|
368
|
-
}
|
|
374
|
+
if (params.onlyInvisible || params.list) {
|
|
375
|
+
entities = [];
|
|
376
|
+
if (params.onlyInvisible) {
|
|
377
|
+
entities = entities.concat(this.invisibleEntities);
|
|
378
|
+
}
|
|
379
|
+
if (params.list) {
|
|
380
|
+
entities = entities.concat(this.prepareListParam(params.list));
|
|
369
381
|
}
|
|
370
|
-
var entityType = type === 'name' ? 'nameEntity' : 'digitEntity';
|
|
371
|
-
context.text = this.restoreEntitiesByIndex(context.text, entityType, entities);
|
|
372
382
|
}
|
|
383
|
+
context.text = this.restoreEntitiesByIndex(context.text, type, entities);
|
|
373
384
|
};
|
|
374
385
|
/**
|
|
375
386
|
* Get a entity by utf using the type.
|
|
376
387
|
*/
|
|
377
388
|
HtmlEntities.prototype.getByUtf = function (symbol, type) {
|
|
378
|
-
var result;
|
|
379
389
|
switch (type) {
|
|
380
390
|
case 'digit':
|
|
381
|
-
|
|
382
|
-
break;
|
|
391
|
+
return this.entitiesByDigitEntity[symbol];
|
|
383
392
|
case 'name':
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
result = symbol;
|
|
388
|
-
break;
|
|
393
|
+
return this.entitiesByNameEntity[symbol];
|
|
394
|
+
case 'js':
|
|
395
|
+
return this.entitiesByJsEntity[symbol];
|
|
389
396
|
}
|
|
390
|
-
return
|
|
397
|
+
return symbol;
|
|
391
398
|
};
|
|
392
399
|
HtmlEntities.prototype.prepareEntities = function (entities) {
|
|
393
400
|
var result = [];
|
|
@@ -396,11 +403,13 @@
|
|
|
396
403
|
var utf = String.fromCharCode(digit);
|
|
397
404
|
result.push({
|
|
398
405
|
name: name,
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
406
|
+
utf: utf, // \u00a0
|
|
407
|
+
reUtf: new RegExp(utf, 'g'),
|
|
408
|
+
type: {
|
|
409
|
+
name: '&' + name + ';', //
|
|
410
|
+
digit: '&#' + digit + ';', //  
|
|
411
|
+
js: '\\u' + ('0000' + digit.toString(16)).slice(-4), // \u00a0
|
|
412
|
+
},
|
|
404
413
|
});
|
|
405
414
|
});
|
|
406
415
|
return result;
|
|
@@ -418,7 +427,7 @@
|
|
|
418
427
|
};
|
|
419
428
|
HtmlEntities.prototype.restoreEntitiesByIndex = function (text, type, entities) {
|
|
420
429
|
entities.forEach(function (entity) {
|
|
421
|
-
text = text.replace(entity.reUtf, entity[type]);
|
|
430
|
+
text = text.replace(entity.reUtf, entity.type[type]);
|
|
422
431
|
});
|
|
423
432
|
return text;
|
|
424
433
|
};
|
|
@@ -806,7 +815,7 @@
|
|
|
806
815
|
return preparedRule;
|
|
807
816
|
}
|
|
808
817
|
|
|
809
|
-
var PACKAGE_VERSION = '7.
|
|
818
|
+
var PACKAGE_VERSION = '7.6.0';
|
|
810
819
|
|
|
811
820
|
function prepareHtmlEntity(htmlEntity) {
|
|
812
821
|
var result = {
|
|
@@ -1213,7 +1222,8 @@
|
|
|
1213
1222
|
'en-GB/quote': {
|
|
1214
1223
|
left: '‘“',
|
|
1215
1224
|
right: '’”',
|
|
1216
|
-
}
|
|
1225
|
+
},
|
|
1226
|
+
'en-GB/shortWord': 'a|an|and|as|at|bar|but|by|for|if|in|nor|not|of|off|on|or|out|per|pro|so|the|to|up|via|yet',
|
|
1217
1227
|
};
|
|
1218
1228
|
|
|
1219
1229
|
var enUS = {
|
|
@@ -1287,7 +1297,8 @@
|
|
|
1287
1297
|
'it/quote': {
|
|
1288
1298
|
left: '«“',
|
|
1289
1299
|
right: '»”',
|
|
1290
|
-
}
|
|
1300
|
+
},
|
|
1301
|
+
'it/shortWord': 'a|da|di|in|la|il|lo|e|o|se|su|che|come|ma|è|ho|ha|sa',
|
|
1291
1302
|
};
|
|
1292
1303
|
|
|
1293
1304
|
var lv = {
|
|
@@ -1346,7 +1357,7 @@
|
|
|
1346
1357
|
removeDuplicateQuotes: true,
|
|
1347
1358
|
},
|
|
1348
1359
|
'ru/shortMonth': 'янв|фев|мар|апр|ма[ейя]|июн|июл|авг|сен|окт|ноя|дек',
|
|
1349
|
-
'ru/shortWord': '
|
|
1360
|
+
'ru/shortWord': 'а|без|в|во|если|да|до|для|за|и|или|из|к|ко|как|ли|на|но|не|ни|о|об|обо|от|по|про|при|под|с|со|то|у',
|
|
1350
1361
|
'ru/weekday': 'понедельник|вторник|среда|четверг|пятница|суббота|воскресенье',
|
|
1351
1362
|
};
|
|
1352
1363
|
|
|
@@ -1643,14 +1654,11 @@
|
|
|
1643
1654
|
var afterShortWordRule = {
|
|
1644
1655
|
name: 'common/nbsp/afterShortWord',
|
|
1645
1656
|
handler: function (text, settings, context) {
|
|
1646
|
-
var lengthShortWord = settings.lengthShortWord
|
|
1657
|
+
var lengthShortWord = settings.lengthShortWord;
|
|
1647
1658
|
var quote = getData('common/quote');
|
|
1648
1659
|
var char = context.getData('char');
|
|
1649
|
-
var shortWord = context.getData('shortWord');
|
|
1650
1660
|
var before = ' \u00A0(' + privateLabel + quote;
|
|
1651
|
-
var subStr =
|
|
1652
|
-
? '(^|[' + before + '])(' + shortWord + ') '
|
|
1653
|
-
: '(^|[' + before + '])([' + char + ']{1,' + lengthShortWord + '}) ';
|
|
1661
|
+
var subStr = '(^|[' + before + '])([' + char + ']{1,' + lengthShortWord + '}) ';
|
|
1654
1662
|
var newSubStr = '$1$2\u00A0';
|
|
1655
1663
|
var re = new RegExp(subStr, 'gim');
|
|
1656
1664
|
return text
|
|
@@ -1659,7 +1667,21 @@
|
|
|
1659
1667
|
},
|
|
1660
1668
|
settings: {
|
|
1661
1669
|
lengthShortWord: 2,
|
|
1662
|
-
|
|
1670
|
+
},
|
|
1671
|
+
};
|
|
1672
|
+
|
|
1673
|
+
var afterShortWordByListRule = {
|
|
1674
|
+
name: 'common/nbsp/afterShortWordByList',
|
|
1675
|
+
handler: function (text, _, context) {
|
|
1676
|
+
var quote = getData('common/quote');
|
|
1677
|
+
var shortWord = context.getData('shortWord');
|
|
1678
|
+
var before = ' \u00A0(' + privateLabel + quote;
|
|
1679
|
+
var subStr = '(^|[' + before + '])(' + shortWord + ') ';
|
|
1680
|
+
var newSubStr = '$1$2\u00A0';
|
|
1681
|
+
var re = new RegExp(subStr, 'gim');
|
|
1682
|
+
return text
|
|
1683
|
+
.replace(re, newSubStr)
|
|
1684
|
+
.replace(re, newSubStr);
|
|
1663
1685
|
},
|
|
1664
1686
|
};
|
|
1665
1687
|
|
|
@@ -1729,6 +1751,7 @@
|
|
|
1729
1751
|
afterParagraphMarkRule,
|
|
1730
1752
|
afterSectionMarkRule,
|
|
1731
1753
|
afterShortWordRule,
|
|
1754
|
+
afterShortWordByListRule,
|
|
1732
1755
|
beforeShortLastNumberRule,
|
|
1733
1756
|
beforeShortLastWordRule,
|
|
1734
1757
|
dpiRule,
|
|
@@ -1817,9 +1840,9 @@
|
|
|
1817
1840
|
handler: function (text, settings, context) {
|
|
1818
1841
|
var quote = getData('common/quote');
|
|
1819
1842
|
var char = context.getData('char');
|
|
1820
|
-
var punc = '[;:,.?! \n' + quote + ']';
|
|
1843
|
+
var punc = '[;:,.?! \u00a0\n' + quote + ']';
|
|
1821
1844
|
var re = new RegExp('(' + punc + '|^)' +
|
|
1822
|
-
'([' + char + ']{' + settings.min + ',}) ' +
|
|
1845
|
+
'([' + char + ']{' + settings.min + ',})[ \u00a0]' +
|
|
1823
1846
|
'\\2(' + punc + '|$)', 'gi');
|
|
1824
1847
|
return text.replace(re, '$1$2$3');
|
|
1825
1848
|
},
|
package/dist/typograf.min.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/*! typograf | © 2025 Denis Seleznev | MIT License | https://github.com/typograf/typograf */
|
|
2
|
-
((e,t)=>{"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).Typograf=t()})(this,function(){var r=function(){return(r=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var a in t=arguments[n])Object.prototype.hasOwnProperty.call(t,a)&&(e[a]=t[a]);return e}).apply(this,arguments)};function n(e,t,n){if(n||2===arguments.length)for(var r,a=0,i=t.length;a<i;a++)!r&&a in t||((r=r||Array.prototype.slice.call(t,0,a))[a]=t[a]);return e.concat(r||Array.prototype.slice.call(t))}var P=[["iexcl",161],["cent",162],["pound",163],["curren",164],["yen",165],["brvbar",166],["sect",167],["uml",168],["copy",169],["ordf",170],["laquo",171],["not",172],["reg",174],["macr",175],["deg",176],["plusmn",177],["sup2",178],["sup3",179],["acute",180],["micro",181],["para",182],["middot",183],["cedil",184],["sup1",185],["ordm",186],["raquo",187],["frac14",188],["frac12",189],["frac34",190],["iquest",191],["Agrave",192],["Aacute",193],["Acirc",194],["Atilde",195],["Auml",196],["Aring",197],["AElig",198],["Ccedil",199],["Egrave",200],["Eacute",201],["Ecirc",202],["Euml",203],["Igrave",204],["Iacute",205],["Icirc",206],["Iuml",207],["ETH",208],["Ntilde",209],["Ograve",210],["Oacute",211],["Ocirc",212],["Otilde",213],["Ouml",214],["times",215],["Oslash",216],["Ugrave",217],["Uacute",218],["Ucirc",219],["Uuml",220],["Yacute",221],["THORN",222],["szlig",223],["agrave",224],["aacute",225],["acirc",226],["atilde",227],["auml",228],["aring",229],["aelig",230],["ccedil",231],["egrave",232],["eacute",233],["ecirc",234],["euml",235],["igrave",236],["iacute",237],["icirc",238],["iuml",239],["eth",240],["ntilde",241],["ograve",242],["oacute",243],["ocirc",244],["otilde",245],["ouml",246],["divide",247],["oslash",248],["ugrave",249],["uacute",250],["ucirc",251],["uuml",252],["yacute",253],["thorn",254],["yuml",255],["fnof",402],["Alpha",913],["Beta",914],["Gamma",915],["Delta",916],["Epsilon",917],["Zeta",918],["Eta",919],["Theta",920],["Iota",921],["Kappa",922],["Lambda",923],["Mu",924],["Nu",925],["Xi",926],["Omicron",927],["Pi",928],["Rho",929],["Sigma",931],["Tau",932],["Upsilon",933],["Phi",934],["Chi",935],["Psi",936],["Omega",937],["alpha",945],["beta",946],["gamma",947],["delta",948],["epsilon",949],["zeta",950],["eta",951],["theta",952],["iota",953],["kappa",954],["lambda",955],["mu",956],["nu",957],["xi",958],["omicron",959],["pi",960],["rho",961],["sigmaf",962],["sigma",963],["tau",964],["upsilon",965],["phi",966],["chi",967],["psi",968],["omega",969],["thetasym",977],["upsih",978],["piv",982],["bull",8226],["hellip",8230],["prime",8242],["Prime",8243],["oline",8254],["frasl",8260],["weierp",8472],["image",8465],["real",8476],["trade",8482],["alefsym",8501],["larr",8592],["uarr",8593],["rarr",8594],["darr",8595],["harr",8596],["crarr",8629],["lArr",8656],["uArr",8657],["rArr",8658],["dArr",8659],["hArr",8660],["forall",8704],["part",8706],["exist",8707],["empty",8709],["nabla",8711],["isin",8712],["notin",8713],["ni",8715],["prod",8719],["sum",8721],["minus",8722],["lowast",8727],["radic",8730],["prop",8733],["infin",8734],["ang",8736],["and",8743],["or",8744],["cap",8745],["cup",8746],["int",8747],["there4",8756],["sim",8764],["cong",8773],["asymp",8776],["ne",8800],["equiv",8801],["le",8804],["ge",8805],["sub",8834],["sup",8835],["nsub",8836],["sube",8838],["supe",8839],["oplus",8853],["otimes",8855],["perp",8869],["sdot",8901],["lceil",8968],["rceil",8969],["lfloor",8970],["rfloor",8971],["lang",9001],["rang",9002],["spades",9824],["clubs",9827],["hearts",9829],["diams",9830],["loz",9674],["OElig",338],["oelig",339],["Scaron",352],["scaron",353],["Yuml",376],["circ",710],["tilde",732],["ndash",8211],["mdash",8212],["lsquo",8216],["rsquo",8217],["sbquo",8218],["ldquo",8220],["rdquo",8221],["bdquo",8222],["dagger",8224],["Dagger",8225],["permil",8240],["lsaquo",8249],["rsaquo",8250],["euro",8364],["NestedGreaterGreater",8811],["NestedLessLess",8810]],e=[["nbsp",160],["thinsp",8201],["ensp",8194],["emsp",8195],["shy",173],["zwnj",8204],["zwj",8205],["lrm",8206],["rlm",8207]];function t(){var t=this;this.entities=this.prepareEntities(n(n([],P,!0),e,!0)),this.entitiesByName={},this.entitiesByNameEntity={},this.entitiesByDigitEntity={},this.entitiesByUtf={},this.entities.forEach(function(e){t.entitiesByName[e.name]=e,t.entitiesByNameEntity[e.nameEntity]=e,t.entitiesByDigitEntity[e.digitEntity]=e,t.entitiesByUtf[e.utf]=e}),this.invisibleEntities=this.prepareEntities(e)}t.prototype.toUtf=function(e){var n=this;-1!==e.text.search(/&#/)&&(e.text=this.decHexToUtf(e.text)),-1!==e.text.search(/&[a-z]/i)&&(e.text=e.text.replace(/&[a-z\d]{2,31};/gi,function(e){var t=n.entitiesByNameEntity[e];return t?t.utf:e}))},t.prototype.decHexToUtf=function(e){return e.replace(/&#(\d{1,6});/gi,function(e,t){return String.fromCharCode(parseInt(t,10))}).replace(/&#x([\da-f]{1,6});/gi,function(e,t){return String.fromCharCode(parseInt(t,16))})},t.prototype.restore=function(e){var t=e.prefs.htmlEntity,n=t.type,r=this.entities;"name"!==n&&"digit"!==n||((t.onlyInvisible||t.list)&&(r=[],t.onlyInvisible&&(r=r.concat(this.invisibleEntities)),t.list)&&(r=r.concat(this.prepareListParam(t.list))),e.text=this.restoreEntitiesByIndex(e.text,"name"===n?"nameEntity":"digitEntity",r))},t.prototype.getByUtf=function(e,t){var n;switch(t){case"digit":n=this.entitiesByDigitEntity[e];break;case"name":n=this.entitiesByNameEntity[e];break;default:n=e}return n},t.prototype.prepareEntities=function(e){var r=[];return e.forEach(function(e){var t=e[0],e=e[1],n=String.fromCharCode(e);r.push({name:t,nameEntity:"&"+t+";",digitEntity:"&#"+e+";",utf:n,reName:new RegExp("&"+t+";","g"),reUtf:new RegExp(n,"g")})}),r},t.prototype.prepareListParam=function(e){var t=this,n=[];return e.forEach(function(e){e=t.entitiesByName[e];e&&n.push(e)}),n},t.prototype.restoreEntitiesByIndex=function(t,n,e){return e.forEach(function(e){t=t.replace(e.reUtf,e[n])}),t};var o=new t,a=[];function i(e){e=(e||"").split("/")[0];e&&"common"!==e&&!s(e)&&(a.push(e),a.sort())}function s(e){return"common"===e||-1!==a.indexOf(e)}function u(e,t){e=e||t;return e?Array.isArray(e)?e:[e]:[]}function l(e){if(!e.length)throw Error('Not defined the property "locale".');e.forEach(function(e){if(!s(e))throw Error('"'.concat(e,'" is not supported locale.'))})}var c={};function N(e){return c[e]}function p(t){Object.keys(t).forEach(function(e){i(e),c[e]=t[e]})}var j=["a","abbr","acronym","b","bdo","big","br","button","cite","code","dfn","em","i","img","input","kbd","label","map","object","q","samp","script","select","small","span","strong","sub","sup","textarea","time","tt","var"],g=new RegExp("(https?|file|ftp)://([a-zA-Z0-9/+-=%&:_.~?]+[a-zA-Z0-9#+]*)","g"),h="\\d+([.,]\\d+)?",O=/\d/;function f(e){return-1<e.search(O)}var d="",m="",M=($.prototype.add=function(e){this.tags.own.push(this.prepareRegExp(e))},$.prototype.show=function(t,n){for(var e=new RegExp("tf\\d+","g"),r=new RegExp("tf\\d"),a=function(e){return t.safeTags.hidden[n][e]||e},i=0,o=this.tags[n].length;i<o&&(t.text=t.text.replace(e,a),-1!==t.text.search(r));i++);},$.prototype.hide=function(t,e){var n=this,r=(t.safeTags.hidden[e]={},this.pasteLabel.bind(this,t,e));this.tags[e].forEach(function(e){t.text=t.text.replace(n.prepareRegExp(e),r)})},$.prototype.hideHTMLTags=function(e){var t;e.isHTML&&(t=this.pasteLabel.bind(this,e,"html"),e.text=e.text.replace(/<\/?[a-z][^]*?>/gi,t).replace(/<\/?[a-z][^]*?>/gi,t).replace(/&[gl]t;/gi,t))},$.prototype.getPrevLabel=function(e,t){for(var n=t-1;0<=n;n--)if(e[n]===d)return e.slice(n,t+1);return""},$.prototype.getNextLabel=function(e,t){for(var n=t+1;n<e.length;n++)if(e[n]===d)return e.slice(t,n+1);return""},$.prototype.getTagByLabel=function(n,r){var a=null;return this.groups.some(function(e){var t=n.safeTags.hidden[e][r];return a=void 0!==t?{group:e,value:t}:a}),a},$.prototype.getTagInfo=function(e){if(!e)return null;var t={group:e.group};switch(e.group){case"html":t.name=e.value.split(/[<\s>]/)[1],t.isInline=-1<j.indexOf(t.name),t.isClosing=-1<e.value.search(/^<\//);break;case"url":t.isInline=!0;break;case"own":t.isInline=!1}return t},$.prototype.pasteLabel=function(e,t,n){var e=e.safeTags,r="tf"+e.counter+d;return e.hidden[t][r]=n,e.counter++,r},$.prototype.prepareRegExp=function(e){var t,n;return e instanceof RegExp?e:(t=e[0],n=e[2],new RegExp(t+(void 0===n?"[^]*?":n)+e[1],"gi"))},$.prototype.getPrevTagInfo=function(e,t,n){t=this.getPrevLabel(t,n-1);if(t){n=this.getTagByLabel(e,t);if(n)return this.getTagInfo(n)}return null},$.prototype.getNextTagInfo=function(e,t,n){t=this.getNextLabel(t,n+1);if(t){n=this.getTagByLabel(e,t);if(n)return this.getTagInfo(n)}return null},$);function $(){this.groups=["own","html","url"],this.hidden={},this.counter=0;var t=[["\x3c!--","--\x3e"],["<!ENTITY",">"],["<!DOCTYPE",">"],["<\\?xml","\\?>"],["<!\\[CDATA\\[","\\]\\]>"]];["code","kbd","object","pre","samp","script","style","var"].forEach(function(e){t.push(["<".concat(e,"(\\s[^>]*?)?>"),"</".concat(e,">")])}),this.tags={own:[],html:t.map(this.prepareRegExp),url:[g]}}function b(e,t){for(var n="";1==(1&t)&&(n+=e),0!=(t>>>=1);)e+=e;return n}function x(e){return e.replace(/\u00A0/g," ")}function v(e,t){for(var n=0;n<t.length;n++)e=e.replace(t[n][0],t[n][1]);return e}function U(e){return-1!==e.search(/(<\/?[a-z]|<!|&[lg]t;)/i)}function y(e){return"object"==typeof e?JSON.parse(JSON.stringify(e)):e}var Q={symbols:110,number:150,space:210,dash:310,punctuation:410,nbsp:510,money:710,date:810,other:910,optalign:1010,typo:1110,html:1210},F=0,H="default",W=[],G=[];function R(){var e=n([],W,!0);return e.sort(function(e,t){return e.index>t.index?1:-1}),e}function X(){return n([],G,!0)}function V(e){var t=e.name.split("/"),n=t[0];return{name:e.name,shortName:t[2],handler:e.handler,queue:e.queue||H,enabled:!0!==e.disabled,locale:n,group:t[1],index:"number"==typeof(n=e).index?n.index:(t=n.name.split("/")[1],void 0===(t=Q[t])&&(t=F),"string"==typeof n.index?t+parseInt(n.index,10):t),settings:e.settings,live:e.live,htmlAttrs:e.htmlAttrs}}function K(e){return{type:(null==e?void 0:e.type)||"default",list:null==e?void 0:e.list,onlyInvisible:Boolean(null==e?void 0:e.onlyInvisible)}}function Y(e){return e||"LF"}w.addRule=function(e){i((e=V(e=e)).locale),W.push(e)},w.addRules=function(e){var t=this;e.forEach(function(e){t.addRule(e)})},w.addInnerRule=function(e){G.push(V(e))},w.addInnerRules=function(e){var t=this;e.forEach(function(e){t.addInnerRule(e)})},w.getRule=function(t){var n=null;return R().some(function(e){return e.name===t&&(n=e,!0)}),n},w.getRules=R,w.getInnerRules=X,w.getLocales=function(){return a},w.addLocale=function(e){i(e)},w.hasLocale=s,w.setData=function(e){p(e)},w.getData=function(e){return c[e]},w.prototype.execute=function(e,t){var n;return(e=""+e)?(n=this.prefs,t=t,n=r({},n),t&&("locale"in t&&(n.locale=u(t.locale)),"htmlEntity"in t&&(n.htmlEntity=K(t.htmlEntity)),"lineEnding"in t&&(n.lineEnding=Y(t.lineEnding)),"processingSeparateParts"in t&&(n.processingSeparateParts=t.processingSeparateParts),"ruleFilter"in t)&&(n.ruleFilter=t.ruleFilter),l((t=n).locale),n=this.prepareContext(e,t),this.process(n)):""},w.prototype.getSetting=function(e,t){return this.settings[e]&&this.settings[e][t]},w.prototype.setSetting=function(e,t,n){this.settings[e]=this.settings[e]||{},this.settings[e][t]=n},w.prototype.isEnabledRule=function(e){return!1!==this.enabledRules[e]},w.prototype.isDisabledRule=function(e){return!this.enabledRules[e]},w.prototype.enableRule=function(e){return this.enable(e,!0)},w.prototype.disableRule=function(e){return this.enable(e,!1)},w.prototype.addSafeTag=function(e,t,n){e=e instanceof RegExp?e:[e,t,n];this.safeTags.add(e)},w.prototype.prepareContext=function(e,n){return{text:e,isHTML:U(e),prefs:n,getData:function(t){return"char"===t?n.locale.map(function(e){return c[e+"/"+t]}).join(""):N(n.locale[0]+"/"+t)},safeTags:this.safeTags}},w.prototype.splitBySeparateParts=function(a){var i,e,o;return a.isHTML&&!1!==a.prefs.processingSeparateParts?(i=[],e=new RegExp("<("+this.separatePartsTags.join("|")+")(\\s[^>]*?)?>[^]*?</\\1>","gi"),o=0,a.text.replace(e,function(e,t,n,r){return o!==r&&i.push((o?m:"")+a.text.slice(o,r)+m),i.push(e),o=r+e.length,e}),i.push(o?m+a.text.slice(o,a.text.length):a.text),i):[a.text]},w.prototype.process=function(t){var e,n=this,r=(t.text=t.text.replace(/\r\n?/g,"\n"),this.executeRules(t,"start"),this.safeTags.hide(t,"own"),this.executeRules(t,"hide-safe-tags-own"),this.safeTags.hide(t,"html"),this.executeRules(t,"hide-safe-tags-html"),t.isHTML),a=new RegExp(m,"g");return t.text=this.splitBySeparateParts(t).map(function(e){return t.text=e,t.isHTML=U(e),n.safeTags.hideHTMLTags(t),n.safeTags.hide(t,"url"),n.executeRules(t,"hide-safe-tags-url"),n.executeRules(t,"hide-safe-tags"),o.toUtf(t),t.prefs.live&&(t.text=x(t.text)),n.executeRules(t,"utf"),n.executeRules(t),o.restore(t),n.executeRules(t,"html-entities"),n.safeTags.show(t,"url"),n.executeRules(t,"show-safe-tags-url"),t.text.replace(a,"")}).join(""),t.isHTML=r,this.safeTags.show(t,"html"),this.executeRules(t,"show-safe-tags-html"),this.safeTags.show(t,"own"),this.executeRules(t,"show-safe-tags-own"),this.executeRules(t,"end"),r=t.text,"CRLF"===(e=t.prefs.lineEnding)?r.replace(/\n/g,"\r\n"):"CR"===e?r.replace(/\n/g,"\r"):r},w.prototype.executeRules=function(t,e){var n=this,r=this.rulesByQueues[e=void 0===e?H:e],e=this.innerRulesByQueues[e];e&&e.forEach(function(e){n.ruleIterator(t,e)}),r&&r.forEach(function(e){n.ruleIterator(t,e)})},w.prototype.ruleIterator=function(e,t){!0===e.prefs.live&&!1===t.live||!1===e.prefs.live&&!0===t.live||"common"!==t.locale&&t.locale!==e.prefs.locale[0]||!this.isEnabledRule(t.name)||e.prefs.ruleFilter&&!e.prefs.ruleFilter(t)||(this.onBeforeRule&&this.onBeforeRule(t.name,e),e.text=t.handler.call(this,e.text,this.settings[t.name],e),this.onAfterRule&&this.onAfterRule(t.name,e))},w.prototype.prepareRuleSettings=function(e){this.settings[e.name]=y(e.settings),this.enabledRules[e.name]=e.enabled},w.prototype.enable=function(e,t){var n=this;Array.isArray(e)?e.forEach(function(e){n.enableByMask(e,t)}):this.enableByMask(e,t)},w.prototype.enableByMask=function(e,t){var n,r=this;e&&(-1!==e.search(/\*/)?(n=new RegExp(e.replace(/\//g,"\\/").replace(/\*/g,".*")),this.rules.forEach(function(e){e=e.name;n.test(e)&&(r.enabledRules[e]=t)})):this.enabledRules[e]=t)},w.groups=[],w.titles={},w.version="7.4.4";var E=w;function w(e){var t=this;this.rules=[],this.innerRules=[],this.rulesByQueues={},this.innerRulesByQueues={},this.separatePartsTags=["title","p","h[1-6]","select","legend"],this.prefs={locale:u((e=e).locale),lineEnding:Y(e.lineEnding),live:Boolean(e.live),ruleFilter:e.ruleFilter,enableRule:e.enableRule,disableRule:e.disableRule,processingSeparateParts:e.processingSeparateParts,htmlEntity:K(e.htmlEntity)},l(this.prefs.locale),this.safeTags=new M,this.settings={},this.enabledRules={},this.innerRulesByQueues={},this.innerRules=X(),this.innerRules.forEach(function(e){t.innerRulesByQueues[e.queue]=t.innerRulesByQueues[e.queue]||[],t.innerRulesByQueues[e.queue].push(e)}),this.rulesByQueues={},this.rules=R(),this.rules.forEach(function(e){t.prepareRuleSettings(e),t.rulesByQueues[e.queue]=t.rulesByQueues[e.queue]||[],t.rulesByQueues[e.queue].push(e)}),this.prefs.disableRule&&this.disableRule(this.prefs.disableRule),this.prefs.enableRule&&this.enableRule(this.prefs.enableRule)}[{"common/char":"a-z","common/dash":"--?|‒|–|—","common/quote":'«‹»›„“‟”"'},{"be/char":"абвгдежзйклмнопрстуфхцчшыьэюяёіўґ","be/quote":{left:"«“",right:"»”"}},{"bg/char":"абвгдежзийклмнопрстуфхцчшщъьюя","bg/quote":{left:"„’",right:"“’"}},{"ca/char":"abcdefghijlmnopqrstuvxyzàçèéíïòóúü","ca/quote":{left:"«“",right:"»”"}},{"cs/char":"a-záéíóúýčďěňřšťůž","cs/quote":{left:"„‚",right:"“‘"}},{"da/char":"a-zåæø","da/quote":{left:"»›",right:"«‹"}},{"de/char":"a-zßäöü","de/quote":{left:"„‚",right:"“‘"}},{"el/char":"ΐάέήίΰαβγδεζηθικλμνξοπρςστυφχψωϊϋόύώϲάέήίόύώ","el/quote":{left:"«“",right:"»”"}},{"en-GB/char":"a-z","en-GB/quote":{left:"‘“",right:"’”"}},{"en-US/char":"a-z","en-US/quote":{left:"“‘",right:"”’"},"en-US/shortWord":"a|an|and|as|at|bar|but|by|for|if|in|nor|not|of|off|on|or|out|per|pro|so|the|to|up|via|yet"},{"eo/char":"abcdefghijklmnoprstuvzĉĝĥĵŝŭ","eo/quote":{left:"“‘",right:"”’"}},{"es/char":"a-záéíñóúü","es/quote":{left:"«“",right:"»”"}},{"et/char":"abdefghijklmnoprstuvzäõöüšž","et/quote":{left:"„«",right:"“»"}},{"fi/char":"abcdefghijklmnopqrstuvyöäå","fi/quote":{left:"”’",right:"”’"}},{"fr/char":"a-zàâçèéêëîïôûüœæ","fr/quote":{left:"«‹",right:"»›",spacing:!0}},{"ga/char":"abcdefghilmnoprstuvwxyzáéíóú","ga/quote":{left:"“‘",right:"”’"}},{"hu/char":"a-záäéíóöúüőű","hu/quote":{left:"„»",right:"”«"}},{"it/char":"a-zàéèìòù","it/quote":{left:"«“",right:"»”"}},{"lv/char":"abcdefghijklmnopqrstuvxzæœ","lv/quote":{left:"«„",right:"»“"}},{"nl/char":"a-zäçèéêëîïñöûü","nl/quote":{left:"‘“",right:"’”"}},{"no/char":"a-zåæèéêòóôø","no/quote":{left:"«’",right:"»’"}},{"pl/char":"abcdefghijklmnoprstuvwxyzóąćęłńśźż","pl/quote":{left:"„«",right:"”»"}},{"ro/char":"abcdefghijklmnoprstuvxzîășț","ro/quote":{left:"„«",right:"”»"}},{"ru/char":"а-яё","ru/dashBefore":"(^| |\\n)","ru/dashAfter":"(?=[ ,.?:!]|$)","ru/dashAfterDe":"(?=[,.?:!]|[ ][^А-ЯЁ]|$)","ru/l":"а-яёa-z","ru/L":"А-ЯЁA-Z","ru/month":"январь|февраль|март|апрель|май|июнь|июль|август|сентябрь|октябрь|ноябрь|декабрь","ru/monthGenCase":"января|февраля|марта|апреля|мая|июня|июля|августа|сентября|октября|ноября|декабря","ru/monthPreCase":"январе|феврале|марте|апреле|мае|июне|июле|августе|сентябре|октябре|ноябре|декабре","ru/quote":{left:"«„‚",right:"»“‘",removeDuplicateQuotes:!0},"ru/shortMonth":"янв|фев|мар|апр|ма[ейя]|июн|июл|авг|сен|окт|ноя|дек","ru/shortWord":"а|бы|в|во|да|до|же|за|и|из|к|ко|ли|на|не|ни|но|о|об|от|по|с|со|то|у","ru/weekday":"понедельник|вторник|среда|четверг|пятница|суббота|воскресенье"},{"sk/char":"abcdefghijklmnoprstuvwxyzáäéíóôúýčďľňŕšťž","sk/quote":{left:"„‚",right:"“‘"}},{"sl/char":"a-zčšž","sl/quote":{left:"„‚",right:"“‘"}},{"sr/char":"abcdefghijklmnoprstuvzćčđšž","sr/quote":{left:"„’",right:"”’"}},{"sv/char":"a-zäåéö","sv/quote":{left:"”’",right:"”’"}},{"tr/char":"abcdefghijklmnoprstuvyzâçîöûüğış","tr/quote":{left:"“‘",right:"”’"}},{"uk/char":"абвгдежзийклмнопрстуфхцчшщьюяєіїґ","uk/quote":{left:"«„",right:"»“"}}].forEach(p);var Z={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"},q={name:"common/html/escape",index:"+100",queue:"end",handler:function(e){return e.replace(/[&<>"'/]/g,function(e){return Z[e]})},disabled:!0},J=new RegExp("<("+["address","article","aside","blockquote","canvas","dd","div","dl","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","header","hgroup","hr","li","main","nav","noscript","ol","output","p","pre","section","table","tfoot","ul","video"].join("|")+")[>\\s]"),q=(E.addRules([{name:"common/html/e-mail",queue:"end",handler:function(e,t,n){return n.isHTML?e:e.replace(/(^|[\s;(])([\w\-.]{2,64})@([\w\-.]{2,64})\.([a-z]{2,64})([)\s.,!?]|$)/gi,'$1<a href="mailto:$2@$3.$4">$2@$3.$4</a>$5')},disabled:!0,htmlAttrs:!1},q,{name:"common/html/nbr",index:"+10",queue:"end",handler:function(e){return e.replace(/([^\n>])\n(?=[^\n])/g,"$1<br/>\n")},disabled:!0,htmlAttrs:!1},{name:"common/html/p",index:"+5",queue:"end",handler:function(e){e=e.split("\n\n");return e.forEach(function(e,t,n){!e.trim()||J.test(e)||(n[t]=e.replace(/^(\s*)/,"$1<p>").replace(/(\s*)$/,"</p>$1"))}),e.join("\n\n")},disabled:!0,htmlAttrs:!1},{name:"common/html/processingAttrs",queue:"hide-safe-tags-own",handler:function(e,t,n){var o=this,r=new RegExp("(^|\\s)("+t.attrs.join("|")+")=(\"[^\"]*?\"|'[^']*?')","gi"),s=y(n.prefs);return s.ruleFilter=function(e){return!1!==e.htmlAttrs},e.replace(/(<[-\w]+\s)([^>]+?)(?=>)/g,function(e,t,n){return t+n.replace(r,function(e,t,n,r){var a=r[0],i=r[r.length-1],r=r.slice(1,-1);return t+n+"="+a+o.execute(r,s)+i})})},settings:{attrs:["title","placeholder"]},disabled:!0,htmlAttrs:!1},{name:"common/html/quot",queue:"hide-safe-tags",handler:function(e){return e.replace(/"/g,'"')}},{name:"common/html/stripTags",index:"+99",queue:"end",handler:function(e){return e.replace(/<[^>]+>/g,"")},disabled:!0},{name:"common/html/url",queue:"end",handler:function(e,t,n){return n.isHTML?e:e.replace(g,function(e,t,n){n=n.replace(/([^/]+\/?)(\?|#)$/,"$1").replace(/^([^/]+)\/$/,"$1"),"http"===t?n=n.replace(/^([^/]+)(:80)([^\d]|\/|$)/,"$1$3"):"https"===t&&(n=n.replace(/^([^/]+)(:443)([^\d]|\/|$)/,"$1$3"));var r=n,n=t+"://"+n,a='<a href="'+n+'">';return"http"===t||"https"===t?(r=r.replace(/^www\./,""),a+("http"===t?r:t+"://"+r)+"</a>"):a+n+"</a>"})},disabled:!0,htmlAttrs:!1}]),{name:"common/nbsp/afterNumber",handler:function(e,t,n){n=n.getData("char");return e.replace(new RegExp("(^|\\s)(\\d{1,5}) (["+n+"]+)","gi"),"$1$2 $3")},disabled:!0});function _(e,t,n,r){return t+n.replace(/([^\u00A0])\u00A0([^\u00A0])/g,"$1 $2")+r}E.addRules([q,{name:"common/nbsp/afterParagraphMark",handler:function(e){return e.replace(/¶ ?(?=\d)/g,"¶ ")}},{name:"common/nbsp/afterSectionMark",handler:function(e,t,n){n=n.prefs.locale[0];return e.replace(/§[ \u00A0\u2009]?(?=\d|I|V|X)/g,"ru"===n?"§ ":"§ ")}},{name:"common/nbsp/afterShortWord",handler:function(e,t,n){var r=t.lengthShortWord,t=t.useShortWordList,a=c["common/quote"],i=n.getData("char"),n=n.getData("shortWord"),a=" ("+a,t=new RegExp(t&&void 0!==n?"(^|["+a+"])("+n+") ":"(^|["+a+"])(["+i+"]{1,"+r+"}) ","gim");return e.replace(t,"$1$2 ").replace(t,"$1$2 ")},settings:{lengthShortWord:2,useShortWordList:!1}},{name:"common/nbsp/beforeShortLastNumber",handler:function(e,t,n){var r=n.getData("quote"),n=n.getData("char"),a=n.toUpperCase(),n=new RegExp("(["+n+a+"]) (?=\\d{1,"+t.lengthLastNumber+"}[-+−%'\""+r.right+")]?([.!?…]( ["+a+"]|$)|$))","gm");return e.replace(n,"$1 ")},live:!1,settings:{lengthLastNumber:2}},{name:"common/nbsp/beforeShortLastWord",handler:function(e,t,n){var n=n.getData("char"),r=n.toUpperCase(),n=new RegExp("(["+n+"\\d]) (["+n+r+"]{1,"+t.lengthLastWord+"}[.!?…])( ["+r+"]|$)","g");return e.replace(n,"$1 $2$3")},settings:{lengthLastWord:3}},{name:"common/nbsp/dpi",handler:function(e){return e.replace(/(\d) ?(lpi|dpi)(?!\w)/,"$1 $2")}},{name:"common/nbsp/nowrap",queue:"end",handler:function(e){return e.replace(/(<nowrap>)(.*?)(<\/nowrap>)/g,_).replace(/(<nobr>)(.*?)(<\/nobr>)/g,_)}},{name:"common/nbsp/replaceNbsp",queue:"utf",live:!1,handler:x,disabled:!0}]);q={name:"common/number/digitGrouping",index:"310",disabled:!0,handler:function(e,a){return e.replace(new RegExp("(^ ?|\\D |".concat(d,")(\\d{1,3}([ ]\\d{3})+)(?! ?[\\d-])"),"gm"),function(e,t,n){return t+n.replace(/\s/g,a.space)}).replace(/(\d{5,}([.,]\d+)?)/g,function(e,t){var n=t.match(/[.,]/),t=n?t.split(n):[t],r=t[0],t=t[1],r=r.replace(/(\d)(?=(\d{3})+([^\d]|$))/g,"$1"+a.space);return n?r+n+t:r})},settings:{space:" "}},E.addRules([q,{name:"common/number/fraction",handler:function(e){return e.replace(/(^|\D)1\/2(\D|$)/g,"$1½$2").replace(/(^|\D)1\/4(\D|$)/g,"$1¼$2").replace(/(^|\D)3\/4(\D|$)/g,"$1¾$2")}},{name:"common/number/mathSigns",handler:function(e){return v(e,[[/!=/g,"≠"],[/<=/g,"≤"],[/(^|[^=])>=/g,"$1≥"],[/<=>/g,"⇔"],[/<</g,"≪"],[/>>/g,"≫"],[/~=/g,"≅"],[/(^|[^+])\+-/g,"$1±"]])}},{name:"common/number/times",handler:function(e){return e.replace(/(\d)[ \u00A0]?[xх][ \u00A0]?(\d)/g,"$1×$2")}}]),E.addRules([{name:"common/other/delBOM",queue:"start",index:-1,handler:function(e){return 65279===e.charCodeAt(0)?e.slice(1):e}},{name:"common/other/repeatWord",handler:function(e,t,n){var r=c["common/quote"],n=n.getData("char"),r="[;:,.?! \n"+r+"]",n=new RegExp("("+r+"|^)(["+n+"]{"+t.min+",}) \\2("+r+"|$)","gi");return e.replace(n,"$1$2$3")},settings:{min:2},disabled:!0}]),q={name:"common/punctuation/apostrophe",handler:function(e,t,n){n="(["+n.getData("char")+"])",n=new RegExp(n+"'"+n,"gi");return e.replace(n,"$1’$2")}};function A(){this.bufferQuotes={left:"",right:""},this.beforeLeft=" \n\t [(",this.afterRight=" \n\t !?.:;#*,…)\\]"}A.prototype.process=function(e){var t,n,r=e.context.text;return this.count(r).total&&(t=e.settings,(n=e.settings.left[0]===e.settings.right[0])&&(e.settings=y(e.settings),e.settings.left=this.bufferQuotes.left.slice(0,e.settings.left.length),e.settings.right=this.bufferQuotes.right.slice(0,e.settings.right.length)),e.settings.spacing&&(r=this.removeSpacing(r,e.settings)),r=this.set(r,e),e.settings.spacing&&(r=this.setSpacing(r,e.settings)),e.settings.removeDuplicateQuotes&&(r=this.removeDuplicates(r,e.settings)),n)&&(r=this.returnOriginalQuotes(r,t,e.settings),e.settings=t),r},A.prototype.returnOriginalQuotes=function(e,t,n){for(var r={},a=0;a<n.left.length;a++)r[n.left[a]]=t.left[a],r[n.right[a]]=t.right[a];return e.replace(new RegExp("["+n.left+n.right+"]","g"),function(e){return r[e]})},A.prototype.count=function(e){var t={total:0};return e.replace(new RegExp("["+c["common/quote"]+"]","g"),function(e){return t[e]||(t[e]=0),t[e]++,t.total++,e}),t},A.prototype.removeDuplicates=function(e,t){var n=t.left[0],r=t.left[1]||n,t=t.right[0];return n!==r?e:e.replace(new RegExp(n+n,"g"),n).replace(new RegExp(t+t,"g"),t)},A.prototype.removeSpacing=function(e,t){for(var n=0,r=t.left.length;n<r;n++){var a=t.left[n],i=t.right[n];e=e.replace(new RegExp(a+"([ ])","g"),a).replace(new RegExp("([ ])"+i,"g"),i)}return e},A.prototype.setSpacing=function(e,t){for(var n=0,r=t.left.length;n<r;n++){var a=t.left[n],i=t.right[n];e=e.replace(new RegExp(a+"([^ ])","g"),a+" $1").replace(new RegExp("([^ ])"+i,"g"),"$1 "+i)}return e},A.prototype.set=function(e,t){var n=c["common/quote"],r=t.settings.left[0],a=t.settings.left[1]||r,i=t.settings.right[0],o=new RegExp("(^|["+this.beforeLeft+"])(["+n+"]+)(?=[^\\s"+d+"])","gim"),n=new RegExp("([^\\s])(["+n+"]+)(?=["+this.afterRight+"]|$)","gim");return e=e.replace(o,function(e,t,n){return t+b(r,n.length)}).replace(n,function(e,t,n){return t+b(i,n.length)}),e=this.setAboveTags(e,t),e=r!==a?this.setInner(e,t.settings):e},A.prototype.setAboveTags=function(i,o){var s=this,u=o.settings.left[0],l=o.settings.right[0];return i.replace(new RegExp("(^|.)(["+c["common/quote"]+"])(.|$)","gm"),function(e,t,n,r,a){return t!==d&&r!==d?e:t===d&&r===d?'"'===n?t+s.getAboveTwoTags(i,a+1,o)+r:e:t===d?(n=-1<s.afterRight.indexOf(r),e=o.safeTags.getPrevTagInfo(o.context,i,a+1),n&&e&&"html"===e.group?t+(e.isClosing?l:u)+r:t+(!r||n?l:u)+r):(e=-1<s.beforeLeft.indexOf(t),n=o.safeTags.getNextTagInfo(o.context,i,a+1),e&&n&&"html"===n.group?t+(n.isClosing?l:u)+r:t+(!t||e?u:l)+r)})},A.prototype.getAboveTwoTags=function(e,t,n){var r=n.safeTags.getPrevTagInfo(n.context,e,t),a=n.safeTags.getNextTagInfo(n.context,e,t);if(r&&"html"===r.group){if(!r.isClosing)return n.settings.left[0];if(a&&a.isClosing&&r.isClosing)return n.settings.right[0]}return e[t]},A.prototype.setInner=function(e,t){for(var n=t.left[0],r=t.right[0],a=this.getMaxLevel(e,n,r,t.left.length),i=0,o="",s=0,u=e.length;s<u;s++){var l=e[s];l===n?(o+=t.left[a-1<i?a-1:i],a<++i&&(i=a)):l===r?(--i<0&&(i=0),o+=t.right[i]):('"'===l&&(i=0),o+=l)}return o},A.prototype.getMaxLevel=function(e,t,n,r){e=this.count(e);return e[t]===e[n]?r:Math.min(r,2)};var ee=new A,te={},T=(a.forEach(function(e){te[e]=y(c[e+"/quote"])}),{name:"common/punctuation/quote",handler:function(e,t,n){t=t[n.prefs.locale[0]];return t?ee.process({context:n,settings:t,safeTags:this.safeTags}):e},settings:te}),q=(E.addRules([q,{name:"common/punctuation/delDoublePunctuation",handler:function(e){return e.replace(/(^|[^,]),,(?!,)/g,"$1,").replace(/(^|[^:])::(?!:)/g,"$1:").replace(/(^|[^!?.])\.\.(?!\.)/g,"$1.").replace(/(^|[^;]);;(?!;)/g,"$1;").replace(/(^|[^?])\?\?(?!\?)/g,"$1?")}},{name:"common/punctuation/hellip",handler:function(e,t,n){return"ru"===n.prefs.locale[0]?e.replace(/(^|[^.])\.{3,4}(?=[^.]|$)/g,"$1…"):e.replace(/(^|[^.])\.{3}(\.?)(?=[^.]|$)/g,"$1…$2")}},T,{name:"common/punctuation/quoteLink",queue:"show-safe-tags-html",index:"+5",handler:function(e,t,n){var n=this.getSetting("common/punctuation/quote",n.prefs.locale[0]),r=o.getByUtf(n.left[0]),a=o.getByUtf(n.right[0]),i=(i=o.getByUtf(n.left[1]))?"|"+i:"",n=(n=o.getByUtf(n.right[1]))?"|"+n:"",r=new RegExp("(<[aA]\\s[^>]*?>)("+r+i+")([^]*?)("+a+n+")(</[aA]>)","g");return e.replace(r,"$2$1$3$5$4")}}]),{name:"common/space/beforeBracket",handler:function(e,t,n){n=n.getData("char"),n=new RegExp("(["+n+".!?,;…)])\\(","gi");return e.replace(n,"$1 (")}}),T={name:"common/space/delRepeatN",index:"-1",handler:function(e,t){var t=t.maxConsecutiveLineBreaks,n=new RegExp("\n{".concat(t+1,",}"),"g"),t=b("\n",t);return e.replace(n,t)},settings:{maxConsecutiveLineBreaks:2}},B={name:"common/space/trimLeft",index:"-4",handler:String.prototype.trimLeft?function(e){return e.trimLeft()}:function(e){return e.replace(/^[\s\uFEFF\xA0]+/g,"")}},ne={name:"common/space/trimRight",index:"-3",live:!1,handler:String.prototype.trimRight?function(e){return e.trimRight()}:function(e){return e.replace(/[\s\uFEFF\xA0]+$/g,"")}},re=new RegExp('(\\D):([^)",:.?\\s\\/\\\\])',"g"),k={name:"common/space/afterColon",handler:function(e){return e.replace(re,"$1: $2")}},L={name:"common/space/afterComma",handler:function(e,t,n){n=n.getData("quote"),n="string"==typeof n?n:n.right;return e.replace(new RegExp('(.),([^)",:.?\\s\\/\\\\'+n+"])","g"),function(e,t,n){return f(t)&&f(n)?e:t+", "+n})}},ae=new RegExp("\\?([^).…!;?\\s[\\])"+c["common/quote"]+"])","g"),D={name:"common/space/afterQuestionMark",handler:function(e){return e.replace(ae,"? $1")}},ie=new RegExp("!([^).…!;?\\s[\\])"+c["common/quote"]+"])","g"),S={name:"common/space/afterExclamationMark",handler:function(e){return e.replace(ie,"! $1")}},oe=new RegExp(";([^).…!;?\\s[\\])"+c["common/quote"]+"])","g"),k=(E.addRules([k,L,D,S,{name:"common/space/afterSemicolon",handler:function(e){return e.replace(oe,"; $1")}},q,{name:"common/space/bracket",handler:function(e){return e.replace(/(\() +/g,"(").replace(/ +\)/g,")")}},{name:"common/space/delBeforeDot",handler:function(e){return e.replace(/(^|[^!?:;,.…]) (\.|\.\.\.)(\s|$)/g,"$1$2$3")}},{name:"common/space/delBeforePercent",handler:function(e){return e.replace(/(\d)( |\u00A0)(%|‰|‱)/g,"$1$3")}},{name:"common/space/delBeforePunctuation",handler:function(e){return e.replace(/(^|[^!?:;,.…]) ([!?:;,])(?!\))/g,"$1$2")}},{name:"common/space/delBetweenExclamationMarks",handler:function(e){return e.replace(/([!?]) (?=[!?])/g,"$1")}},{name:"common/space/delLeadingBlanks",handler:function(e){return e.replace(/^[ \t]+/gm,"")},disabled:!0},T,{name:"common/space/delRepeatSpace",index:"-1",handler:function(e){return e.replace(/([^\n \t])[ \t]{2,}(?![\n \t])/g,"$1 ")}},{name:"common/space/delTrailingBlanks",index:"-3",handler:function(e){return e.replace(/[ \t]+\n/g,"\n")}},{name:"common/space/insertFinalNewline",queue:"end",handler:function(e){return"\n"===e[e.length-1]?e:e+"\n"},live:!1,disabled:!0},{name:"common/space/replaceTab",index:"-5",handler:function(e){return e.replace(/\t/g," ")}},{name:"common/space/squareBracket",handler:function(e){return e.replace(/(\[) +/g,"[").replace(/ +\]/g,"]")}},B,ne]),{name:"common/symbols/arrow",handler:function(e){return v(e,[[/(^|[^-])->(?!>)/g,"$1→"],[/(^|[^<])<-(?!-)/g,"$1←"]])}}),L=(E.addRules([k,{name:"common/symbols/cf",handler:function(e){var t=new RegExp('(^|[\\s(\\[+≈±−—–\\-])(\\d+(?:[.,]\\d+)?)[ ]?(C|F)([\\W\\s.,:!?")\\]]|$)',"mg");return e.replace(t,"$1$2 °$3$4")}},{name:"common/symbols/copy",handler:function(e){return v(e,[[/\(r\)/gi,"®"],[/(copyright )?\((c|с)\)/gi,"©"],[/\(tm\)/gi,"™"]])}}]),{name:"en-US/dash/main",index:"-5",handler:function(e){var t=c["common/dash"],n="[ ".concat(" ","]"),r="[ ".concat(" ","\n]"),n=new RegExp("".concat(n,"(").concat(t,")(").concat(r,")"),"g");return e.replace(n,"".concat(" ").concat("—","$2"))}}),D=(E.addRules([L]),{name:"ru/dash/centuries",handler:function(e,t){var n=new RegExp("(X|I|V)[ | ]?"+("("+c["common/dash"]+")")+"[ | ]?(X|I|V)","g");return e.replace(n,"$1"+t.dash+"$3")},settings:{dash:"–"}}),S=(E.addRules([D,{name:"ru/dash/daysMonth",handler:function(e,t){var n=new RegExp("(^|\\s)([123]?\\d)("+c["common/dash"]+")([123]?\\d)[ ]("+c["ru/monthGenCase"]+")","g");return e.replace(n,"$1$2"+t.dash+"$4 $5")},settings:{dash:"–"}},{name:"ru/dash/de",handler:function(e){var t=new RegExp("([a-яё]+) де"+c["ru/dashAfterDe"],"g");return e.replace(t,"$1-де")},disabled:!0},{name:"ru/dash/decade",handler:function(e,t){var n=new RegExp("(^|\\s)(\\d{3}|\\d)0("+c["common/dash"]+")(\\d{3}|\\d)0(-е[ ])(?=г\\.?[ ]?г|год)","g");return e.replace(n,"$1$20"+t.dash+"$40$5")},settings:{dash:"–"}},{name:"ru/dash/directSpeech",handler:function(e){var t=c["common/dash"],n=new RegExp('(["»‘“,])[ | ]?('.concat(t,")[ | ]"),"g"),r=new RegExp("(^|".concat(d,")(").concat(t,")( | )"),"gm"),t=new RegExp("([.…?!])[ ](".concat(t,")[ ]"),"g");return e.replace(n,"$1 — ").replace(r,"$1— ").replace(t,"$1 — ")}},{name:"ru/dash/izpod",handler:function(e){var t=new RegExp(c["ru/dashBefore"]+"(И|и)з под"+c["ru/dashAfter"],"g");return e.replace(t,"$1$2з-под")}},{name:"ru/dash/izza",handler:function(e){var t=new RegExp(c["ru/dashBefore"]+"(И|и)з за"+c["ru/dashAfter"],"g");return e.replace(t,"$1$2з-за")}},{name:"ru/dash/ka",handler:function(e){var t=new RegExp("([a-яё]+) ка(сь)?"+c["ru/dashAfter"],"g");return e.replace(t,"$1-ка$2")}},{name:"ru/dash/koe",handler:function(e){var t=new RegExp(c["ru/dashBefore"]+"([Кк]о[ей])\\s([а-яё]{3,})"+c["ru/dashAfter"],"g");return e.replace(t,"$1$2-$3")}},{name:"ru/dash/main",index:"-5",handler:function(e){var t=new RegExp("([ ])("+c["common/dash"]+")([ \\n])","g");return e.replace(t," —$3")}},{name:"ru/dash/month",handler:function(e,t){var n="("+c["ru/month"]+")",r="("+c["ru/monthPreCase"]+")",a=c["common/dash"],n=new RegExp(n+" ?("+a+") ?"+n,"gi"),a=new RegExp(r+" ?("+a+") ?"+r,"gi"),r="$1"+t.dash+"$3";return e.replace(n,r).replace(a,r)},settings:{dash:"–"}},{name:"ru/dash/surname",handler:function(e){var t=new RegExp("([А-ЯЁ][а-яё]+)\\s-([а-яё]{1,3})(?![^а-яё]|$)","g");return e.replace(t,"$1 —$2")}},{name:"ru/dash/taki",handler:function(e){var t=new RegExp("(верно|довольно|опять|прямо|так|вс[её]|действительно|неужели)\\s(таки)"+c["ru/dashAfter"],"g");return e.replace(t,"$1-$2")}},{name:"ru/dash/time",handler:function(e,t){var n=new RegExp(c["ru/dashBefore"]+"(\\d?\\d:[0-5]\\d)"+c["common/dash"]+"(\\d?\\d:[0-5]\\d)"+c["ru/dashAfter"],"g");return e.replace(n,"$1$2"+t.dash+"$3")},settings:{dash:"–"}},{name:"ru/dash/to",handler:function(e){var t=new RegExp("(^|[^А-ЯЁа-яё\\w])([Оо]ткуда|[Кк]уда|[Гг]де|[Кк]огда|[Зз]ачем|[Пп]очему|[Кк]ак|[Кк]ако[ейм]|[Кк]акая|[Кк]аки[емх]|[Кк]акими|[Кк]акую|[Чч]то|[Чч]его|[Чч]е[йм]|[Чч]ьим?|[Кк]то|[Кк]ого|[Кк]ому|[Кк]ем)( | -|- )(то|либо|нибудь)"+c["ru/dashAfter"],"g");return e.replace(t,function(e,t,n,r,a){r=n+r+a;return"как то"===r||"Как то"===r?e:t+n+"-"+a})}},{name:"ru/dash/kakto",handler:function(e){var t=new RegExp("(^|[^А-ЯЁа-яё\\w])([Кк]ак) то"+c["ru/dashAfter"],"g");return e.replace(t,"$1$2-то")}},{name:"ru/dash/weekday",handler:function(e,t){var n="("+c["ru/weekday"]+")",n=new RegExp(n+" ?("+c["common/dash"]+") ?"+n,"gi");return e.replace(n,"$1"+t.dash+"$3")},settings:{dash:"–"}},{name:"ru/dash/years",handler:function(e,i){var t=new RegExp("(\\D|^)(\\d{4})[ ]?("+c["common/dash"]+")[ ]?(\\d{4})(?=[ ]?г)","g");return e.replace(t,function(e,t,n,r,a){return parseInt(n,10)<parseInt(a,10)?t+n+i.dash+a:e})},settings:{dash:"–"}}]),"(-|\\.|\\/)"),q="(-|\\/)",se=new RegExp("(^|\\D)(\\d{4})"+S+"(\\d{2})"+S+"(\\d{2})(\\D|$)","gi"),ue=new RegExp("(^|\\D)(\\d{2})"+q+"(\\d{2})"+q+"(\\d{4})(\\D|$)","gi"),T=(E.addRules([{name:"ru/date/fromISO",handler:function(e){return e.replace(se,"$1$6.$4.$2$7").replace(ue,"$1$4.$2.$6$7")}},{name:"ru/date/weekday",handler:function(e){var t=new RegExp("(\\d)( | )("+c["ru/monthGenCase"]+"),( | )("+c["ru/weekday"]+")","gi");return e.replace(t,function(e,t,n,r,a,i){return t+n+r.toLowerCase()+","+a+i.toLowerCase()})}}]),{name:"ru/money/currency",handler:function(e){var t="([$€¥Ұ£₤₽])",n=new RegExp("(^|[\\D]{2})"+t+" ?("+h+"([ ]\\d{3})*)([ ]?(тыс\\.|млн|млрд|трлн))?","gm"),t=new RegExp("(^|[\\D])("+h+") ?"+t,"gm");return e.replace(n,function(e,t,n,r,a,i,o,s){return t+r+(s?" "+s:"")+" "+n}).replace(t,"$1$2 $4")},disabled:!0});function le(e,t,n,r){return"дд"===n&&"мм"===r||-1<["рф","ру","рус","орг","укр","бг","срб"].indexOf(r)?e:t+n+". "+r+"."}E.addRules([T,{name:"ru/money/ruble",handler:function(e){var t="$1 ₽",n="(\\d+)( | )?(р|руб)\\.",r=new RegExp("^"+n+"$","g"),a=new RegExp(n+"(?=[!?,:;])","g"),n=new RegExp(n+"(?=\\s+[A-ЯЁ])","g");return e.replace(r,t).replace(a,t).replace(n,t+".")},disabled:!0}]);var ce={2:"²","²":"²",3:"³","³":"³","":""};E.addRules([{name:"ru/nbsp/abbr",handler:function(e){var t=new RegExp("(^|\\s|".concat(d,")([а-яё]{1,3})\\. ?([а-яё]{1,3})\\."),"g");return e.replace(t,le).replace(t,le)}},{name:"ru/nbsp/addr",handler:function(e){return e.replace(/(\s|^)(дом|д\.|кв\.|под\.|п-д) *(\d+)/gi,"$1$2 $3").replace(/(\s|^)(мкр-н|мк-н|мкр\.|мкрн)\s/gi,"$1$2 ").replace(/(\s|^)(эт\.) *(-?\d+)/gi,"$1$2 $3").replace(/(\s|^)(\d+) +этаж([^а-яё]|$)/gi,"$1$2 этаж$3").replace(/(\s|^)литер\s([А-Я]|$)/gi,"$1литер $2").replace(/(\s|^)(обл|кр|ст|пос|с|д|ул|пер|пр|пр-т|просп|пл|бул|б-р|наб|ш|туп|оф|комн?|уч|вл|влад|стр|кор)\. *([а-яёa-z\d]+)/gi,"$1$2. $3").replace(/(\D[ \u00A0]|^)г\. ?([А-ЯЁ])/gm,"$1г. $2")}},{name:"ru/nbsp/afterNumberSign",handler:function(e){return e.replace(/№[ \u00A0\u2009]?(\d|п\/п)/g,"№ $1")}},{name:"ru/nbsp/beforeParticle",index:"+5",handler:function(e){var t="(ли|ль|же|ж|бы|б)",n=new RegExp("([А-ЯЁа-яё]) "+t+'(?=[,;:?!"‘“»])',"g"),t=new RegExp("([А-ЯЁа-яё])[ ]"+t+"[ ]","g");return e.replace(n,"$1 $2").replace(t,"$1 $2 ")}},{name:"ru/nbsp/centuries",handler:function(e){var t=c["common/dash"],n="(^|\\s)([VIX]+)",r='(?=[,;:?!"‘“»]|$)',a=new RegExp(n+"[ ]?в\\.?"+r,"gm"),n=new RegExp(n+"("+t+")([VIX]+)[ ]?в\\.?([ ]?в\\.?)?"+r,"gm");return e.replace(a,"$1$2 в.").replace(n,"$1$2$3$4 вв.")}},{name:"ru/nbsp/dayMonth",handler:function(e){var t=new RegExp("(\\d{1,2}) ("+c["ru/shortMonth"]+")","gi");return e.replace(t,"$1 $2")}},{name:"ru/nbsp/initials",handler:function(e){var t=new RegExp("(^|[( "+c["ru/quote"].left+d+'"])([А-ЯЁ])\\.[ ]?([А-ЯЁ])\\.[ ]?([А-ЯЁ][а-яё]+)',"gm");return e.replace(t,"$1$2. $3. $4")}},{name:"ru/nbsp/m",index:"+5",handler:function(e){var t=new RegExp("(^|[\\s,.\\(])(\\d+)[ ]?(мм?|см|км|дм|гм|mm?|km|cm|dm)([23²³])?([\\s\\).!?,;]|$)","gm");return e.replace(t,function(e,t,n,r,a,i){return t+n+" "+r+ce[a||""]+(" "===i?" ":i)})}},{name:"ru/nbsp/mln",handler:function(e){return e.replace(/(\d) ?(тыс|млн|млрд|трлн)(\.|\s|$)/gi,"$1 $2$3")}},{name:"ru/nbsp/ooo",handler:function(e){return e.replace(/(^|[^a-яёA-ЯЁ])(ООО|ОАО|ЗАО|НИИ|ПБОЮЛ) /g,"$1$2 ")}},{name:"ru/nbsp/page",handler:function(e){var t=new RegExp("(^|[)\\s])(стр|гл|рис|илл?|ст|п|c)\\. *(\\d+)([\\s.,?!;:]|$)","gim");return e.replace(t,"$1$2. $3$4")}},{name:"ru/nbsp/ps",handler:function(e){var t=new RegExp("(^|\\s|".concat(d,")[pз]\\.[ ]?([pз]\\.[ ]?)?[sы]\\.:? "),"gim");return e.replace(t,function(e,t,n){return t+(n?"P. P. S. ":"P. S. ")})}},{name:"ru/nbsp/rubleKopek",handler:function(e){return e.replace(/(\d) ?(?=(руб|коп)\.)/g,"$1 ")}},{name:"ru/nbsp/see",handler:function(e){var t=new RegExp("(^|\\s|".concat(d,"|\\()(см|им)\\.[ ]?([а-яё0-9a-z]+)([\\s.,?!]|$)"),"gi");return e.replace(t,function(e,t,n,r,a){return(" "===t?" ":t)+n+". "+r+a})}},{name:"ru/nbsp/year",handler:function(e){return e.replace(/(^|\D)(\d{4}) ?г([ ,;.\n]|$)/g,"$1$2 г$3")}},{name:"ru/nbsp/years",index:"+5",handler:function(e){var t=new RegExp("(^|\\D)(\\d{4})("+c["common/dash"]+')(\\d{4})[ ]?г\\.?([ ]?г\\.)?(?=[,;:?!"‘“»\\s]|$)',"gm");return e.replace(t,"$1$2$3$4 гг.")}}]);function I(e,t){t=new RegExp('<span class="('+t.join("|")+')">([^]*?)</span>',"g");return e.replace(t,"$2")}function z(e,t){return e.replace(/<title>[^]*?<\/title>/i,function(e){return I(e,t)})}E.addRules([{name:"ru/number/comma",handler:function(e){return e.replace(/(^|\s)(\d+)\.(\d+[\u00A0\u2009\u202F ]*?[%‰°×x])/gim,"$1$2,$3")}},{name:"ru/number/ordinals",handler:function(e,t,n){n=n.getData("char"),n=new RegExp("(\\d[%‰]?)-(ый|ой|ая|ое|ые|ым|ом|ых|ого|ому|ыми)(?!["+n+"])","g");return e.replace(n,function(e,t,n){return t+"-"+{"ой":"й","ый":"й","ая":"я","ое":"е","ые":"е","ым":"м","ом":"м","ых":"х","ого":"го","ому":"му","ыми":"ми"}[n]})}}]);var pe=["typograf-oa-lbracket","typograf-oa-n-lbracket","typograf-oa-sp-lbracket"],B="ru/optalign/bracket",ne={name:B,queue:"start",handler:function(e){return I(e,pe)},htmlAttrs:!1},k={name:B,queue:"end",handler:function(e){return z(e,pe)},htmlAttrs:!1},ge=["typograf-oa-comma","typograf-oa-comma-sp"],L="ru/optalign/comma",D={name:L,queue:"start",handler:function(e){return I(e,ge)},htmlAttrs:!1},S={name:L,queue:"end",handler:function(e){return z(e,ge)},htmlAttrs:!1},he=["typograf-oa-lquote","typograf-oa-n-lquote","typograf-oa-sp-lquote"],q="ru/optalign/quote",T={name:q,queue:"start",handler:function(e){return I(e,he)},htmlAttrs:!1},fe={name:q,queue:"end",handler:function(e){return z(e,he)},htmlAttrs:!1},C=(E.addRules([{name:B,handler:function(e){return e.replace(/( |\u00A0)\(/g,'<span class="typograf-oa-sp-lbracket">$1</span><span class="typograf-oa-lbracket">(</span>').replace(/^\(/gm,'<span class="typograf-oa-n-lbracket">(</span>')},disabled:!0,htmlAttrs:!1},{name:L,handler:function(e,t,n){n=n.getData("char"),n=new RegExp("(["+n+"\\d́]+), ","gi");return e.replace(n,'$1<span class="typograf-oa-comma">,</span><span class="typograf-oa-comma-sp"> </span>')},disabled:!0,htmlAttrs:!1},{name:q,handler:function(e){var t=this.getSetting("common/punctuation/quote","ru"),t="(["+t.left[0]+(t.left[1]||"")+"])",n=new RegExp("(^|\n\n|)("+t+")","g"),t=new RegExp("([^\n])([ \n])("+t+")","gi");return e.replace(n,'$1<span class="typograf-oa-n-lquote">$2</span>').replace(t,'$1<span class="typograf-oa-sp-lquote">$2</span><span class="typograf-oa-lquote">$3</span>')},disabled:!0,htmlAttrs:!1}]),E.addInnerRules([ne,k,D,S,T,fe]),[]);function de(e){var t,n,r=e[0],a="";if(e.length<8)return me(e);if(10<e.length)if("+"===r){if("7"!==e[1])return e;t=!0,e=e.substr(2)}else"8"===r&&(n=!0,e=e.substr(1));for(var i=8;2<=i;i--){var o=+e.substr(0,i);if(-1<C.indexOf(o)){a=e.substr(0,i),e=e.substr(i);break}}return a||(a=e.substr(0,5),e=e.substr(5)),(t?"+7 ":"")+(n?"8 ":"")+(e=>{var t=+e,n=e.length,r=[e],a=!1;if(3<n)switch(n){case 4:r=[e.substr(0,2),e.substr(2,2)];break;case 5:r=[e.substr(0,3),e.substr(3,3)];break;case 6:r=[e.substr(0,2),e.substr(2,2),e.substr(4,2)]}else a=900<t&&t<=999||495==t||499==t||800==t;return n=r.join("-"),a?n:"("+n+")"})(a)+" "+me(e)}function me(e){var t="";return e.length%2&&(t=e[0],t+=e.length<=5?"-":"",e=e.substr(1,e.length-1)),t+e.split(/(?=(?:\d\d)+$)/).join("-")}function $e(e){return e.replace(/[^\d+]/g,"")}[4162,416332,8512,851111,4722,4725,391379,8442,4732,4152,4154451,4154459,4154455,41544513,8142,8332,8612,8622,3525,812,8342,8152,3812,4862,3422,342633,8112,9142,8452,3432,3434,3435,4812,8432,8439,3822,4872,3412,3511,3512,3022,4112,4852,4855,3852,3854,8182,818,90,3472,4741,4764,4832,4922,8172,8202,8722,4932,493,3952,3951,3953,411533,4842,3842,3843,8212,4942,"39131-39179","39190-39199",391,4712,4742,8362,495,499,4966,4964,4967,498,8312,8313,3832,383612,3532,8412,4232,423370,423630,8632,8642,8482,4242,8672,8652,4752,4822,482502,4826300,3452,8422,4212,3466,3462,8712,8352,800,"901-934","936-939","950-953",958,"960-969","977-989","991-997",999].forEach(function(e){if("string"==typeof e)for(var t=e.split("-"),n=+t[0];n<=+t[1];n++)C.push(n);else C.push(e)});E.addRules([{name:"ru/other/accent",handler:function(e){return e.replace(/([а-яё])([АЕЁИОУЫЭЮЯ])([^А-ЯЁ\w]|$)/g,function(e,t,n,r){return t+n.toLowerCase()+"́"+r})},disabled:!0},{name:"ru/other/phone-number",live:!1,handler:function(e){var t=new RegExp("(^|,| |)(\\+7[\\d\\(\\) -]{10,18})(?=,|;||$)","gm");return e.replace(t,function(e,t,n){n=$e(n);return 12===n.length?t+de(n):e}).replace(/(^|[^а-яё])([☎☏✆📠📞📱]|т\.|тел\.|ф\.|моб\.|факс|сотовый|мобильный|телефон)(:?\s*?)([+\d(][\d \u00A0\-()]{3,}\d)/gi,function(e,t,n,r,a){a=$e(a);return 5<=a.length?t+n+r+de(a):e})}}]);var B={name:"ru/punctuation/ano",handler:function(e){var t=new RegExp("([^«„[(!?,:;\\-‒–—\\s])(\\s+)(а|но)(?= | |\\n)","g");return e.replace(t,"$1,$2$3")}},be=(E.addRules([B,{name:"ru/punctuation/exclamation",handler:function(e){return e.replace(/(^|[^!])!{2}($|[^!])/gm,"$1!$2").replace(/(^|[^!])!{4}($|[^!])/gm,"$1!!!$2")},live:!1},{name:"ru/punctuation/exclamationQuestion",index:"+5",handler:function(e){var t=new RegExp("(^|[^!])!\\?([^?]|$)","g");return e.replace(t,"$1?!$2")}},{name:"ru/punctuation/hellipQuestion",handler:function(e){return e.replace(/(^|[^.])(\.\.\.|…),/g,"$1…").replace(/(!|\?)(\.\.\.|…)(?=[^.]|$)/g,"$1..")}}]),E.addRules([{name:"ru/space/afterHellip",handler:function(e){return e.replace(/([а-яё])(\.\.\.|…)([А-ЯЁ])/g,"$1$2 $3").replace(/([?!]\.\.)([а-яёa-z])/gi,"$1 $2")}},{name:"ru/space/year",handler:function(e,t,n){n=n.getData("char"),n=new RegExp("(^| | )(\\d{3,4})(год([ауе]|ом)?)([^"+n+"]|$)","g");return e.replace(n,"$1$2 $3$5")}}]),E.addRules([{name:"ru/symbols/NN",handler:function(e){return e.replace(/№№/g,"№")}}]),{A:"А",a:"а",B:"В",E:"Е",e:"е",K:"К",M:"М",H:"Н",O:"О",o:"о",P:"Р",p:"р",C:"С",c:"с",T:"Т",y:"у",X:"Х",x:"х"}),xe=Object.keys(be).join("");return E.addRules([{name:"ru/typo/switchingKeyboardLayout",handler:function(e){var t=new RegExp("(["+xe+"]{1,3})(?=[А-ЯЁа-яё]+?)","g");return e.replace(t,function(e,t){for(var n="",r=0;r<t.length;r++)n+=be[t[r]];return n})}}]),E});
|
|
2
|
+
((e,t)=>{"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).Typograf=t()})(this,function(){var r=function(){return(r=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var a in t=arguments[n])Object.prototype.hasOwnProperty.call(t,a)&&(e[a]=t[a]);return e}).apply(this,arguments)};function n(e,t,n){if(n||2===arguments.length)for(var r,a=0,i=t.length;a<i;a++)!r&&a in t||((r=r||Array.prototype.slice.call(t,0,a))[a]=t[a]);return e.concat(r||Array.prototype.slice.call(t))}var P=[["iexcl",161],["cent",162],["pound",163],["curren",164],["yen",165],["brvbar",166],["sect",167],["uml",168],["copy",169],["ordf",170],["laquo",171],["not",172],["reg",174],["macr",175],["deg",176],["plusmn",177],["sup2",178],["sup3",179],["acute",180],["micro",181],["para",182],["middot",183],["cedil",184],["sup1",185],["ordm",186],["raquo",187],["frac14",188],["frac12",189],["frac34",190],["iquest",191],["Agrave",192],["Aacute",193],["Acirc",194],["Atilde",195],["Auml",196],["Aring",197],["AElig",198],["Ccedil",199],["Egrave",200],["Eacute",201],["Ecirc",202],["Euml",203],["Igrave",204],["Iacute",205],["Icirc",206],["Iuml",207],["ETH",208],["Ntilde",209],["Ograve",210],["Oacute",211],["Ocirc",212],["Otilde",213],["Ouml",214],["times",215],["Oslash",216],["Ugrave",217],["Uacute",218],["Ucirc",219],["Uuml",220],["Yacute",221],["THORN",222],["szlig",223],["agrave",224],["aacute",225],["acirc",226],["atilde",227],["auml",228],["aring",229],["aelig",230],["ccedil",231],["egrave",232],["eacute",233],["ecirc",234],["euml",235],["igrave",236],["iacute",237],["icirc",238],["iuml",239],["eth",240],["ntilde",241],["ograve",242],["oacute",243],["ocirc",244],["otilde",245],["ouml",246],["divide",247],["oslash",248],["ugrave",249],["uacute",250],["ucirc",251],["uuml",252],["yacute",253],["thorn",254],["yuml",255],["fnof",402],["Alpha",913],["Beta",914],["Gamma",915],["Delta",916],["Epsilon",917],["Zeta",918],["Eta",919],["Theta",920],["Iota",921],["Kappa",922],["Lambda",923],["Mu",924],["Nu",925],["Xi",926],["Omicron",927],["Pi",928],["Rho",929],["Sigma",931],["Tau",932],["Upsilon",933],["Phi",934],["Chi",935],["Psi",936],["Omega",937],["alpha",945],["beta",946],["gamma",947],["delta",948],["epsilon",949],["zeta",950],["eta",951],["theta",952],["iota",953],["kappa",954],["lambda",955],["mu",956],["nu",957],["xi",958],["omicron",959],["pi",960],["rho",961],["sigmaf",962],["sigma",963],["tau",964],["upsilon",965],["phi",966],["chi",967],["psi",968],["omega",969],["thetasym",977],["upsih",978],["piv",982],["bull",8226],["hellip",8230],["prime",8242],["Prime",8243],["oline",8254],["frasl",8260],["weierp",8472],["image",8465],["real",8476],["trade",8482],["alefsym",8501],["larr",8592],["uarr",8593],["rarr",8594],["darr",8595],["harr",8596],["crarr",8629],["lArr",8656],["uArr",8657],["rArr",8658],["dArr",8659],["hArr",8660],["forall",8704],["part",8706],["exist",8707],["empty",8709],["nabla",8711],["isin",8712],["notin",8713],["ni",8715],["prod",8719],["sum",8721],["minus",8722],["lowast",8727],["radic",8730],["prop",8733],["infin",8734],["ang",8736],["and",8743],["or",8744],["cap",8745],["cup",8746],["int",8747],["there4",8756],["sim",8764],["cong",8773],["asymp",8776],["ne",8800],["equiv",8801],["le",8804],["ge",8805],["sub",8834],["sup",8835],["nsub",8836],["sube",8838],["supe",8839],["oplus",8853],["otimes",8855],["perp",8869],["sdot",8901],["lceil",8968],["rceil",8969],["lfloor",8970],["rfloor",8971],["lang",9001],["rang",9002],["spades",9824],["clubs",9827],["hearts",9829],["diams",9830],["loz",9674],["OElig",338],["oelig",339],["Scaron",352],["scaron",353],["Yuml",376],["circ",710],["tilde",732],["ndash",8211],["mdash",8212],["lsquo",8216],["rsquo",8217],["sbquo",8218],["ldquo",8220],["rdquo",8221],["bdquo",8222],["dagger",8224],["Dagger",8225],["permil",8240],["lsaquo",8249],["rsaquo",8250],["euro",8364],["NestedGreaterGreater",8811],["NestedLessLess",8810]],e=[["nbsp",160],["thinsp",8201],["ensp",8194],["emsp",8195],["shy",173],["zwnj",8204],["zwj",8205],["lrm",8206],["rlm",8207]];function t(){var t=this;this.entities=this.prepareEntities(n(n([],P,!0),e,!0)),this.entitiesByName={},this.entitiesByNameEntity={},this.entitiesByDigitEntity={},this.entitiesByJsEntity={},this.entitiesByUtf={},this.entities.forEach(function(e){t.entitiesByName[e.name]=e,t.entitiesByNameEntity[e.type.name]=e,t.entitiesByDigitEntity[e.type.digit]=e,t.entitiesByJsEntity[e.type.js]=e,t.entitiesByUtf[e.utf]=e}),this.invisibleEntities=this.prepareEntities(e)}t.prototype.toUtf=function(e){var n=this;-1!==e.text.search(/&#/)&&(e.text=this.decHexToUtf(e.text)),-1!==e.text.search(/&[a-z]/i)&&(e.text=e.text.replace(/&[a-z\d]{2,31};/gi,function(e){var t=n.entitiesByNameEntity[e];return t?t.utf:e})),-1!==e.text.search(/\\u[\da-f]/i)&&(e.text=e.text.replace(/\\u[\da-f]{4};/gi,function(e){var t=n.entitiesByJsEntity[e.toLowerCase()];return t?t.utf:e}))},t.prototype.decHexToUtf=function(e){return e.replace(/&#(\d{1,6});/gi,function(e,t){return String.fromCharCode(parseInt(t,10))}).replace(/&#x([\da-f]{1,6});/gi,function(e,t){return String.fromCharCode(parseInt(t,16))})},t.prototype.restore=function(e){var t,n=e.prefs.htmlEntity,r=n.type;"default"!==r&&(t=this.entities,(n.onlyInvisible||n.list)&&(t=[],n.onlyInvisible&&(t=t.concat(this.invisibleEntities)),n.list)&&(t=t.concat(this.prepareListParam(n.list))),e.text=this.restoreEntitiesByIndex(e.text,r,t))},t.prototype.getByUtf=function(e,t){switch(t){case"digit":return this.entitiesByDigitEntity[e];case"name":return this.entitiesByNameEntity[e];case"js":return this.entitiesByJsEntity[e]}return e},t.prototype.prepareEntities=function(e){var r=[];return e.forEach(function(e){var t=e[0],e=e[1],n=String.fromCharCode(e);r.push({name:t,utf:n,reUtf:new RegExp(n,"g"),type:{name:"&"+t+";",digit:"&#"+e+";",js:"\\u"+("0000"+e.toString(16)).slice(-4)}})}),r},t.prototype.prepareListParam=function(e){var t=this,n=[];return e.forEach(function(e){e=t.entitiesByName[e];e&&n.push(e)}),n},t.prototype.restoreEntitiesByIndex=function(t,n,e){return e.forEach(function(e){t=t.replace(e.reUtf,e.type[n])}),t};var o=new t,a=[];function i(e){e=(e||"").split("/")[0];e&&"common"!==e&&!s(e)&&(a.push(e),a.sort())}function s(e){return"common"===e||-1!==a.indexOf(e)}function u(e,t){e=e||t;return e?Array.isArray(e)?e:[e]:[]}function l(e){if(!e.length)throw Error('Not defined the property "locale".');e.forEach(function(e){if(!s(e))throw Error('"'.concat(e,'" is not supported locale.'))})}var c={};function j(e){return c[e]}function p(t){Object.keys(t).forEach(function(e){i(e),c[e]=t[e]})}var N=["a","abbr","acronym","b","bdo","big","br","button","cite","code","dfn","em","i","img","input","kbd","label","map","object","q","samp","script","select","small","span","strong","sub","sup","textarea","time","tt","var"],g=new RegExp("(https?|file|ftp)://([a-zA-Z0-9/+-=%&:_.~?]+[a-zA-Z0-9#+]*)","g"),h="\\d+([.,]\\d+)?",O=/\d/;function f(e){return-1<e.search(O)}var d="",m="",M=($.prototype.add=function(e){this.tags.own.push(this.prepareRegExp(e))},$.prototype.show=function(t,n){for(var e=new RegExp("tf\\d+","g"),r=new RegExp("tf\\d"),a=function(e){return t.safeTags.hidden[n][e]||e},i=0,o=this.tags[n].length;i<o&&(t.text=t.text.replace(e,a),-1!==t.text.search(r));i++);},$.prototype.hide=function(t,e){var n=this,r=(t.safeTags.hidden[e]={},this.pasteLabel.bind(this,t,e));this.tags[e].forEach(function(e){t.text=t.text.replace(n.prepareRegExp(e),r)})},$.prototype.hideHTMLTags=function(e){var t;e.isHTML&&(t=this.pasteLabel.bind(this,e,"html"),e.text=e.text.replace(/<\/?[a-z][^]*?>/gi,t).replace(/<\/?[a-z][^]*?>/gi,t).replace(/&[gl]t;/gi,t))},$.prototype.getPrevLabel=function(e,t){for(var n=t-1;0<=n;n--)if(e[n]===d)return e.slice(n,t+1);return""},$.prototype.getNextLabel=function(e,t){for(var n=t+1;n<e.length;n++)if(e[n]===d)return e.slice(t,n+1);return""},$.prototype.getTagByLabel=function(n,r){var a=null;return this.groups.some(function(e){var t=n.safeTags.hidden[e][r];return a=void 0!==t?{group:e,value:t}:a}),a},$.prototype.getTagInfo=function(e){if(!e)return null;var t={group:e.group};switch(e.group){case"html":t.name=e.value.split(/[<\s>]/)[1],t.isInline=-1<N.indexOf(t.name),t.isClosing=-1<e.value.search(/^<\//);break;case"url":t.isInline=!0;break;case"own":t.isInline=!1}return t},$.prototype.pasteLabel=function(e,t,n){var e=e.safeTags,r="tf"+e.counter+d;return e.hidden[t][r]=n,e.counter++,r},$.prototype.prepareRegExp=function(e){var t,n;return e instanceof RegExp?e:(t=e[0],n=e[2],new RegExp(t+(void 0===n?"[^]*?":n)+e[1],"gi"))},$.prototype.getPrevTagInfo=function(e,t,n){t=this.getPrevLabel(t,n-1);if(t){n=this.getTagByLabel(e,t);if(n)return this.getTagInfo(n)}return null},$.prototype.getNextTagInfo=function(e,t,n){t=this.getNextLabel(t,n+1);if(t){n=this.getTagByLabel(e,t);if(n)return this.getTagInfo(n)}return null},$);function $(){this.groups=["own","html","url"],this.hidden={},this.counter=0;var t=[["\x3c!--","--\x3e"],["<!ENTITY",">"],["<!DOCTYPE",">"],["<\\?xml","\\?>"],["<!\\[CDATA\\[","\\]\\]>"]];["code","kbd","object","pre","samp","script","style","var"].forEach(function(e){t.push(["<".concat(e,"(\\s[^>]*?)?>"),"</".concat(e,">")])}),this.tags={own:[],html:t.map(this.prepareRegExp),url:[g]}}function b(e,t){for(var n="";1==(1&t)&&(n+=e),0!=(t>>>=1);)e+=e;return n}function x(e){return e.replace(/\u00A0/g," ")}function y(e,t){for(var n=0;n<t.length;n++)e=e.replace(t[n][0],t[n][1]);return e}function U(e){return-1!==e.search(/(<\/?[a-z]|<!|&[lg]t;)/i)}function v(e){return"object"==typeof e?JSON.parse(JSON.stringify(e)):e}var Q={symbols:110,number:150,space:210,dash:310,punctuation:410,nbsp:510,money:710,date:810,other:910,optalign:1010,typo:1110,html:1210},F=0,H="default",W=[],G=[];function R(){var e=n([],W,!0);return e.sort(function(e,t){return e.index>t.index?1:-1}),e}function X(){return n([],G,!0)}function J(e){var t=e.name.split("/"),n=t[0];return{name:e.name,shortName:t[2],handler:e.handler,queue:e.queue||H,enabled:!0!==e.disabled,locale:n,group:t[1],index:"number"==typeof(n=e).index?n.index:(t=n.name.split("/")[1],void 0===(t=Q[t])&&(t=F),"string"==typeof n.index?t+parseInt(n.index,10):t),settings:e.settings,live:e.live,htmlAttrs:e.htmlAttrs}}function V(e){return{type:(null==e?void 0:e.type)||"default",list:null==e?void 0:e.list,onlyInvisible:Boolean(null==e?void 0:e.onlyInvisible)}}function K(e){return e||"LF"}w.addRule=function(e){i((e=J(e=e)).locale),W.push(e)},w.addRules=function(e){var t=this;e.forEach(function(e){t.addRule(e)})},w.addInnerRule=function(e){G.push(J(e))},w.addInnerRules=function(e){var t=this;e.forEach(function(e){t.addInnerRule(e)})},w.getRule=function(t){var n=null;return R().some(function(e){return e.name===t&&(n=e,!0)}),n},w.getRules=R,w.getInnerRules=X,w.getLocales=function(){return a},w.addLocale=function(e){i(e)},w.hasLocale=s,w.setData=function(e){p(e)},w.getData=function(e){return c[e]},w.prototype.execute=function(e,t){var n;return(e=""+e)?(n=this.prefs,t=t,n=r({},n),t&&("locale"in t&&(n.locale=u(t.locale)),"htmlEntity"in t&&(n.htmlEntity=V(t.htmlEntity)),"lineEnding"in t&&(n.lineEnding=K(t.lineEnding)),"processingSeparateParts"in t&&(n.processingSeparateParts=t.processingSeparateParts),"ruleFilter"in t)&&(n.ruleFilter=t.ruleFilter),l((t=n).locale),n=this.prepareContext(e,t),this.process(n)):""},w.prototype.getSetting=function(e,t){return this.settings[e]&&this.settings[e][t]},w.prototype.setSetting=function(e,t,n){this.settings[e]=this.settings[e]||{},this.settings[e][t]=n},w.prototype.isEnabledRule=function(e){return!1!==this.enabledRules[e]},w.prototype.isDisabledRule=function(e){return!this.enabledRules[e]},w.prototype.enableRule=function(e){return this.enable(e,!0)},w.prototype.disableRule=function(e){return this.enable(e,!1)},w.prototype.addSafeTag=function(e,t,n){e=e instanceof RegExp?e:[e,t,n];this.safeTags.add(e)},w.prototype.prepareContext=function(e,n){return{text:e,isHTML:U(e),prefs:n,getData:function(t){return"char"===t?n.locale.map(function(e){return c[e+"/"+t]}).join(""):j(n.locale[0]+"/"+t)},safeTags:this.safeTags}},w.prototype.splitBySeparateParts=function(a){var i,e,o;return a.isHTML&&!1!==a.prefs.processingSeparateParts?(i=[],e=new RegExp("<("+this.separatePartsTags.join("|")+")(\\s[^>]*?)?>[^]*?</\\1>","gi"),o=0,a.text.replace(e,function(e,t,n,r){return o!==r&&i.push((o?m:"")+a.text.slice(o,r)+m),i.push(e),o=r+e.length,e}),i.push(o?m+a.text.slice(o,a.text.length):a.text),i):[a.text]},w.prototype.process=function(t){var e,n=this,r=(t.text=t.text.replace(/\r\n?/g,"\n"),this.executeRules(t,"start"),this.safeTags.hide(t,"own"),this.executeRules(t,"hide-safe-tags-own"),this.safeTags.hide(t,"html"),this.executeRules(t,"hide-safe-tags-html"),t.isHTML),a=new RegExp(m,"g");return t.text=this.splitBySeparateParts(t).map(function(e){return t.text=e,t.isHTML=U(e),n.safeTags.hideHTMLTags(t),n.safeTags.hide(t,"url"),n.executeRules(t,"hide-safe-tags-url"),n.executeRules(t,"hide-safe-tags"),o.toUtf(t),t.prefs.live&&(t.text=x(t.text)),n.executeRules(t,"utf"),n.executeRules(t),o.restore(t),n.executeRules(t,"html-entities"),n.safeTags.show(t,"url"),n.executeRules(t,"show-safe-tags-url"),t.text.replace(a,"")}).join(""),t.isHTML=r,this.safeTags.show(t,"html"),this.executeRules(t,"show-safe-tags-html"),this.safeTags.show(t,"own"),this.executeRules(t,"show-safe-tags-own"),this.executeRules(t,"end"),r=t.text,"CRLF"===(e=t.prefs.lineEnding)?r.replace(/\n/g,"\r\n"):"CR"===e?r.replace(/\n/g,"\r"):r},w.prototype.executeRules=function(t,e){var n=this,r=this.rulesByQueues[e=void 0===e?H:e],e=this.innerRulesByQueues[e];e&&e.forEach(function(e){n.ruleIterator(t,e)}),r&&r.forEach(function(e){n.ruleIterator(t,e)})},w.prototype.ruleIterator=function(e,t){!0===e.prefs.live&&!1===t.live||!1===e.prefs.live&&!0===t.live||"common"!==t.locale&&t.locale!==e.prefs.locale[0]||!this.isEnabledRule(t.name)||e.prefs.ruleFilter&&!e.prefs.ruleFilter(t)||(this.onBeforeRule&&this.onBeforeRule(t.name,e),e.text=t.handler.call(this,e.text,this.settings[t.name],e),this.onAfterRule&&this.onAfterRule(t.name,e))},w.prototype.prepareRuleSettings=function(e){this.settings[e.name]=v(e.settings),this.enabledRules[e.name]=e.enabled},w.prototype.enable=function(e,t){var n=this;Array.isArray(e)?e.forEach(function(e){n.enableByMask(e,t)}):this.enableByMask(e,t)},w.prototype.enableByMask=function(e,t){var n,r=this;e&&(-1!==e.search(/\*/)?(n=new RegExp(e.replace(/\//g,"\\/").replace(/\*/g,".*")),this.rules.forEach(function(e){e=e.name;n.test(e)&&(r.enabledRules[e]=t)})):this.enabledRules[e]=t)},w.groups=[],w.titles={},w.version="7.6.0";var E=w;function w(e){var t=this;this.rules=[],this.innerRules=[],this.rulesByQueues={},this.innerRulesByQueues={},this.separatePartsTags=["title","p","h[1-6]","select","legend"],this.prefs={locale:u((e=e).locale),lineEnding:K(e.lineEnding),live:Boolean(e.live),ruleFilter:e.ruleFilter,enableRule:e.enableRule,disableRule:e.disableRule,processingSeparateParts:e.processingSeparateParts,htmlEntity:V(e.htmlEntity)},l(this.prefs.locale),this.safeTags=new M,this.settings={},this.enabledRules={},this.innerRulesByQueues={},this.innerRules=X(),this.innerRules.forEach(function(e){t.innerRulesByQueues[e.queue]=t.innerRulesByQueues[e.queue]||[],t.innerRulesByQueues[e.queue].push(e)}),this.rulesByQueues={},this.rules=R(),this.rules.forEach(function(e){t.prepareRuleSettings(e),t.rulesByQueues[e.queue]=t.rulesByQueues[e.queue]||[],t.rulesByQueues[e.queue].push(e)}),this.prefs.disableRule&&this.disableRule(this.prefs.disableRule),this.prefs.enableRule&&this.enableRule(this.prefs.enableRule)}[{"common/char":"a-z","common/dash":"--?|‒|–|—","common/quote":'«‹»›„“‟”"'},{"be/char":"абвгдежзйклмнопрстуфхцчшыьэюяёіўґ","be/quote":{left:"«“",right:"»”"}},{"bg/char":"абвгдежзийклмнопрстуфхцчшщъьюя","bg/quote":{left:"„’",right:"“’"}},{"ca/char":"abcdefghijlmnopqrstuvxyzàçèéíïòóúü","ca/quote":{left:"«“",right:"»”"}},{"cs/char":"a-záéíóúýčďěňřšťůž","cs/quote":{left:"„‚",right:"“‘"}},{"da/char":"a-zåæø","da/quote":{left:"»›",right:"«‹"}},{"de/char":"a-zßäöü","de/quote":{left:"„‚",right:"“‘"}},{"el/char":"ΐάέήίΰαβγδεζηθικλμνξοπρςστυφχψωϊϋόύώϲάέήίόύώ","el/quote":{left:"«“",right:"»”"}},{"en-GB/char":"a-z","en-GB/quote":{left:"‘“",right:"’”"},"en-GB/shortWord":"a|an|and|as|at|bar|but|by|for|if|in|nor|not|of|off|on|or|out|per|pro|so|the|to|up|via|yet"},{"en-US/char":"a-z","en-US/quote":{left:"“‘",right:"”’"},"en-US/shortWord":"a|an|and|as|at|bar|but|by|for|if|in|nor|not|of|off|on|or|out|per|pro|so|the|to|up|via|yet"},{"eo/char":"abcdefghijklmnoprstuvzĉĝĥĵŝŭ","eo/quote":{left:"“‘",right:"”’"}},{"es/char":"a-záéíñóúü","es/quote":{left:"«“",right:"»”"}},{"et/char":"abdefghijklmnoprstuvzäõöüšž","et/quote":{left:"„«",right:"“»"}},{"fi/char":"abcdefghijklmnopqrstuvyöäå","fi/quote":{left:"”’",right:"”’"}},{"fr/char":"a-zàâçèéêëîïôûüœæ","fr/quote":{left:"«‹",right:"»›",spacing:!0}},{"ga/char":"abcdefghilmnoprstuvwxyzáéíóú","ga/quote":{left:"“‘",right:"”’"}},{"hu/char":"a-záäéíóöúüőű","hu/quote":{left:"„»",right:"”«"}},{"it/char":"a-zàéèìòù","it/quote":{left:"«“",right:"»”"},"it/shortWord":"a|da|di|in|la|il|lo|e|o|se|su|che|come|ma|è|ho|ha|sa"},{"lv/char":"abcdefghijklmnopqrstuvxzæœ","lv/quote":{left:"«„",right:"»“"}},{"nl/char":"a-zäçèéêëîïñöûü","nl/quote":{left:"‘“",right:"’”"}},{"no/char":"a-zåæèéêòóôø","no/quote":{left:"«’",right:"»’"}},{"pl/char":"abcdefghijklmnoprstuvwxyzóąćęłńśźż","pl/quote":{left:"„«",right:"”»"}},{"ro/char":"abcdefghijklmnoprstuvxzîășț","ro/quote":{left:"„«",right:"”»"}},{"ru/char":"а-яё","ru/dashBefore":"(^| |\\n)","ru/dashAfter":"(?=[ ,.?:!]|$)","ru/dashAfterDe":"(?=[,.?:!]|[ ][^А-ЯЁ]|$)","ru/l":"а-яёa-z","ru/L":"А-ЯЁA-Z","ru/month":"январь|февраль|март|апрель|май|июнь|июль|август|сентябрь|октябрь|ноябрь|декабрь","ru/monthGenCase":"января|февраля|марта|апреля|мая|июня|июля|августа|сентября|октября|ноября|декабря","ru/monthPreCase":"январе|феврале|марте|апреле|мае|июне|июле|августе|сентябре|октябре|ноябре|декабре","ru/quote":{left:"«„‚",right:"»“‘",removeDuplicateQuotes:!0},"ru/shortMonth":"янв|фев|мар|апр|ма[ейя]|июн|июл|авг|сен|окт|ноя|дек","ru/shortWord":"а|без|в|во|если|да|до|для|за|и|или|из|к|ко|как|ли|на|но|не|ни|о|об|обо|от|по|про|при|под|с|со|то|у","ru/weekday":"понедельник|вторник|среда|четверг|пятница|суббота|воскресенье"},{"sk/char":"abcdefghijklmnoprstuvwxyzáäéíóôúýčďľňŕšťž","sk/quote":{left:"„‚",right:"“‘"}},{"sl/char":"a-zčšž","sl/quote":{left:"„‚",right:"“‘"}},{"sr/char":"abcdefghijklmnoprstuvzćčđšž","sr/quote":{left:"„’",right:"”’"}},{"sv/char":"a-zäåéö","sv/quote":{left:"”’",right:"”’"}},{"tr/char":"abcdefghijklmnoprstuvyzâçîöûüğış","tr/quote":{left:"“‘",right:"”’"}},{"uk/char":"абвгдежзийклмнопрстуфхцчшщьюяєіїґ","uk/quote":{left:"«„",right:"»“"}}].forEach(p);var Y={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"},q={name:"common/html/escape",index:"+100",queue:"end",handler:function(e){return e.replace(/[&<>"'/]/g,function(e){return Y[e]})},disabled:!0},Z=new RegExp("<("+["address","article","aside","blockquote","canvas","dd","div","dl","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","header","hgroup","hr","li","main","nav","noscript","ol","output","p","pre","section","table","tfoot","ul","video"].join("|")+")[>\\s]"),q=(E.addRules([{name:"common/html/e-mail",queue:"end",handler:function(e,t,n){return n.isHTML?e:e.replace(/(^|[\s;(])([\w\-.]{2,64})@([\w\-.]{2,64})\.([a-z]{2,64})([)\s.,!?]|$)/gi,'$1<a href="mailto:$2@$3.$4">$2@$3.$4</a>$5')},disabled:!0,htmlAttrs:!1},q,{name:"common/html/nbr",index:"+10",queue:"end",handler:function(e){return e.replace(/([^\n>])\n(?=[^\n])/g,"$1<br/>\n")},disabled:!0,htmlAttrs:!1},{name:"common/html/p",index:"+5",queue:"end",handler:function(e){e=e.split("\n\n");return e.forEach(function(e,t,n){!e.trim()||Z.test(e)||(n[t]=e.replace(/^(\s*)/,"$1<p>").replace(/(\s*)$/,"</p>$1"))}),e.join("\n\n")},disabled:!0,htmlAttrs:!1},{name:"common/html/processingAttrs",queue:"hide-safe-tags-own",handler:function(e,t,n){var o=this,r=new RegExp("(^|\\s)("+t.attrs.join("|")+")=(\"[^\"]*?\"|'[^']*?')","gi"),s=v(n.prefs);return s.ruleFilter=function(e){return!1!==e.htmlAttrs},e.replace(/(<[-\w]+\s)([^>]+?)(?=>)/g,function(e,t,n){return t+n.replace(r,function(e,t,n,r){var a=r[0],i=r[r.length-1],r=r.slice(1,-1);return t+n+"="+a+o.execute(r,s)+i})})},settings:{attrs:["title","placeholder"]},disabled:!0,htmlAttrs:!1},{name:"common/html/quot",queue:"hide-safe-tags",handler:function(e){return e.replace(/"/g,'"')}},{name:"common/html/stripTags",index:"+99",queue:"end",handler:function(e){return e.replace(/<[^>]+>/g,"")},disabled:!0},{name:"common/html/url",queue:"end",handler:function(e,t,n){return n.isHTML?e:e.replace(g,function(e,t,n){n=n.replace(/([^/]+\/?)(\?|#)$/,"$1").replace(/^([^/]+)\/$/,"$1"),"http"===t?n=n.replace(/^([^/]+)(:80)([^\d]|\/|$)/,"$1$3"):"https"===t&&(n=n.replace(/^([^/]+)(:443)([^\d]|\/|$)/,"$1$3"));var r=n,n=t+"://"+n,a='<a href="'+n+'">';return"http"===t||"https"===t?(r=r.replace(/^www\./,""),a+("http"===t?r:t+"://"+r)+"</a>"):a+n+"</a>"})},disabled:!0,htmlAttrs:!1}]),{name:"common/nbsp/afterNumber",handler:function(e,t,n){n=n.getData("char");return e.replace(new RegExp("(^|\\s)(\\d{1,5}) (["+n+"]+)","gi"),"$1$2 $3")},disabled:!0});function _(e,t,n,r){return t+n.replace(/([^\u00A0])\u00A0([^\u00A0])/g,"$1 $2")+r}E.addRules([q,{name:"common/nbsp/afterParagraphMark",handler:function(e){return e.replace(/¶ ?(?=\d)/g,"¶ ")}},{name:"common/nbsp/afterSectionMark",handler:function(e,t,n){n=n.prefs.locale[0];return e.replace(/§[ \u00A0\u2009]?(?=\d|I|V|X)/g,"ru"===n?"§ ":"§ ")}},{name:"common/nbsp/afterShortWord",handler:function(e,t,n){var t=t.lengthShortWord,r=c["common/quote"],n=n.getData("char"),r=new RegExp("(^|["+(" ("+r)+"])(["+n+"]{1,"+t+"}) ","gim");return e.replace(r,"$1$2 ").replace(r,"$1$2 ")},settings:{lengthShortWord:2}},{name:"common/nbsp/afterShortWordByList",handler:function(e,t,n){var r=c["common/quote"],n=n.getData("shortWord"),r=new RegExp("(^|["+(" ("+r)+"])("+n+") ","gim");return e.replace(r,"$1$2 ").replace(r,"$1$2 ")}},{name:"common/nbsp/beforeShortLastNumber",handler:function(e,t,n){var r=n.getData("quote"),n=n.getData("char"),a=n.toUpperCase(),n=new RegExp("(["+n+a+"]) (?=\\d{1,"+t.lengthLastNumber+"}[-+−%'\""+r.right+")]?([.!?…]( ["+a+"]|$)|$))","gm");return e.replace(n,"$1 ")},live:!1,settings:{lengthLastNumber:2}},{name:"common/nbsp/beforeShortLastWord",handler:function(e,t,n){var n=n.getData("char"),r=n.toUpperCase(),n=new RegExp("(["+n+"\\d]) (["+n+r+"]{1,"+t.lengthLastWord+"}[.!?…])( ["+r+"]|$)","g");return e.replace(n,"$1 $2$3")},settings:{lengthLastWord:3}},{name:"common/nbsp/dpi",handler:function(e){return e.replace(/(\d) ?(lpi|dpi)(?!\w)/,"$1 $2")}},{name:"common/nbsp/nowrap",queue:"end",handler:function(e){return e.replace(/(<nowrap>)(.*?)(<\/nowrap>)/g,_).replace(/(<nobr>)(.*?)(<\/nobr>)/g,_)}},{name:"common/nbsp/replaceNbsp",queue:"utf",live:!1,handler:x,disabled:!0}]);q={name:"common/number/digitGrouping",index:"310",disabled:!0,handler:function(e,a){return e.replace(new RegExp("(^ ?|\\D |".concat(d,")(\\d{1,3}([ ]\\d{3})+)(?! ?[\\d-])"),"gm"),function(e,t,n){return t+n.replace(/\s/g,a.space)}).replace(/(\d{5,}([.,]\d+)?)/g,function(e,t){var n=t.match(/[.,]/),t=n?t.split(n):[t],r=t[0],t=t[1],r=r.replace(/(\d)(?=(\d{3})+([^\d]|$))/g,"$1"+a.space);return n?r+n+t:r})},settings:{space:" "}},E.addRules([q,{name:"common/number/fraction",handler:function(e){return e.replace(/(^|\D)1\/2(\D|$)/g,"$1½$2").replace(/(^|\D)1\/4(\D|$)/g,"$1¼$2").replace(/(^|\D)3\/4(\D|$)/g,"$1¾$2")}},{name:"common/number/mathSigns",handler:function(e){return y(e,[[/!=/g,"≠"],[/<=/g,"≤"],[/(^|[^=])>=/g,"$1≥"],[/<=>/g,"⇔"],[/<</g,"≪"],[/>>/g,"≫"],[/~=/g,"≅"],[/(^|[^+])\+-/g,"$1±"]])}},{name:"common/number/times",handler:function(e){return e.replace(/(\d)[ \u00A0]?[xх][ \u00A0]?(\d)/g,"$1×$2")}}]),E.addRules([{name:"common/other/delBOM",queue:"start",index:-1,handler:function(e){return 65279===e.charCodeAt(0)?e.slice(1):e}},{name:"common/other/repeatWord",handler:function(e,t,n){var r=c["common/quote"],n=n.getData("char"),r="[;:,.?! \n"+r+"]",n=new RegExp("("+r+"|^)(["+n+"]{"+t.min+",})[ ]\\2("+r+"|$)","gi");return e.replace(n,"$1$2$3")},settings:{min:2},disabled:!0}]),q={name:"common/punctuation/apostrophe",handler:function(e,t,n){n="(["+n.getData("char")+"])",n=new RegExp(n+"'"+n,"gi");return e.replace(n,"$1’$2")}};function A(){this.bufferQuotes={left:"",right:""},this.beforeLeft=" \n\t [(",this.afterRight=" \n\t !?.:;#*,…)\\]"}A.prototype.process=function(e){var t,n,r=e.context.text;return this.count(r).total&&(t=e.settings,(n=e.settings.left[0]===e.settings.right[0])&&(e.settings=v(e.settings),e.settings.left=this.bufferQuotes.left.slice(0,e.settings.left.length),e.settings.right=this.bufferQuotes.right.slice(0,e.settings.right.length)),e.settings.spacing&&(r=this.removeSpacing(r,e.settings)),r=this.set(r,e),e.settings.spacing&&(r=this.setSpacing(r,e.settings)),e.settings.removeDuplicateQuotes&&(r=this.removeDuplicates(r,e.settings)),n)&&(r=this.returnOriginalQuotes(r,t,e.settings),e.settings=t),r},A.prototype.returnOriginalQuotes=function(e,t,n){for(var r={},a=0;a<n.left.length;a++)r[n.left[a]]=t.left[a],r[n.right[a]]=t.right[a];return e.replace(new RegExp("["+n.left+n.right+"]","g"),function(e){return r[e]})},A.prototype.count=function(e){var t={total:0};return e.replace(new RegExp("["+c["common/quote"]+"]","g"),function(e){return t[e]||(t[e]=0),t[e]++,t.total++,e}),t},A.prototype.removeDuplicates=function(e,t){var n=t.left[0],r=t.left[1]||n,t=t.right[0];return n!==r?e:e.replace(new RegExp(n+n,"g"),n).replace(new RegExp(t+t,"g"),t)},A.prototype.removeSpacing=function(e,t){for(var n=0,r=t.left.length;n<r;n++){var a=t.left[n],i=t.right[n];e=e.replace(new RegExp(a+"([ ])","g"),a).replace(new RegExp("([ ])"+i,"g"),i)}return e},A.prototype.setSpacing=function(e,t){for(var n=0,r=t.left.length;n<r;n++){var a=t.left[n],i=t.right[n];e=e.replace(new RegExp(a+"([^ ])","g"),a+" $1").replace(new RegExp("([^ ])"+i,"g"),"$1 "+i)}return e},A.prototype.set=function(e,t){var n=c["common/quote"],r=t.settings.left[0],a=t.settings.left[1]||r,i=t.settings.right[0],o=new RegExp("(^|["+this.beforeLeft+"])(["+n+"]+)(?=[^\\s"+d+"])","gim"),n=new RegExp("([^\\s])(["+n+"]+)(?=["+this.afterRight+"]|$)","gim");return e=e.replace(o,function(e,t,n){return t+b(r,n.length)}).replace(n,function(e,t,n){return t+b(i,n.length)}),e=this.setAboveTags(e,t),e=r!==a?this.setInner(e,t.settings):e},A.prototype.setAboveTags=function(i,o){var s=this,u=o.settings.left[0],l=o.settings.right[0];return i.replace(new RegExp("(^|.)(["+c["common/quote"]+"])(.|$)","gm"),function(e,t,n,r,a){return t!==d&&r!==d?e:t===d&&r===d?'"'===n?t+s.getAboveTwoTags(i,a+1,o)+r:e:t===d?(n=-1<s.afterRight.indexOf(r),e=o.safeTags.getPrevTagInfo(o.context,i,a+1),n&&e&&"html"===e.group?t+(e.isClosing?l:u)+r:t+(!r||n?l:u)+r):(e=-1<s.beforeLeft.indexOf(t),n=o.safeTags.getNextTagInfo(o.context,i,a+1),e&&n&&"html"===n.group?t+(n.isClosing?l:u)+r:t+(!t||e?u:l)+r)})},A.prototype.getAboveTwoTags=function(e,t,n){var r=n.safeTags.getPrevTagInfo(n.context,e,t),a=n.safeTags.getNextTagInfo(n.context,e,t);if(r&&"html"===r.group){if(!r.isClosing)return n.settings.left[0];if(a&&a.isClosing&&r.isClosing)return n.settings.right[0]}return e[t]},A.prototype.setInner=function(e,t){for(var n=t.left[0],r=t.right[0],a=this.getMaxLevel(e,n,r,t.left.length),i=0,o="",s=0,u=e.length;s<u;s++){var l=e[s];l===n?(o+=t.left[a-1<i?a-1:i],a<++i&&(i=a)):l===r?(--i<0&&(i=0),o+=t.right[i]):('"'===l&&(i=0),o+=l)}return o},A.prototype.getMaxLevel=function(e,t,n,r){e=this.count(e);return e[t]===e[n]?r:Math.min(r,2)};var ee=new A,te={},T=(a.forEach(function(e){te[e]=v(c[e+"/quote"])}),{name:"common/punctuation/quote",handler:function(e,t,n){t=t[n.prefs.locale[0]];return t?ee.process({context:n,settings:t,safeTags:this.safeTags}):e},settings:te}),q=(E.addRules([q,{name:"common/punctuation/delDoublePunctuation",handler:function(e){return e.replace(/(^|[^,]),,(?!,)/g,"$1,").replace(/(^|[^:])::(?!:)/g,"$1:").replace(/(^|[^!?.])\.\.(?!\.)/g,"$1.").replace(/(^|[^;]);;(?!;)/g,"$1;").replace(/(^|[^?])\?\?(?!\?)/g,"$1?")}},{name:"common/punctuation/hellip",handler:function(e,t,n){return"ru"===n.prefs.locale[0]?e.replace(/(^|[^.])\.{3,4}(?=[^.]|$)/g,"$1…"):e.replace(/(^|[^.])\.{3}(\.?)(?=[^.]|$)/g,"$1…$2")}},T,{name:"common/punctuation/quoteLink",queue:"show-safe-tags-html",index:"+5",handler:function(e,t,n){var n=this.getSetting("common/punctuation/quote",n.prefs.locale[0]),r=o.getByUtf(n.left[0]),a=o.getByUtf(n.right[0]),i=(i=o.getByUtf(n.left[1]))?"|"+i:"",n=(n=o.getByUtf(n.right[1]))?"|"+n:"",r=new RegExp("(<[aA]\\s[^>]*?>)("+r+i+")([^]*?)("+a+n+")(</[aA]>)","g");return e.replace(r,"$2$1$3$5$4")}}]),{name:"common/space/beforeBracket",handler:function(e,t,n){n=n.getData("char"),n=new RegExp("(["+n+".!?,;…)])\\(","gi");return e.replace(n,"$1 (")}}),T={name:"common/space/delRepeatN",index:"-1",handler:function(e,t){var t=t.maxConsecutiveLineBreaks,n=new RegExp("\n{".concat(t+1,",}"),"g"),t=b("\n",t);return e.replace(n,t)},settings:{maxConsecutiveLineBreaks:2}},B={name:"common/space/trimLeft",index:"-4",handler:String.prototype.trimLeft?function(e){return e.trimLeft()}:function(e){return e.replace(/^[\s\uFEFF\xA0]+/g,"")}},ne={name:"common/space/trimRight",index:"-3",live:!1,handler:String.prototype.trimRight?function(e){return e.trimRight()}:function(e){return e.replace(/[\s\uFEFF\xA0]+$/g,"")}},re=new RegExp('(\\D):([^)",:.?\\s\\/\\\\])',"g"),k={name:"common/space/afterColon",handler:function(e){return e.replace(re,"$1: $2")}},L={name:"common/space/afterComma",handler:function(e,t,n){n=n.getData("quote"),n="string"==typeof n?n:n.right;return e.replace(new RegExp('(.),([^)",:.?\\s\\/\\\\'+n+"])","g"),function(e,t,n){return f(t)&&f(n)?e:t+", "+n})}},ae=new RegExp("\\?([^).…!;?\\s[\\])"+c["common/quote"]+"])","g"),D={name:"common/space/afterQuestionMark",handler:function(e){return e.replace(ae,"? $1")}},ie=new RegExp("!([^).…!;?\\s[\\])"+c["common/quote"]+"])","g"),S={name:"common/space/afterExclamationMark",handler:function(e){return e.replace(ie,"! $1")}},oe=new RegExp(";([^).…!;?\\s[\\])"+c["common/quote"]+"])","g"),k=(E.addRules([k,L,D,S,{name:"common/space/afterSemicolon",handler:function(e){return e.replace(oe,"; $1")}},q,{name:"common/space/bracket",handler:function(e){return e.replace(/(\() +/g,"(").replace(/ +\)/g,")")}},{name:"common/space/delBeforeDot",handler:function(e){return e.replace(/(^|[^!?:;,.…]) (\.|\.\.\.)(\s|$)/g,"$1$2$3")}},{name:"common/space/delBeforePercent",handler:function(e){return e.replace(/(\d)( |\u00A0)(%|‰|‱)/g,"$1$3")}},{name:"common/space/delBeforePunctuation",handler:function(e){return e.replace(/(^|[^!?:;,.…]) ([!?:;,])(?!\))/g,"$1$2")}},{name:"common/space/delBetweenExclamationMarks",handler:function(e){return e.replace(/([!?]) (?=[!?])/g,"$1")}},{name:"common/space/delLeadingBlanks",handler:function(e){return e.replace(/^[ \t]+/gm,"")},disabled:!0},T,{name:"common/space/delRepeatSpace",index:"-1",handler:function(e){return e.replace(/([^\n \t])[ \t]{2,}(?![\n \t])/g,"$1 ")}},{name:"common/space/delTrailingBlanks",index:"-3",handler:function(e){return e.replace(/[ \t]+\n/g,"\n")}},{name:"common/space/insertFinalNewline",queue:"end",handler:function(e){return"\n"===e[e.length-1]?e:e+"\n"},live:!1,disabled:!0},{name:"common/space/replaceTab",index:"-5",handler:function(e){return e.replace(/\t/g," ")}},{name:"common/space/squareBracket",handler:function(e){return e.replace(/(\[) +/g,"[").replace(/ +\]/g,"]")}},B,ne]),{name:"common/symbols/arrow",handler:function(e){return y(e,[[/(^|[^-])->(?!>)/g,"$1→"],[/(^|[^<])<-(?!-)/g,"$1←"]])}}),L=(E.addRules([k,{name:"common/symbols/cf",handler:function(e){var t=new RegExp('(^|[\\s(\\[+≈±−—–\\-])(\\d+(?:[.,]\\d+)?)[ ]?(C|F)([\\W\\s.,:!?")\\]]|$)',"mg");return e.replace(t,"$1$2 °$3$4")}},{name:"common/symbols/copy",handler:function(e){return y(e,[[/\(r\)/gi,"®"],[/(copyright )?\((c|с)\)/gi,"©"],[/\(tm\)/gi,"™"]])}}]),{name:"en-US/dash/main",index:"-5",handler:function(e){var t=c["common/dash"],n="[ ".concat(" ","]"),r="[ ".concat(" ","\n]"),n=new RegExp("".concat(n,"(").concat(t,")(").concat(r,")"),"g");return e.replace(n,"".concat(" ").concat("—","$2"))}}),D=(E.addRules([L]),{name:"ru/dash/centuries",handler:function(e,t){var n=new RegExp("(X|I|V)[ | ]?"+("("+c["common/dash"]+")")+"[ | ]?(X|I|V)","g");return e.replace(n,"$1"+t.dash+"$3")},settings:{dash:"–"}}),S=(E.addRules([D,{name:"ru/dash/daysMonth",handler:function(e,t){var n=new RegExp("(^|\\s)([123]?\\d)("+c["common/dash"]+")([123]?\\d)[ ]("+c["ru/monthGenCase"]+")","g");return e.replace(n,"$1$2"+t.dash+"$4 $5")},settings:{dash:"–"}},{name:"ru/dash/de",handler:function(e){var t=new RegExp("([a-яё]+) де"+c["ru/dashAfterDe"],"g");return e.replace(t,"$1-де")},disabled:!0},{name:"ru/dash/decade",handler:function(e,t){var n=new RegExp("(^|\\s)(\\d{3}|\\d)0("+c["common/dash"]+")(\\d{3}|\\d)0(-е[ ])(?=г\\.?[ ]?г|год)","g");return e.replace(n,"$1$20"+t.dash+"$40$5")},settings:{dash:"–"}},{name:"ru/dash/directSpeech",handler:function(e){var t=c["common/dash"],n=new RegExp('(["»‘“,])[ | ]?('.concat(t,")[ | ]"),"g"),r=new RegExp("(^|".concat(d,")(").concat(t,")( | )"),"gm"),t=new RegExp("([.…?!])[ ](".concat(t,")[ ]"),"g");return e.replace(n,"$1 — ").replace(r,"$1— ").replace(t,"$1 — ")}},{name:"ru/dash/izpod",handler:function(e){var t=new RegExp(c["ru/dashBefore"]+"(И|и)з под"+c["ru/dashAfter"],"g");return e.replace(t,"$1$2з-под")}},{name:"ru/dash/izza",handler:function(e){var t=new RegExp(c["ru/dashBefore"]+"(И|и)з за"+c["ru/dashAfter"],"g");return e.replace(t,"$1$2з-за")}},{name:"ru/dash/ka",handler:function(e){var t=new RegExp("([a-яё]+) ка(сь)?"+c["ru/dashAfter"],"g");return e.replace(t,"$1-ка$2")}},{name:"ru/dash/koe",handler:function(e){var t=new RegExp(c["ru/dashBefore"]+"([Кк]о[ей])\\s([а-яё]{3,})"+c["ru/dashAfter"],"g");return e.replace(t,"$1$2-$3")}},{name:"ru/dash/main",index:"-5",handler:function(e){var t=new RegExp("([ ])("+c["common/dash"]+")([ \\n])","g");return e.replace(t," —$3")}},{name:"ru/dash/month",handler:function(e,t){var n="("+c["ru/month"]+")",r="("+c["ru/monthPreCase"]+")",a=c["common/dash"],n=new RegExp(n+" ?("+a+") ?"+n,"gi"),a=new RegExp(r+" ?("+a+") ?"+r,"gi"),r="$1"+t.dash+"$3";return e.replace(n,r).replace(a,r)},settings:{dash:"–"}},{name:"ru/dash/surname",handler:function(e){var t=new RegExp("([А-ЯЁ][а-яё]+)\\s-([а-яё]{1,3})(?![^а-яё]|$)","g");return e.replace(t,"$1 —$2")}},{name:"ru/dash/taki",handler:function(e){var t=new RegExp("(верно|довольно|опять|прямо|так|вс[её]|действительно|неужели)\\s(таки)"+c["ru/dashAfter"],"g");return e.replace(t,"$1-$2")}},{name:"ru/dash/time",handler:function(e,t){var n=new RegExp(c["ru/dashBefore"]+"(\\d?\\d:[0-5]\\d)"+c["common/dash"]+"(\\d?\\d:[0-5]\\d)"+c["ru/dashAfter"],"g");return e.replace(n,"$1$2"+t.dash+"$3")},settings:{dash:"–"}},{name:"ru/dash/to",handler:function(e){var t=new RegExp("(^|[^А-ЯЁа-яё\\w])([Оо]ткуда|[Кк]уда|[Гг]де|[Кк]огда|[Зз]ачем|[Пп]очему|[Кк]ак|[Кк]ако[ейм]|[Кк]акая|[Кк]аки[емх]|[Кк]акими|[Кк]акую|[Чч]то|[Чч]его|[Чч]е[йм]|[Чч]ьим?|[Кк]то|[Кк]ого|[Кк]ому|[Кк]ем)( | -|- )(то|либо|нибудь)"+c["ru/dashAfter"],"g");return e.replace(t,function(e,t,n,r,a){r=n+r+a;return"как то"===r||"Как то"===r?e:t+n+"-"+a})}},{name:"ru/dash/kakto",handler:function(e){var t=new RegExp("(^|[^А-ЯЁа-яё\\w])([Кк]ак) то"+c["ru/dashAfter"],"g");return e.replace(t,"$1$2-то")}},{name:"ru/dash/weekday",handler:function(e,t){var n="("+c["ru/weekday"]+")",n=new RegExp(n+" ?("+c["common/dash"]+") ?"+n,"gi");return e.replace(n,"$1"+t.dash+"$3")},settings:{dash:"–"}},{name:"ru/dash/years",handler:function(e,i){var t=new RegExp("(\\D|^)(\\d{4})[ ]?("+c["common/dash"]+")[ ]?(\\d{4})(?=[ ]?г)","g");return e.replace(t,function(e,t,n,r,a){return parseInt(n,10)<parseInt(a,10)?t+n+i.dash+a:e})},settings:{dash:"–"}}]),"(-|\\.|\\/)"),q="(-|\\/)",se=new RegExp("(^|\\D)(\\d{4})"+S+"(\\d{2})"+S+"(\\d{2})(\\D|$)","gi"),ue=new RegExp("(^|\\D)(\\d{2})"+q+"(\\d{2})"+q+"(\\d{4})(\\D|$)","gi"),T=(E.addRules([{name:"ru/date/fromISO",handler:function(e){return e.replace(se,"$1$6.$4.$2$7").replace(ue,"$1$4.$2.$6$7")}},{name:"ru/date/weekday",handler:function(e){var t=new RegExp("(\\d)( | )("+c["ru/monthGenCase"]+"),( | )("+c["ru/weekday"]+")","gi");return e.replace(t,function(e,t,n,r,a,i){return t+n+r.toLowerCase()+","+a+i.toLowerCase()})}}]),{name:"ru/money/currency",handler:function(e){var t="([$€¥Ұ£₤₽])",n=new RegExp("(^|[\\D]{2})"+t+" ?("+h+"([ ]\\d{3})*)([ ]?(тыс\\.|млн|млрд|трлн))?","gm"),t=new RegExp("(^|[\\D])("+h+") ?"+t,"gm");return e.replace(n,function(e,t,n,r,a,i,o,s){return t+r+(s?" "+s:"")+" "+n}).replace(t,"$1$2 $4")},disabled:!0});function le(e,t,n,r){return"дд"===n&&"мм"===r||-1<["рф","ру","рус","орг","укр","бг","срб"].indexOf(r)?e:t+n+". "+r+"."}E.addRules([T,{name:"ru/money/ruble",handler:function(e){var t="$1 ₽",n="(\\d+)( | )?(р|руб)\\.",r=new RegExp("^"+n+"$","g"),a=new RegExp(n+"(?=[!?,:;])","g"),n=new RegExp(n+"(?=\\s+[A-ЯЁ])","g");return e.replace(r,t).replace(a,t).replace(n,t+".")},disabled:!0}]);var ce={2:"²","²":"²",3:"³","³":"³","":""};E.addRules([{name:"ru/nbsp/abbr",handler:function(e){var t=new RegExp("(^|\\s|".concat(d,")([а-яё]{1,3})\\. ?([а-яё]{1,3})\\."),"g");return e.replace(t,le).replace(t,le)}},{name:"ru/nbsp/addr",handler:function(e){return e.replace(/(\s|^)(дом|д\.|кв\.|под\.|п-д) *(\d+)/gi,"$1$2 $3").replace(/(\s|^)(мкр-н|мк-н|мкр\.|мкрн)\s/gi,"$1$2 ").replace(/(\s|^)(эт\.) *(-?\d+)/gi,"$1$2 $3").replace(/(\s|^)(\d+) +этаж([^а-яё]|$)/gi,"$1$2 этаж$3").replace(/(\s|^)литер\s([А-Я]|$)/gi,"$1литер $2").replace(/(\s|^)(обл|кр|ст|пос|с|д|ул|пер|пр|пр-т|просп|пл|бул|б-р|наб|ш|туп|оф|комн?|уч|вл|влад|стр|кор)\. *([а-яёa-z\d]+)/gi,"$1$2. $3").replace(/(\D[ \u00A0]|^)г\. ?([А-ЯЁ])/gm,"$1г. $2")}},{name:"ru/nbsp/afterNumberSign",handler:function(e){return e.replace(/№[ \u00A0\u2009]?(\d|п\/п)/g,"№ $1")}},{name:"ru/nbsp/beforeParticle",index:"+5",handler:function(e){var t="(ли|ль|же|ж|бы|б)",n=new RegExp("([А-ЯЁа-яё]) "+t+'(?=[,;:?!"‘“»])',"g"),t=new RegExp("([А-ЯЁа-яё])[ ]"+t+"[ ]","g");return e.replace(n,"$1 $2").replace(t,"$1 $2 ")}},{name:"ru/nbsp/centuries",handler:function(e){var t=c["common/dash"],n="(^|\\s)([VIX]+)",r='(?=[,;:?!"‘“»]|$)',a=new RegExp(n+"[ ]?в\\.?"+r,"gm"),n=new RegExp(n+"("+t+")([VIX]+)[ ]?в\\.?([ ]?в\\.?)?"+r,"gm");return e.replace(a,"$1$2 в.").replace(n,"$1$2$3$4 вв.")}},{name:"ru/nbsp/dayMonth",handler:function(e){var t=new RegExp("(\\d{1,2}) ("+c["ru/shortMonth"]+")","gi");return e.replace(t,"$1 $2")}},{name:"ru/nbsp/initials",handler:function(e){var t=new RegExp("(^|[( "+c["ru/quote"].left+d+'"])([А-ЯЁ])\\.[ ]?([А-ЯЁ])\\.[ ]?([А-ЯЁ][а-яё]+)',"gm");return e.replace(t,"$1$2. $3. $4")}},{name:"ru/nbsp/m",index:"+5",handler:function(e){var t=new RegExp("(^|[\\s,.\\(])(\\d+)[ ]?(мм?|см|км|дм|гм|mm?|km|cm|dm)([23²³])?([\\s\\).!?,;]|$)","gm");return e.replace(t,function(e,t,n,r,a,i){return t+n+" "+r+ce[a||""]+(" "===i?" ":i)})}},{name:"ru/nbsp/mln",handler:function(e){return e.replace(/(\d) ?(тыс|млн|млрд|трлн)(\.|\s|$)/gi,"$1 $2$3")}},{name:"ru/nbsp/ooo",handler:function(e){return e.replace(/(^|[^a-яёA-ЯЁ])(ООО|ОАО|ЗАО|НИИ|ПБОЮЛ) /g,"$1$2 ")}},{name:"ru/nbsp/page",handler:function(e){var t=new RegExp("(^|[)\\s])(стр|гл|рис|илл?|ст|п|c)\\. *(\\d+)([\\s.,?!;:]|$)","gim");return e.replace(t,"$1$2. $3$4")}},{name:"ru/nbsp/ps",handler:function(e){var t=new RegExp("(^|\\s|".concat(d,")[pз]\\.[ ]?([pз]\\.[ ]?)?[sы]\\.:? "),"gim");return e.replace(t,function(e,t,n){return t+(n?"P. P. S. ":"P. S. ")})}},{name:"ru/nbsp/rubleKopek",handler:function(e){return e.replace(/(\d) ?(?=(руб|коп)\.)/g,"$1 ")}},{name:"ru/nbsp/see",handler:function(e){var t=new RegExp("(^|\\s|".concat(d,"|\\()(см|им)\\.[ ]?([а-яё0-9a-z]+)([\\s.,?!]|$)"),"gi");return e.replace(t,function(e,t,n,r,a){return(" "===t?" ":t)+n+". "+r+a})}},{name:"ru/nbsp/year",handler:function(e){return e.replace(/(^|\D)(\d{4}) ?г([ ,;.\n]|$)/g,"$1$2 г$3")}},{name:"ru/nbsp/years",index:"+5",handler:function(e){var t=new RegExp("(^|\\D)(\\d{4})("+c["common/dash"]+')(\\d{4})[ ]?г\\.?([ ]?г\\.)?(?=[,;:?!"‘“»\\s]|$)',"gm");return e.replace(t,"$1$2$3$4 гг.")}}]);function I(e,t){t=new RegExp('<span class="('+t.join("|")+')">([^]*?)</span>',"g");return e.replace(t,"$2")}function z(e,t){return e.replace(/<title>[^]*?<\/title>/i,function(e){return I(e,t)})}E.addRules([{name:"ru/number/comma",handler:function(e){return e.replace(/(^|\s)(\d+)\.(\d+[\u00A0\u2009\u202F ]*?[%‰°×x])/gim,"$1$2,$3")}},{name:"ru/number/ordinals",handler:function(e,t,n){n=n.getData("char"),n=new RegExp("(\\d[%‰]?)-(ый|ой|ая|ое|ые|ым|ом|ых|ого|ому|ыми)(?!["+n+"])","g");return e.replace(n,function(e,t,n){return t+"-"+{"ой":"й","ый":"й","ая":"я","ое":"е","ые":"е","ым":"м","ом":"м","ых":"х","ого":"го","ому":"му","ыми":"ми"}[n]})}}]);var pe=["typograf-oa-lbracket","typograf-oa-n-lbracket","typograf-oa-sp-lbracket"],B="ru/optalign/bracket",ne={name:B,queue:"start",handler:function(e){return I(e,pe)},htmlAttrs:!1},k={name:B,queue:"end",handler:function(e){return z(e,pe)},htmlAttrs:!1},ge=["typograf-oa-comma","typograf-oa-comma-sp"],L="ru/optalign/comma",D={name:L,queue:"start",handler:function(e){return I(e,ge)},htmlAttrs:!1},S={name:L,queue:"end",handler:function(e){return z(e,ge)},htmlAttrs:!1},he=["typograf-oa-lquote","typograf-oa-n-lquote","typograf-oa-sp-lquote"],q="ru/optalign/quote",T={name:q,queue:"start",handler:function(e){return I(e,he)},htmlAttrs:!1},fe={name:q,queue:"end",handler:function(e){return z(e,he)},htmlAttrs:!1},C=(E.addRules([{name:B,handler:function(e){return e.replace(/( |\u00A0)\(/g,'<span class="typograf-oa-sp-lbracket">$1</span><span class="typograf-oa-lbracket">(</span>').replace(/^\(/gm,'<span class="typograf-oa-n-lbracket">(</span>')},disabled:!0,htmlAttrs:!1},{name:L,handler:function(e,t,n){n=n.getData("char"),n=new RegExp("(["+n+"\\d́]+), ","gi");return e.replace(n,'$1<span class="typograf-oa-comma">,</span><span class="typograf-oa-comma-sp"> </span>')},disabled:!0,htmlAttrs:!1},{name:q,handler:function(e){var t=this.getSetting("common/punctuation/quote","ru"),t="(["+t.left[0]+(t.left[1]||"")+"])",n=new RegExp("(^|\n\n|)("+t+")","g"),t=new RegExp("([^\n])([ \n])("+t+")","gi");return e.replace(n,'$1<span class="typograf-oa-n-lquote">$2</span>').replace(t,'$1<span class="typograf-oa-sp-lquote">$2</span><span class="typograf-oa-lquote">$3</span>')},disabled:!0,htmlAttrs:!1}]),E.addInnerRules([ne,k,D,S,T,fe]),[]);function de(e){var t,n,r=e[0],a="";if(e.length<8)return me(e);if(10<e.length)if("+"===r){if("7"!==e[1])return e;t=!0,e=e.substr(2)}else"8"===r&&(n=!0,e=e.substr(1));for(var i=8;2<=i;i--){var o=+e.substr(0,i);if(-1<C.indexOf(o)){a=e.substr(0,i),e=e.substr(i);break}}return a||(a=e.substr(0,5),e=e.substr(5)),(t?"+7 ":"")+(n?"8 ":"")+(e=>{var t=+e,n=e.length,r=[e],a=!1;if(3<n)switch(n){case 4:r=[e.substr(0,2),e.substr(2,2)];break;case 5:r=[e.substr(0,3),e.substr(3,3)];break;case 6:r=[e.substr(0,2),e.substr(2,2),e.substr(4,2)]}else a=900<t&&t<=999||495==t||499==t||800==t;return n=r.join("-"),a?n:"("+n+")"})(a)+" "+me(e)}function me(e){var t="";return e.length%2&&(t=e[0],t+=e.length<=5?"-":"",e=e.substr(1,e.length-1)),t+e.split(/(?=(?:\d\d)+$)/).join("-")}function $e(e){return e.replace(/[^\d+]/g,"")}[4162,416332,8512,851111,4722,4725,391379,8442,4732,4152,4154451,4154459,4154455,41544513,8142,8332,8612,8622,3525,812,8342,8152,3812,4862,3422,342633,8112,9142,8452,3432,3434,3435,4812,8432,8439,3822,4872,3412,3511,3512,3022,4112,4852,4855,3852,3854,8182,818,90,3472,4741,4764,4832,4922,8172,8202,8722,4932,493,3952,3951,3953,411533,4842,3842,3843,8212,4942,"39131-39179","39190-39199",391,4712,4742,8362,495,499,4966,4964,4967,498,8312,8313,3832,383612,3532,8412,4232,423370,423630,8632,8642,8482,4242,8672,8652,4752,4822,482502,4826300,3452,8422,4212,3466,3462,8712,8352,800,"901-934","936-939","950-953",958,"960-969","977-989","991-997",999].forEach(function(e){if("string"==typeof e)for(var t=e.split("-"),n=+t[0];n<=+t[1];n++)C.push(n);else C.push(e)});E.addRules([{name:"ru/other/accent",handler:function(e){return e.replace(/([а-яё])([АЕЁИОУЫЭЮЯ])([^А-ЯЁ\w]|$)/g,function(e,t,n,r){return t+n.toLowerCase()+"́"+r})},disabled:!0},{name:"ru/other/phone-number",live:!1,handler:function(e){var t=new RegExp("(^|,| |)(\\+7[\\d\\(\\) -]{10,18})(?=,|;||$)","gm");return e.replace(t,function(e,t,n){n=$e(n);return 12===n.length?t+de(n):e}).replace(/(^|[^а-яё])([☎☏✆📠📞📱]|т\.|тел\.|ф\.|моб\.|факс|сотовый|мобильный|телефон)(:?\s*?)([+\d(][\d \u00A0\-()]{3,}\d)/gi,function(e,t,n,r,a){a=$e(a);return 5<=a.length?t+n+r+de(a):e})}}]);var B={name:"ru/punctuation/ano",handler:function(e){var t=new RegExp("([^«„[(!?,:;\\-‒–—\\s])(\\s+)(а|но)(?= | |\\n)","g");return e.replace(t,"$1,$2$3")}},be=(E.addRules([B,{name:"ru/punctuation/exclamation",handler:function(e){return e.replace(/(^|[^!])!{2}($|[^!])/gm,"$1!$2").replace(/(^|[^!])!{4}($|[^!])/gm,"$1!!!$2")},live:!1},{name:"ru/punctuation/exclamationQuestion",index:"+5",handler:function(e){var t=new RegExp("(^|[^!])!\\?([^?]|$)","g");return e.replace(t,"$1?!$2")}},{name:"ru/punctuation/hellipQuestion",handler:function(e){return e.replace(/(^|[^.])(\.\.\.|…),/g,"$1…").replace(/(!|\?)(\.\.\.|…)(?=[^.]|$)/g,"$1..")}}]),E.addRules([{name:"ru/space/afterHellip",handler:function(e){return e.replace(/([а-яё])(\.\.\.|…)([А-ЯЁ])/g,"$1$2 $3").replace(/([?!]\.\.)([а-яёa-z])/gi,"$1 $2")}},{name:"ru/space/year",handler:function(e,t,n){n=n.getData("char"),n=new RegExp("(^| | )(\\d{3,4})(год([ауе]|ом)?)([^"+n+"]|$)","g");return e.replace(n,"$1$2 $3$5")}}]),E.addRules([{name:"ru/symbols/NN",handler:function(e){return e.replace(/№№/g,"№")}}]),{A:"А",a:"а",B:"В",E:"Е",e:"е",K:"К",M:"М",H:"Н",O:"О",o:"о",P:"Р",p:"р",C:"С",c:"с",T:"Т",y:"у",X:"Х",x:"х"}),xe=Object.keys(be).join("");return E.addRules([{name:"ru/typo/switchingKeyboardLayout",handler:function(e){var t=new RegExp("(["+xe+"]{1,3})(?=[А-ЯЁа-яё]+?)","g");return e.replace(t,function(e,t){for(var n="",r=0;r<t.length;r++)n+=be[t[r]];return n})}}]),E});
|