marked-typograf
Version:
marked extension for typograf
15 lines (14 loc) • 55.2 kB
JavaScript
var q=Object.defineProperty;var me=Object.getOwnPropertyDescriptor;var Re=Object.getOwnPropertyNames;var $e=Object.prototype.hasOwnProperty;var be=(r,e)=>{for(var a in e)q(r,a,{get:e[a],enumerable:!0})},ye=(r,e,a,t)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of Re(e))!$e.call(r,n)&&n!==a&&q(r,n,{get:()=>e[n],enumerable:!(t=me(e,n))||t.enumerable});return r};var Ee=r=>ye(q({},"__esModule",{value:!0}),r);var Mt={};be(Mt,{markedTypograf:()=>zt});module.exports=Ee(Mt);var k=function(){return k=Object.assign||function(e){for(var a,t=1,n=arguments.length;t<n;t++){a=arguments[t];for(var u in a)Object.prototype.hasOwnProperty.call(a,u)&&(e[u]=a[u])}return e},k.apply(this,arguments)};function y(r,e,a){if(a||arguments.length===2)for(var t=0,n=e.length,u;t<n;t++)(u||!(t in e))&&(u||(u=Array.prototype.slice.call(e,0,t)),u[t]=e[t]);return r.concat(u||Array.prototype.slice.call(e))}var Ae=[["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]],M=[["nbsp",160],["thinsp",8201],["ensp",8194],["emsp",8195],["shy",173],["zwnj",8204],["zwj",8205],["lrm",8206],["rlm",8207]],we=function(){function r(){var e=this;this.entities=this.prepareEntities(y(y([],Ae,!0),M,!0)),this.entitiesByName={},this.entitiesByNameEntity={},this.entitiesByDigitEntity={},this.entitiesByUtf={},this.entities.forEach(function(a){e.entitiesByName[a.name]=a,e.entitiesByNameEntity[a.nameEntity]=a,e.entitiesByDigitEntity[a.digitEntity]=a,e.entitiesByUtf[a.utf]=a}),this.invisibleEntities=this.prepareEntities(M)}return r.prototype.toUtf=function(e){var a=this;e.text.search(/&#/)!==-1&&(e.text=this.decHexToUtf(e.text)),e.text.search(/&[a-z]/i)!==-1&&(e.text=e.text.replace(/&[a-z\d]{2,31};/gi,function(t){var n=a.entitiesByNameEntity[t];return n?n.utf:t}))},r.prototype.decHexToUtf=function(e){return e.replace(/&#(\d{1,6});/gi,function(a,t){return String.fromCharCode(parseInt(t,10))}).replace(/&#x([\da-f]{1,6});/gi,function(a,t){return String.fromCharCode(parseInt(t,16))})},r.prototype.restore=function(e){var a=e.prefs.htmlEntity,t=a.type,n=this.entities;if(t==="name"||t==="digit"){(a.onlyInvisible||a.list)&&(n=[],a.onlyInvisible&&(n=n.concat(this.invisibleEntities)),a.list&&(n=n.concat(this.prepareListParam(a.list))));var u=t==="name"?"nameEntity":"digitEntity";e.text=this.restoreEntitiesByIndex(e.text,u,n)}},r.prototype.getByUtf=function(e,a){var t;switch(a){case"digit":t=this.entitiesByDigitEntity[e];break;case"name":t=this.entitiesByNameEntity[e];break;default:t=e;break}return t},r.prototype.prepareEntities=function(e){var a=[];return e.forEach(function(t){var n=t[0],u=t[1],i=String.fromCharCode(u);a.push({name:n,nameEntity:"&"+n+";",digitEntity:"&#"+u+";",utf:i,reName:new RegExp("&"+n+";","g"),reUtf:new RegExp(i,"g")})}),a},r.prototype.prepareListParam=function(e){var a=this,t=[];return e.forEach(function(n){var u=a.entitiesByName[n];u&&t.push(u)}),t},r.prototype.restoreEntitiesByIndex=function(e,a,t){return t.forEach(function(n){e=e.replace(n.reUtf,n[a])}),e},r}(),m=new we,E=[];function L(r){var e=(r||"").split("/")[0];e&&e!=="common"&&!S(e)&&(E.push(e),E.sort())}function J(){return E}function S(r){return r==="common"||E.indexOf(r)!==-1}function ee(r,e){var a=r||e;return a?Array.isArray(a)?a:[a]:[]}function _(r){if(!r.length)throw Error('Not defined the property "locale".');r.forEach(function(e){if(!S(e))throw Error('"'.concat(e,'" is not supported locale.'))})}var re={};function o(r){return re[r]}function ae(r){Object.keys(r).forEach(function(e){L(e),re[e]=r[e]})}var qe=["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"],te=new RegExp("(https?|file|ftp)://([a-zA-Z0-9/+-=%&:_.~?]+[a-zA-Z0-9#+]*)","g"),N="\\d+([.,]\\d+)?",xe=/\d/;function P(r){return r.search(xe)>-1}var c="\uF000",b="\uF001",ke=function(){function r(){this.groups=["own","html","url"],this.hidden={},this.counter=0;var e=[["<!--","-->"],["<!ENTITY",">"],["<!DOCTYPE",">"],["<\\?xml","\\?>"],["<!\\[CDATA\\[","\\]\\]>"]];["code","kbd","object","pre","samp","script","style","var"].forEach(function(a){e.push(["<".concat(a,"(\\s[^>]*?)?>"),"</".concat(a,">")])}),this.tags={own:[],html:e.map(this.prepareRegExp),url:[te]}}return r.prototype.add=function(e){this.tags.own.push(this.prepareRegExp(e))},r.prototype.show=function(e,a){for(var t=new RegExp(c+"tf\\d+"+c,"g"),n=new RegExp(c+"tf\\d"),u=function(l){return e.safeTags.hidden[a][l]||l},i=0,s=this.tags[a].length;i<s&&(e.text=e.text.replace(t,u),e.text.search(n)!==-1);i++);},r.prototype.hide=function(e,a){var t=this;e.safeTags.hidden[a]={};var n=this.pasteLabel.bind(this,e,a);this.tags[a].forEach(function(u){e.text=e.text.replace(t.prepareRegExp(u),n)})},r.prototype.hideHTMLTags=function(e){if(e.isHTML){var a=this.pasteLabel.bind(this,e,"html");e.text=e.text.replace(/<\/?[a-z][^]*?>/gi,a).replace(/<\/?[a-z][^]*?>/gi,a).replace(/&[gl]t;/gi,a)}},r.prototype.getPrevLabel=function(e,a){for(var t=a-1;t>=0;t--)if(e[t]===c)return e.slice(t,a+1);return""},r.prototype.getNextLabel=function(e,a){for(var t=a+1;t<e.length;t++)if(e[t]===c)return e.slice(a,t+1);return""},r.prototype.getTagByLabel=function(e,a){var t=null;return this.groups.some(function(n){var u=e.safeTags.hidden[n][a];return typeof u<"u"&&(t={group:n,value:u}),t}),t},r.prototype.getTagInfo=function(e){if(!e)return null;var a={group:e.group};switch(e.group){case"html":a.name=e.value.split(/[<\s>]/)[1],a.isInline=qe.indexOf(a.name)>-1,a.isClosing=e.value.search(/^<\//)>-1;break;case"url":a.isInline=!0;break;case"own":a.isInline=!1;break}return a},r.prototype.pasteLabel=function(e,a,t){var n=e.safeTags,u=c+"tf"+n.counter+c;return n.hidden[a][u]=t,n.counter++,u},r.prototype.prepareRegExp=function(e){if(e instanceof RegExp)return e;var a=e[0],t=e[1],n=e[2];return new RegExp(a+(typeof n>"u"?"[^]*?":n)+t,"gi")},r.prototype.getPrevTagInfo=function(e,a,t){var n=this.getPrevLabel(a,t-1);if(n){var u=this.getTagByLabel(e,n);if(u)return this.getTagInfo(u)}return null},r.prototype.getNextTagInfo=function(e,a,t){var n=this.getNextLabel(a,t+1);if(n){var u=this.getTagByLabel(e,n);if(u)return this.getTagInfo(u)}return null},r}();function T(r,e){for(var a="";(e&1)===1&&(a+=r),e>>>=1,e!==0;)r+=r;return a}function ne(r){return r.replace(/\u00A0/g," ")}function D(r,e){for(var a=0;a<e.length;a++)r=r.replace(e[a][0],e[a][1]);return r}function O(r){return r.search(/(<\/?[a-z]|<!|&[lg]t;)/i)!==-1}function Te(r){return r.replace(/\r\n?/g,`
`)}function Be(r,e){return e==="CRLF"?r.replace(/\n/g,`\r
`):e==="CR"?r.replace(/\n/g,"\r"):r}function A(r){return typeof r=="object"?JSON.parse(JSON.stringify(r)):r}var Le={symbols:110,number:150,space:210,dash:310,punctuation:410,nbsp:510,money:710,date:810,other:910,optalign:1010,typo:1110,html:1210},Se=0,ue="default",ie=[],se=[];function De(r){se.push(le(r))}function Ce(r){var e=le(r);L(e.locale),ie.push(e)}function Ie(r){r.sort(function(e,a){return e.index>a.index?1:-1})}function x(){var r=y([],ie,!0);return Ie(r),r}function U(){return y([],se,!0)}function Fe(r){if(typeof r.index=="number")return r.index;var e=r.name.split("/"),a=e[1],t=Le[a];return typeof t>"u"&&(t=Se),typeof r.index=="string"?t+parseInt(r.index,10):t}function le(r){var e=r.name.split("/"),a=e[0],t=e[1],n=e[2],u={name:r.name,shortName:n,handler:r.handler,queue:r.queue||ue,enabled:r.disabled!==!0,locale:a,group:t,index:Fe(r),settings:r.settings,live:r.live,htmlAttrs:r.htmlAttrs};return u}var ze="7.4.2";function oe(r){var e={type:r?.type||"default",list:r?.list,onlyInvisible:!!r?.onlyInvisible};return e}function ce(r){return r||"LF"}function Me(r){var e={locale:ee(r.locale),lineEnding:ce(r.lineEnding),live:!!r.live,ruleFilter:r.ruleFilter,enableRule:r.enableRule,disableRule:r.disableRule,processingSeparateParts:r.processingSeparateParts,htmlEntity:oe(r.htmlEntity)};return e}function _e(r,e){var a=k({},r);return e&&("locale"in e&&(a.locale=ee(e.locale)),"htmlEntity"in e&&(a.htmlEntity=oe(e.htmlEntity)),"lineEnding"in e&&(a.lineEnding=ce(e.lineEnding)),"processingSeparateParts"in e&&(a.processingSeparateParts=e.processingSeparateParts),"ruleFilter"in e&&(a.ruleFilter=e.ruleFilter)),a}var p=function(){function r(e){var a=this;this.rules=[],this.innerRules=[],this.rulesByQueues={},this.innerRulesByQueues={},this.separatePartsTags=["title","p","h[1-6]","select","legend"],this.prefs=Me(e),_(this.prefs.locale),this.safeTags=new ke,this.settings={},this.enabledRules={},this.innerRulesByQueues={},this.innerRules=U(),this.innerRules.forEach(function(t){a.innerRulesByQueues[t.queue]=a.innerRulesByQueues[t.queue]||[],a.innerRulesByQueues[t.queue].push(t)}),this.rulesByQueues={},this.rules=x(),this.rules.forEach(function(t){a.prepareRuleSettings(t),a.rulesByQueues[t.queue]=a.rulesByQueues[t.queue]||[],a.rulesByQueues[t.queue].push(t)}),this.prefs.disableRule&&this.disableRule(this.prefs.disableRule),this.prefs.enableRule&&this.enableRule(this.prefs.enableRule)}return r.addRule=function(e){Ce(e)},r.addRules=function(e){var a=this;e.forEach(function(t){a.addRule(t)})},r.addInnerRule=function(e){De(e)},r.addInnerRules=function(e){var a=this;e.forEach(function(t){a.addInnerRule(t)})},r.getRule=function(e){var a=null,t=x();return t.some(function(n){return n.name===e?(a=n,!0):!1}),a},r.getRules=function(){return x()},r.getInnerRules=function(){return U()},r.getLocales=function(){return J()},r.addLocale=function(e){L(e)},r.hasLocale=function(e){return S(e)},r.setData=function(e){ae(e)},r.getData=function(e){return o(e)},r.prototype.execute=function(e,a){if(e=""+e,!e)return"";var t=_e(this.prefs,a);_(t.locale);var n=this.prepareContext(e,t);return this.process(n)},r.prototype.getSetting=function(e,a){return this.settings[e]&&this.settings[e][a]},r.prototype.setSetting=function(e,a,t){this.settings[e]=this.settings[e]||{},this.settings[e][a]=t},r.prototype.isEnabledRule=function(e){return this.enabledRules[e]!==!1},r.prototype.isDisabledRule=function(e){return!this.enabledRules[e]},r.prototype.enableRule=function(e){return this.enable(e,!0)},r.prototype.disableRule=function(e){return this.enable(e,!1)},r.prototype.addSafeTag=function(e,a,t){var n=e instanceof RegExp?e:[e,a,t];this.safeTags.add(n)},r.prototype.prepareContext=function(e,a){var t={text:e,isHTML:O(e),prefs:a,getData:function(n){return n==="char"?a.locale.map(function(u){return o(u+"/"+n)}).join(""):o(a.locale[0]+"/"+n)},safeTags:this.safeTags};return t},r.prototype.splitBySeparateParts=function(e){if(!e.isHTML||e.prefs.processingSeparateParts===!1)return[e.text];var a=[],t=new RegExp("<("+this.separatePartsTags.join("|")+")(\\s[^>]*?)?>[^]*?</\\1>","gi"),n=0;return e.text.replace(t,function(u,i,s,l){return n!==l&&a.push((n?b:"")+e.text.slice(n,l)+b),a.push(u),n=l+u.length,u}),a.push(n?b+e.text.slice(n,e.text.length):e.text),a},r.prototype.process=function(e){var a=this;e.text=Te(e.text),this.executeRules(e,"start"),this.safeTags.hide(e,"own"),this.executeRules(e,"hide-safe-tags-own"),this.safeTags.hide(e,"html"),this.executeRules(e,"hide-safe-tags-html");var t=e.isHTML,n=new RegExp(b,"g");return e.text=this.splitBySeparateParts(e).map(function(u){return e.text=u,e.isHTML=O(u),a.safeTags.hideHTMLTags(e),a.safeTags.hide(e,"url"),a.executeRules(e,"hide-safe-tags-url"),a.executeRules(e,"hide-safe-tags"),m.toUtf(e),e.prefs.live&&(e.text=ne(e.text)),a.executeRules(e,"utf"),a.executeRules(e),m.restore(e),a.executeRules(e,"html-entities"),a.safeTags.show(e,"url"),a.executeRules(e,"show-safe-tags-url"),e.text.replace(n,"")}).join(""),e.isHTML=t,this.safeTags.show(e,"html"),this.executeRules(e,"show-safe-tags-html"),this.safeTags.show(e,"own"),this.executeRules(e,"show-safe-tags-own"),this.executeRules(e,"end"),Be(e.text,e.prefs.lineEnding)},r.prototype.executeRules=function(e,a){var t=this;a===void 0&&(a=ue);var n=this.rulesByQueues[a],u=this.innerRulesByQueues[a];u&&u.forEach(function(i){t.ruleIterator(e,i)}),n&&n.forEach(function(i){t.ruleIterator(e,i)})},r.prototype.ruleIterator=function(e,a){if(!(e.prefs.live===!0&&a.live===!1||e.prefs.live===!1&&a.live===!0)&&(a.locale==="common"||a.locale===e.prefs.locale[0])&&this.isEnabledRule(a.name)){if(e.prefs.ruleFilter&&!e.prefs.ruleFilter(a))return;this.onBeforeRule&&this.onBeforeRule(a.name,e),e.text=a.handler.call(this,e.text,this.settings[a.name],e),this.onAfterRule&&this.onAfterRule(a.name,e)}},r.prototype.prepareRuleSettings=function(e){this.settings[e.name]=A(e.settings),this.enabledRules[e.name]=e.enabled},r.prototype.enable=function(e,a){var t=this;Array.isArray(e)?e.forEach(function(n){t.enableByMask(n,a)}):this.enableByMask(e,a)},r.prototype.enableByMask=function(e,a){var t=this;if(e)if(e.search(/\*/)!==-1){var n=new RegExp(e.replace(/\//g,"\\/").replace(/\*/g,".*"));this.rules.forEach(function(u){var i=u.name;n.test(i)&&(t.enabledRules[i]=a)})}else this.enabledRules[e]=a},r.groups=[],r.titles={},r.version=ze,r}(),Ne={"common/char":"a-z","common/dash":"--?|\u2012|\u2013|\u2014","common/quote":'\xAB\u2039\xBB\u203A\u201E\u201C\u201F\u201D"'},Pe={"be/char":"\u0430\u0431\u0432\u0433\u0434\u0435\u0436\u0437\u0439\u043A\u043B\u043C\u043D\u043E\u043F\u0440\u0441\u0442\u0443\u0444\u0445\u0446\u0447\u0448\u044B\u044C\u044D\u044E\u044F\u0451\u0456\u045E\u0491","be/quote":{left:"\xAB\u201C",right:"\xBB\u201D"}},Oe={"bg/char":"\u0430\u0431\u0432\u0433\u0434\u0435\u0436\u0437\u0438\u0439\u043A\u043B\u043C\u043D\u043E\u043F\u0440\u0441\u0442\u0443\u0444\u0445\u0446\u0447\u0448\u0449\u044A\u044C\u044E\u044F","bg/quote":{left:"\u201E\u2019",right:"\u201C\u2019"}},Ue={"ca/char":"abcdefghijlmnopqrstuvxyz\xE0\xE7\xE8\xE9\xED\xEF\xF2\xF3\xFA\xFC","ca/quote":{left:"\xAB\u201C",right:"\xBB\u201D"}},Qe={"cs/char":"a-z\xE1\xE9\xED\xF3\xFA\xFD\u010D\u010F\u011B\u0148\u0159\u0161\u0165\u016F\u017E","cs/quote":{left:"\u201E\u201A",right:"\u201C\u2018"}},je={"da/char":"a-z\xE5\xE6\xF8","da/quote":{left:"\xBB\u203A",right:"\xAB\u2039"}},He={"de/char":"a-z\xDF\xE4\xF6\xFC","de/quote":{left:"\u201E\u201A",right:"\u201C\u2018"}},We={"el/char":"\u0390\u03AC\u03AD\u03AE\u03AF\u03B0\u03B1\u03B2\u03B3\u03B4\u03B5\u03B6\u03B7\u03B8\u03B9\u03BA\u03BB\u03BC\u03BD\u03BE\u03BF\u03C0\u03C1\u03C2\u03C3\u03C4\u03C5\u03C6\u03C7\u03C8\u03C9\u03CA\u03CB\u03CC\u03CD\u03CE\u03F2\u1F71\u1F73\u1F75\u1F77\u1F79\u1F7B\u1F7D","el/quote":{left:"\xAB\u201C",right:"\xBB\u201D"}},Ge={"en-GB/char":"a-z","en-GB/quote":{left:"\u2018\u201C",right:"\u2019\u201D"}},Xe={"en-US/char":"a-z","en-US/quote":{left:"\u201C\u2018",right:"\u201D\u2019"},"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"},Ke={"eo/char":"abcdefghijklmnoprstuvz\u0109\u011D\u0125\u0135\u015D\u016D","eo/quote":{left:"\u201C\u2018",right:"\u201D\u2019"}},Ve={"es/char":"a-z\xE1\xE9\xED\xF1\xF3\xFA\xFC","es/quote":{left:"\xAB\u201C",right:"\xBB\u201D"}},Ye={"et/char":"abdefghijklmnoprstuvz\xE4\xF5\xF6\xFC\u0161\u017E","et/quote":{left:"\u201E\xAB",right:"\u201C\xBB"}},Ze={"fi/char":"abcdefghijklmnopqrstuvy\xF6\xE4\xE5","fi/quote":{left:"\u201D\u2019",right:"\u201D\u2019"}},Je={"fr/char":"a-z\xE0\xE2\xE7\xE8\xE9\xEA\xEB\xEE\xEF\xF4\xFB\xFC\u0153\xE6","fr/quote":{left:"\xAB\u2039",right:"\xBB\u203A",spacing:!0}},er={"ga/char":"abcdefghilmnoprstuvwxyz\xE1\xE9\xED\xF3\xFA","ga/quote":{left:"\u201C\u2018",right:"\u201D\u2019"}},rr={"hu/char":"a-z\xE1\xE4\xE9\xED\xF3\xF6\xFA\xFC\u0151\u0171","hu/quote":{left:"\u201E\xBB",right:"\u201D\xAB"}},ar={"it/char":"a-z\xE0\xE9\xE8\xEC\xF2\xF9","it/quote":{left:"\xAB\u201C",right:"\xBB\u201D"}},tr={"lv/char":"abcdefghijklmnopqrstuvxz\xE6\u0153","lv/quote":{left:"\xAB\u201E",right:"\xBB\u201C"}},nr={"nl/char":"a-z\xE4\xE7\xE8\xE9\xEA\xEB\xEE\xEF\xF1\xF6\xFB\xFC","nl/quote":{left:"\u2018\u201C",right:"\u2019\u201D"}},ur={"no/char":"a-z\xE5\xE6\xE8\xE9\xEA\xF2\xF3\xF4\xF8","no/quote":{left:"\xAB\u2019",right:"\xBB\u2019"}},ir={"pl/char":"abcdefghijklmnoprstuvwxyz\xF3\u0105\u0107\u0119\u0142\u0144\u015B\u017A\u017C","pl/quote":{left:"\u201E\xAB",right:"\u201D\xBB"}},sr={"ro/char":"abcdefghijklmnoprstuvxz\xEE\u0103\u0219\u021B","ro/quote":{left:"\u201E\xAB",right:"\u201D\xBB"}},lr={"ru/char":"\u0430-\u044F\u0451","ru/dashBefore":"(^| |\\n)","ru/dashAfter":"(?=[\xA0 ,.?:!]|$)","ru/dashAfterDe":"(?=[,.?:!]|[\xA0 ][^\u0410-\u042F\u0401]|$)","ru/l":"\u0430-\u044F\u0451a-z","ru/L":"\u0410-\u042F\u0401A-Z","ru/month":"\u044F\u043D\u0432\u0430\u0440\u044C|\u0444\u0435\u0432\u0440\u0430\u043B\u044C|\u043C\u0430\u0440\u0442|\u0430\u043F\u0440\u0435\u043B\u044C|\u043C\u0430\u0439|\u0438\u044E\u043D\u044C|\u0438\u044E\u043B\u044C|\u0430\u0432\u0433\u0443\u0441\u0442|\u0441\u0435\u043D\u0442\u044F\u0431\u0440\u044C|\u043E\u043A\u0442\u044F\u0431\u0440\u044C|\u043D\u043E\u044F\u0431\u0440\u044C|\u0434\u0435\u043A\u0430\u0431\u0440\u044C","ru/monthGenCase":"\u044F\u043D\u0432\u0430\u0440\u044F|\u0444\u0435\u0432\u0440\u0430\u043B\u044F|\u043C\u0430\u0440\u0442\u0430|\u0430\u043F\u0440\u0435\u043B\u044F|\u043C\u0430\u044F|\u0438\u044E\u043D\u044F|\u0438\u044E\u043B\u044F|\u0430\u0432\u0433\u0443\u0441\u0442\u0430|\u0441\u0435\u043D\u0442\u044F\u0431\u0440\u044F|\u043E\u043A\u0442\u044F\u0431\u0440\u044F|\u043D\u043E\u044F\u0431\u0440\u044F|\u0434\u0435\u043A\u0430\u0431\u0440\u044F","ru/monthPreCase":"\u044F\u043D\u0432\u0430\u0440\u0435|\u0444\u0435\u0432\u0440\u0430\u043B\u0435|\u043C\u0430\u0440\u0442\u0435|\u0430\u043F\u0440\u0435\u043B\u0435|\u043C\u0430\u0435|\u0438\u044E\u043D\u0435|\u0438\u044E\u043B\u0435|\u0430\u0432\u0433\u0443\u0441\u0442\u0435|\u0441\u0435\u043D\u0442\u044F\u0431\u0440\u0435|\u043E\u043A\u0442\u044F\u0431\u0440\u0435|\u043D\u043E\u044F\u0431\u0440\u0435|\u0434\u0435\u043A\u0430\u0431\u0440\u0435","ru/quote":{left:"\xAB\u201E\u201A",right:"\xBB\u201C\u2018",removeDuplicateQuotes:!0},"ru/shortMonth":"\u044F\u043D\u0432|\u0444\u0435\u0432|\u043C\u0430\u0440|\u0430\u043F\u0440|\u043C\u0430[\u0435\u0439\u044F]|\u0438\u044E\u043D|\u0438\u044E\u043B|\u0430\u0432\u0433|\u0441\u0435\u043D|\u043E\u043A\u0442|\u043D\u043E\u044F|\u0434\u0435\u043A","ru/shortWord":"\u0430|\u0431\u044B|\u0432|\u0432\u043E|\u0434\u0430|\u0434\u043E|\u0436\u0435|\u0437\u0430|\u0438|\u0438\u0437|\u043A|\u043A\u043E|\u043B\u0438|\u043D\u0430|\u043D\u0435|\u043D\u0438|\u043D\u043E|\u043E|\u043E\u0431|\u043E\u0442|\u043F\u043E|\u0441|\u0441\u043E|\u0442\u043E|\u0443","ru/weekday":"\u043F\u043E\u043D\u0435\u0434\u0435\u043B\u044C\u043D\u0438\u043A|\u0432\u0442\u043E\u0440\u043D\u0438\u043A|\u0441\u0440\u0435\u0434\u0430|\u0447\u0435\u0442\u0432\u0435\u0440\u0433|\u043F\u044F\u0442\u043D\u0438\u0446\u0430|\u0441\u0443\u0431\u0431\u043E\u0442\u0430|\u0432\u043E\u0441\u043A\u0440\u0435\u0441\u0435\u043D\u044C\u0435"},or={"sk/char":"abcdefghijklmnoprstuvwxyz\xE1\xE4\xE9\xED\xF3\xF4\xFA\xFD\u010D\u010F\u013E\u0148\u0155\u0161\u0165\u017E","sk/quote":{left:"\u201E\u201A",right:"\u201C\u2018"}},cr={"sl/char":"a-z\u010D\u0161\u017E","sl/quote":{left:"\u201E\u201A",right:"\u201C\u2018"}},pr={"sr/char":"abcdefghijklmnoprstuvz\u0107\u010D\u0111\u0161\u017E","sr/quote":{left:"\u201E\u2019",right:"\u201D\u2019"}},fr={"sv/char":"a-z\xE4\xE5\xE9\xF6","sv/quote":{left:"\u201D\u2019",right:"\u201D\u2019"}},hr={"tr/char":"abcdefghijklmnoprstuvyz\xE2\xE7\xEE\xF6\xFB\xFC\u011F\u0131\u015F","tr/quote":{left:"\u201C\u2018",right:"\u201D\u2019"}},gr={"uk/char":"\u0430\u0431\u0432\u0433\u0434\u0435\u0436\u0437\u0438\u0439\u043A\u043B\u043C\u043D\u043E\u043F\u0440\u0441\u0442\u0443\u0444\u0445\u0446\u0447\u0448\u0449\u044C\u044E\u044F\u0454\u0456\u0457\u0491","uk/quote":{left:"\xAB\u201E",right:"\xBB\u201C"}},dr=[Ne,Pe,Oe,Ue,Qe,je,He,We,Ge,Xe,Ke,Ve,Ye,Ze,Je,er,rr,ar,tr,nr,ur,ir,sr,lr,or,cr,pr,fr,hr,gr];dr.forEach(function(r){return ae(r)});var vr={name:"common/html/e-mail",queue:"end",handler:function(r,e,a){return a.isHTML?r:r.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},mr={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"},Rr={name:"common/html/escape",index:"+100",queue:"end",handler:function(r){return r.replace(/[&<>"'/]/g,function(e){return mr[e]})},disabled:!0},$r={name:"common/html/nbr",index:"+10",queue:"end",handler:function(r){return r.replace(/([^\n>])\n(?=[^\n])/g,`$1<br/>
`)},disabled:!0,htmlAttrs:!1},br=["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"],yr=new RegExp("<("+br.join("|")+")[>\\s]"),Q=`
`,Er={name:"common/html/p",index:"+5",queue:"end",handler:function(r){var e=r.split(Q);return e.forEach(function(a,t,n){a.trim()&&(yr.test(a)||(n[t]=a.replace(/^(\s*)/,"$1<p>").replace(/(\s*)$/,"</p>$1")))}),e.join(Q)},disabled:!0,htmlAttrs:!1},Ar={name:"common/html/processingAttrs",queue:"hide-safe-tags-own",handler:function(r,e,a){var t=this,n=new RegExp("(^|\\s)("+e.attrs.join("|")+`)=("[^"]*?"|'[^']*?')`,"gi"),u=A(a.prefs);return u.ruleFilter=function(i){return i.htmlAttrs!==!1},r.replace(/(<[-\w]+\s)([^>]+?)(?=>)/g,function(i,s,l){var g=l.replace(n,function(f,h,v,d){var $=d[0],R=d[d.length-1],ve=d.slice(1,-1);return h+v+"="+$+t.execute(ve,u)+R});return s+g})},settings:{attrs:["title","placeholder"]},disabled:!0,htmlAttrs:!1},wr={name:"common/html/quot",queue:"hide-safe-tags",handler:function(r){return r.replace(/"/g,'"')}},qr={name:"common/html/stripTags",index:"+99",queue:"end",handler:function(r){return r.replace(/<[^>]+>/g,"")},disabled:!0},xr={name:"common/html/url",queue:"end",handler:function(r,e,a){return a.isHTML?r:r.replace(te,function(t,n,u){u=u.replace(/([^/]+\/?)(\?|#)$/,"$1").replace(/^([^/]+)\/$/,"$1"),n==="http"?u=u.replace(/^([^/]+)(:80)([^\d]|\/|$)/,"$1$3"):n==="https"&&(u=u.replace(/^([^/]+)(:443)([^\d]|\/|$)/,"$1$3"));var i=u,s=n+"://"+u,l='<a href="'+s+'">';return n==="http"||n==="https"?(i=i.replace(/^www\./,""),l+(n==="http"?i:n+"://"+i)+"</a>"):l+s+"</a>"})},disabled:!0,htmlAttrs:!1};p.addRules([vr,Rr,$r,Er,Ar,wr,qr,xr]);var kr={name:"common/nbsp/afterNumber",handler:function(r,e,a){var t=a.getData("char"),n="(^|\\s)(\\d{1,5}) (["+t+"]+)";return r.replace(new RegExp(n,"gi"),"$1$2\xA0$3")},disabled:!0},Tr={name:"common/nbsp/afterParagraphMark",handler:function(r){return r.replace(/¶ ?(?=\d)/g,"\xB6\xA0")}},Br={name:"common/nbsp/afterSectionMark",handler:function(r,e,a){var t=a.prefs.locale[0];return r.replace(/§[ \u00A0\u2009]?(?=\d|I|V|X)/g,t==="ru"?"\xA7\u202F":"\xA7\xA0")}},Lr={name:"common/nbsp/afterShortWord",handler:function(r,e,a){var t=e.lengthShortWord,n=e.useShortWordList,u=o("common/quote"),i=a.getData("char"),s=a.getData("shortWord"),l=" \xA0("+c+u,g=n&&s!==void 0?"(^|["+l+"])("+s+") ":"(^|["+l+"])(["+i+"]{1,"+t+"}) ",f="$1$2\xA0",h=new RegExp(g,"gim");return r.replace(h,f).replace(h,f)},settings:{lengthShortWord:2,useShortWordList:!1}},Sr={name:"common/nbsp/beforeShortLastNumber",handler:function(r,e,a){var t=a.getData("quote"),n=a.getData("char"),u=n.toUpperCase(),i=new RegExp("(["+n+u+"]) (?=\\d{1,"+e.lengthLastNumber+`}[-+\u2212%'"`+t.right+")]?([.!?\u2026]( ["+u+"]|$)|$))","gm");return r.replace(i,"$1\xA0")},live:!1,settings:{lengthLastNumber:2}},Dr={name:"common/nbsp/beforeShortLastWord",handler:function(r,e,a){var t=a.getData("char"),n=t.toUpperCase(),u=new RegExp("(["+t+"\\d]) (["+t+n+"]{1,"+e.lengthLastWord+"}[.!?\u2026])( ["+n+"]|$)","g");return r.replace(u,"$1\xA0$2$3")},settings:{lengthLastWord:3}},Cr={name:"common/nbsp/dpi",handler:function(r){return r.replace(/(\d) ?(lpi|dpi)(?!\w)/,"$1\xA0$2")}};function j(r,e,a,t){return e+a.replace(/([^\u00A0])\u00A0([^\u00A0])/g,"$1 $2")+t}var Ir={name:"common/nbsp/nowrap",queue:"end",handler:function(r){return r.replace(/(<nowrap>)(.*?)(<\/nowrap>)/g,j).replace(/(<nobr>)(.*?)(<\/nobr>)/g,j)}},Fr={name:"common/nbsp/replaceNbsp",queue:"utf",live:!1,handler:ne,disabled:!0};p.addRules([kr,Tr,Br,Lr,Sr,Dr,Cr,Ir,Fr]);var zr={name:"common/number/digitGrouping",index:"310",disabled:!0,handler:function(r,e){return r.replace(new RegExp("(^ ?|\\D |".concat(c,")(\\d{1,3}([ \xA0\u202F\u2009]\\d{3})+)(?! ?[\\d-])"),"gm"),function(a,t,n){return t+n.replace(/\s/g,e.space)}).replace(/(\d{5,}([.,]\d+)?)/g,function(a,t){var n=t.match(/[.,]/),u=n?t.split(n):[t],i=u[0],s=u[1];return i=i.replace(/(\d)(?=(\d{3})+([^\d]|$))/g,"$1"+e.space),n?i+n+s:i})},settings:{space:"\u202F"}},Mr={name:"common/number/fraction",handler:function(r){return r.replace(/(^|\D)1\/2(\D|$)/g,"$1\xBD$2").replace(/(^|\D)1\/4(\D|$)/g,"$1\xBC$2").replace(/(^|\D)3\/4(\D|$)/g,"$1\xBE$2")}},_r={name:"common/number/mathSigns",handler:function(r){return D(r,[[/!=/g,"\u2260"],[/<=/g,"\u2264"],[/(^|[^=])>=/g,"$1\u2265"],[/<=>/g,"\u21D4"],[/<</g,"\u226A"],[/>>/g,"\u226B"],[/~=/g,"\u2245"],[/(^|[^+])\+-/g,"$1\xB1"]])}},Nr={name:"common/number/times",handler:function(r){return r.replace(/(\d)[ \u00A0]?[xх][ \u00A0]?(\d)/g,"$1\xD7$2")}};p.addRules([zr,Mr,_r,Nr]);var Pr={name:"common/other/delBOM",queue:"start",index:-1,handler:function(r){return r.charCodeAt(0)===65279?r.slice(1):r}},Or={name:"common/other/repeatWord",handler:function(r,e,a){var t=o("common/quote"),n=a.getData("char"),u=`[;:,.?!
`+t+"]",i=new RegExp("("+u+"|^)(["+n+"]{"+e.min+",}) \\2("+u+"|$)","gi");return r.replace(i,"$1$2$3")},settings:{min:2},disabled:!0};p.addRules([Pr,Or]);var Ur={name:"common/punctuation/apostrophe",handler:function(r,e,a){var t=a.getData("char"),n="(["+t+"])",u=new RegExp(n+"'"+n,"gi");return r.replace(u,"$1\u2019$2")}},Qr={name:"common/punctuation/delDoublePunctuation",handler:function(r){return r.replace(/(^|[^,]),,(?!,)/g,"$1,").replace(/(^|[^:])::(?!:)/g,"$1:").replace(/(^|[^!?.])\.\.(?!\.)/g,"$1.").replace(/(^|[^;]);;(?!;)/g,"$1;").replace(/(^|[^?])\?\?(?!\?)/g,"$1?")}},jr={name:"common/punctuation/hellip",handler:function(r,e,a){return a.prefs.locale[0]==="ru"?r.replace(/(^|[^.])\.{3,4}(?=[^.]|$)/g,"$1\u2026"):r.replace(/(^|[^.])\.{3}(\.?)(?=[^.]|$)/g,"$1\u2026$2")}},Hr=2,Wr=function(){function r(){this.bufferQuotes={left:"\uF005\uF006\uF007",right:"\uF008\uF009\uF0A0"},this.beforeLeft=`
\xA0[(`,this.afterRight=`
\xA0!?.:;#*,\u2026)\\]`}return r.prototype.process=function(e){var a=e.context.text,t=this.count(a);if(!t.total)return a;var n=e.settings,u=e.settings.left[0]===e.settings.right[0];return u&&(e.settings=A(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&&(a=this.removeSpacing(a,e.settings)),a=this.set(a,e),e.settings.spacing&&(a=this.setSpacing(a,e.settings)),e.settings.removeDuplicateQuotes&&(a=this.removeDuplicates(a,e.settings)),u&&(a=this.returnOriginalQuotes(a,n,e.settings),e.settings=n),a},r.prototype.returnOriginalQuotes=function(e,a,t){for(var n={},u=0;u<t.left.length;u++)n[t.left[u]]=a.left[u],n[t.right[u]]=a.right[u];return e.replace(new RegExp("["+t.left+t.right+"]","g"),function(i){return n[i]})},r.prototype.count=function(e){var a={total:0};return e.replace(new RegExp("["+o("common/quote")+"]","g"),function(t){return a[t]||(a[t]=0),a[t]++,a.total++,t}),a},r.prototype.removeDuplicates=function(e,a){var t=a.left[0],n=a.left[1]||t,u=a.right[0];return t!==n?e:e.replace(new RegExp(t+t,"g"),t).replace(new RegExp(u+u,"g"),u)},r.prototype.removeSpacing=function(e,a){for(var t=0,n=a.left.length;t<n;t++){var u=a.left[t],i=a.right[t];e=e.replace(new RegExp(u+"([ \u202F\xA0])","g"),u).replace(new RegExp("([ \u202F\xA0])"+i,"g"),i)}return e},r.prototype.setSpacing=function(e,a){for(var t=0,n=a.left.length;t<n;t++){var u=a.left[t],i=a.right[t];e=e.replace(new RegExp(u+"([^\u202F])","g"),u+"\u202F$1").replace(new RegExp("([^\u202F])"+i,"g"),"$1\u202F"+i)}return e},r.prototype.set=function(e,a){var t=o("common/quote"),n=a.settings.left[0],u=a.settings.left[1]||n,i=a.settings.right[0],s=new RegExp("(^|["+this.beforeLeft+"])(["+t+"]+)(?=[^\\s"+c+"])","gim"),l=new RegExp("([^\\s"+c+"])(["+t+"]+)(?=["+this.afterRight+"]|$)","gim");return e=e.replace(s,function(g,f,h){return f+T(n,h.length)}).replace(l,function(g,f,h){return f+T(i,h.length)}),e=this.setAboveTags(e,a),n!==u&&(e=this.setInner(e,a.settings)),e},r.prototype.setAboveTags=function(e,a){var t=this,n=o("common/quote"),u=a.settings.left[0],i=a.settings.right[0];return e.replace(new RegExp("(^|.)(["+n+"])(.|$)","gm"),function(s,l,g,f,h){if(l!==c&&f!==c)return s;if(l===c&&f===c)return g==='"'?l+t.getAboveTwoTags(e,h+1,a)+f:s;if(l===c){var v=t.afterRight.indexOf(f)>-1,d=a.safeTags.getPrevTagInfo(a.context,e,h+1);return v&&d&&d.group==="html"?l+(d.isClosing?i:u)+f:l+(!f||v?i:u)+f}else{var $=t.beforeLeft.indexOf(l)>-1,R=a.safeTags.getNextTagInfo(a.context,e,h+1);return $&&R&&R.group==="html"?l+(R.isClosing?i:u)+f:l+(!l||$?u:i)+f}})},r.prototype.getAboveTwoTags=function(e,a,t){var n=t.safeTags.getPrevTagInfo(t.context,e,a),u=t.safeTags.getNextTagInfo(t.context,e,a);if(n&&n.group==="html"){if(!n.isClosing)return t.settings.left[0];if(u&&u.isClosing&&n.isClosing)return t.settings.right[0]}return e[a]},r.prototype.setInner=function(e,a){for(var t=a.left[0],n=a.right[0],u=0,i=this.getMaxLevel(e,t,n,a.left.length),s=u,l="",g=0,f=e.length;g<f;g++){var h=e[g];h===t?(l+=a.left[s>i-1?i-1:s],s++,s>i&&(s=i)):h===n?(s--,s<u&&(s=u),l+=a.right[s]):(h==='"'&&(s=u),l+=h)}return l},r.prototype.getMaxLevel=function(e,a,t,n){var u=this.count(e);return u[a]===u[t]?n:Math.min(n,Hr)},r}(),Gr=new Wr,pe={};J().forEach(function(r){pe[r]=A(o(r+"/quote"))});var Xr={name:"common/punctuation/quote",handler:function(r,e,a){var t=a.prefs.locale[0],n=e[t];return n?Gr.process({context:a,settings:n,safeTags:this.safeTags}):r},settings:pe},Kr={name:"common/punctuation/quoteLink",queue:"show-safe-tags-html",index:"+5",handler:function(r,e,a){var t=this.getSetting("common/punctuation/quote",a.prefs.locale[0]),n=m.getByUtf(t.left[0]),u=m.getByUtf(t.right[0]),i=m.getByUtf(t.left[1]),s=m.getByUtf(t.right[1]);i=i?"|"+i:"",s=s?"|"+s:"";var l=new RegExp("(<[aA]\\s[^>]*?>)("+n+i+")([^]*?)("+u+s+")(</[aA]>)","g");return r.replace(l,"$2$1$3$5$4")}};p.addRules([Ur,Qr,jr,Xr,Kr]);var Vr={name:"common/space/beforeBracket",handler:function(r,e,a){var t=a.getData("char"),n=new RegExp("(["+t+".!?,;\u2026)])\\(","gi");return r.replace(n,"$1 (")}},Yr={name:"common/space/bracket",handler:function(r){return r.replace(/(\() +/g,"(").replace(/ +\)/g,")")}},Zr={name:"common/space/delBeforePercent",handler:function(r){return r.replace(/(\d)( |\u00A0)(%|‰|‱)/g,"$1$3")}},Jr={name:"common/space/delBeforePunctuation",handler:function(r){return r.replace(/(^|[^!?:;,.…]) ([!?:;,])(?!\))/g,"$1$2")}},ea={name:"common/space/delBetweenExclamationMarks",handler:function(r){return r.replace(/([!?]) (?=[!?])/g,"$1")}},ra={name:"common/space/delBeforeDot",handler:function(r){return r.replace(/(^|[^!?:;,.…]) (\.|\.\.\.)(\s|$)/g,"$1$2$3")}},aa={name:"common/space/delLeadingBlanks",handler:function(r){return r.replace(/^[ \t]+/mg,"")},disabled:!0},ta={name:"common/space/delRepeatN",index:"-1",handler:function(r,e){var a=e.maxConsecutiveLineBreaks,t=new RegExp(`
{`.concat(a+1,",}"),"g"),n=T(`
`,a);return r.replace(t,n)},settings:{maxConsecutiveLineBreaks:2}},na={name:"common/space/delRepeatSpace",index:"-1",handler:function(r){return r.replace(/([^\n \t])[ \t]{2,}(?![\n \t])/g,"$1 ")}},ua={name:"common/space/delTrailingBlanks",index:"-3",handler:function(r){return r.replace(/[ \t]+\n/g,`
`)}},ia={name:"common/space/insertFinalNewline",queue:"end",handler:function(r){return r[r.length-1]===`
`?r:r+`
`},live:!1,disabled:!0},sa={name:"common/space/replaceTab",index:"-5",handler:function(r){return r.replace(/\t/g," ")}},la={name:"common/space/squareBracket",handler:function(r){return r.replace(/(\[) +/g,"[").replace(/ +\]/g,"]")}},oa={name:"common/space/trimLeft",index:"-4",handler:String.prototype.trimLeft?function(r){return r.trimLeft()}:function(r){return r.replace(/^[\s\uFEFF\xA0]+/g,"")}},ca={name:"common/space/trimRight",index:"-3",live:!1,handler:String.prototype.trimRight?function(r){return r.trimRight()}:function(r){return r.replace(/[\s\uFEFF\xA0]+$/g,"")}},pa=new RegExp('(\\D):([^)",:.?\\s\\/\\\\'+c+"])","g"),fa={name:"common/space/afterColon",handler:function(r){return r.replace(pa,"$1: $2")}},ha={name:"common/space/afterComma",handler:function(r,e,a){var t=a.getData("quote"),n=typeof t=="string"?t:t.right;return r.replace(new RegExp('(.),([^)",:.?\\s\\/\\\\'+c+n+"])","g"),function(u,i,s){return P(i)&&P(s)?u:i+", "+s})}},ga=new RegExp("\\?([^).\u2026!;?\\s[\\])"+c+o("common/quote")+"])","g"),da={name:"common/space/afterQuestionMark",handler:function(r){return r.replace(ga,"? $1")}},va=new RegExp("!([^).\u2026!;?\\s[\\])"+c+o("common/quote")+"])","g"),ma={name:"common/space/afterExclamationMark",handler:function(r){return r.replace(va,"! $1")}},Ra=new RegExp(";([^).\u2026!;?\\s[\\])"+c+o("common/quote")+"])","g"),$a={name:"common/space/afterSemicolon",handler:function(r){return r.replace(Ra,"; $1")}};p.addRules([fa,ha,da,ma,$a,Vr,Yr,ra,Zr,Jr,ea,aa,ta,na,ua,ia,sa,la,oa,ca]);var ba={name:"common/symbols/arrow",handler:function(r){return D(r,[[/(^|[^-])->(?!>)/g,"$1\u2192"],[/(^|[^<])<-(?!-)/g,"$1\u2190"]])}},ya={name:"common/symbols/cf",handler:function(r){var e=new RegExp('(^|[\\s(\\[+\u2248\xB1\u2212\u2014\u2013\\-])(\\d+(?:[.,]\\d+)?)[ \xA0\u2009]?(C|F)([\\W\\s.,:!?")\\]]|$)',"mg");return r.replace(e,"$1$2\u2009\xB0$3$4")}},Ea={name:"common/symbols/copy",handler:function(r){return D(r,[[/\(r\)/gi,"\xAE"],[/(copyright )?\((c|с)\)/gi,"\xA9"],[/\(tm\)/gi,"\u2122"]])}};p.addRules([ba,ya,Ea]);var Aa={name:"en-US/dash/main",index:"-5",handler:function(r){var e=o("common/dash"),a="\xA0",t="\u2014",n="[ ".concat(a,"]"),u="[ ".concat(a,`
]`),i=new RegExp("".concat(n,"(").concat(e,")(").concat(u,")"),"g");return r.replace(i,"".concat(a).concat(t,"$2"))}};p.addRules([Aa]);var wa={name:"ru/dash/centuries",handler:function(r,e){var a="("+o("common/dash")+")",t=new RegExp("(X|I|V)[ |\xA0]?"+a+"[ |\xA0]?(X|I|V)","g");return r.replace(t,"$1"+e.dash+"$3")},settings:{dash:"\u2013"}},qa={name:"ru/dash/daysMonth",handler:function(r,e){var a=new RegExp("(^|\\s)([123]?\\d)("+o("common/dash")+")([123]?\\d)[ \xA0]("+o("ru/monthGenCase")+")","g");return r.replace(a,"$1$2"+e.dash+"$4\xA0$5")},settings:{dash:"\u2013"}},xa={name:"ru/dash/de",handler:function(r){var e=new RegExp("([a-\u044F\u0451]+) \u0434\u0435"+o("ru/dashAfterDe"),"g");return r.replace(e,"$1-\u0434\u0435")},disabled:!0},ka={name:"ru/dash/decade",handler:function(r,e){var a=new RegExp("(^|\\s)(\\d{3}|\\d)0("+o("common/dash")+")(\\d{3}|\\d)0(-\u0435[ \xA0])(?=\u0433\\.?[ \xA0]?\u0433|\u0433\u043E\u0434)","g");return r.replace(a,"$1$20"+e.dash+"$40$5")},settings:{dash:"\u2013"}},Ta={name:"ru/dash/directSpeech",handler:function(r){var e=o("common/dash"),a=new RegExp('(["\xBB\u2018\u201C,])[ |\xA0]?('.concat(e,")[ |\xA0]"),"g"),t=new RegExp("(^|".concat(c,")(").concat(e,")( |\xA0)"),"gm"),n=new RegExp("([.\u2026?!])[ \xA0](".concat(e,")[ \xA0]"),"g");return r.replace(a,"$1\xA0\u2014 ").replace(t,"$1\u2014\xA0").replace(n,"$1 \u2014\xA0")}},Ba={name:"ru/dash/izpod",handler:function(r){var e=new RegExp(o("ru/dashBefore")+"(\u0418|\u0438)\u0437 \u043F\u043E\u0434"+o("ru/dashAfter"),"g");return r.replace(e,"$1$2\u0437-\u043F\u043E\u0434")}},La={name:"ru/dash/izza",handler:function(r){var e=new RegExp(o("ru/dashBefore")+"(\u0418|\u0438)\u0437 \u0437\u0430"+o("ru/dashAfter"),"g");return r.replace(e,"$1$2\u0437-\u0437\u0430")}},Sa={name:"ru/dash/ka",handler:function(r){var e=new RegExp("([a-\u044F\u0451]+) \u043A\u0430(\u0441\u044C)?"+o("ru/dashAfter"),"g");return r.replace(e,"$1-\u043A\u0430$2")}},Da={name:"ru/dash/koe",handler:function(r){var e=new RegExp(o("ru/dashBefore")+"([\u041A\u043A]\u043E[\u0435\u0439])\\s([\u0430-\u044F\u0451]{3,})"+o("ru/dashAfter"),"g");return r.replace(e,"$1$2-$3")}},Ca={name:"ru/dash/main",index:"-5",handler:function(r){var e=o("common/dash"),a=new RegExp("([ \xA0])("+e+")([ \xA0\\n])","g");return r.replace(a,"\xA0\u2014$3")}},Ia={name:"ru/dash/month",handler:function(r,e){var a="("+o("ru/month")+")",t="("+o("ru/monthPreCase")+")",n=o("common/dash"),u=new RegExp(a+" ?("+n+") ?"+a,"gi"),i=new RegExp(t+" ?("+n+") ?"+t,"gi"),s="$1"+e.dash+"$3";return r.replace(u,s).replace(i,s)},settings:{dash:"\u2013"}},Fa={name:"ru/dash/surname",handler:function(r){var e=new RegExp("([\u0410-\u042F\u0401][\u0430-\u044F\u0451]+)\\s-([\u0430-\u044F\u0451]{1,3})(?![^\u0430-\u044F\u0451]|$)","g");return r.replace(e,"$1\xA0\u2014$2")}},za={name:"ru/dash/taki",handler:function(r){var e=new RegExp("(\u0432\u0435\u0440\u043D\u043E|\u0434\u043E\u0432\u043E\u043B\u044C\u043D\u043E|\u043E\u043F\u044F\u0442\u044C|\u043F\u0440\u044F\u043C\u043E|\u0442\u0430\u043A|\u0432\u0441[\u0435\u0451]|\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043B\u044C\u043D\u043E|\u043D\u0435\u0443\u0436\u0435\u043B\u0438)\\s(\u0442\u0430\u043A\u0438)"+o("ru/dashAfter"),"g");return r.replace(e,"$1-$2")}},Ma={name:"ru/dash/time",handler:function(r,e){var a=new RegExp(o("ru/dashBefore")+"(\\d?\\d:[0-5]\\d)"+o("common/dash")+"(\\d?\\d:[0-5]\\d)"+o("ru/dashAfter"),"g");return r.replace(a,"$1$2"+e.dash+"$3")},settings:{dash:"\u2013"}},_a={name:"ru/dash/to",handler:function(r){var e="[\u041E\u043E]\u0442\u043A\u0443\u0434\u0430|[\u041A\u043A]\u0443\u0434\u0430|[\u0413\u0433]\u0434\u0435|[\u041A\u043A]\u043E\u0433\u0434\u0430|[\u0417\u0437]\u0430\u0447\u0435\u043C|[\u041F\u043F]\u043E\u0447\u0435\u043C\u0443|[\u041A\u043A]\u0430\u043A|[\u041A\u043A]\u0430\u043A\u043E[\u0435\u0439\u043C]|[\u041A\u043A]\u0430\u043A\u0430\u044F|[\u041A\u043A]\u0430\u043A\u0438[\u0435\u043C\u0445]|[\u041A\u043A]\u0430\u043A\u0438\u043C\u0438|[\u041A\u043A]\u0430\u043A\u0443\u044E|[\u0427\u0447]\u0442\u043E|[\u0427\u0447]\u0435\u0433\u043E|[\u0427\u0447]\u0435[\u0439\u043C]|[\u0427\u0447]\u044C\u0438\u043C?|[\u041A\u043A]\u0442\u043E|[\u041A\u043A]\u043E\u0433\u043E|[\u041A\u043A]\u043E\u043C\u0443|[\u041A\u043A]\u0435\u043C",a=new RegExp("(^|[^\u0410-\u042F\u0401\u0430-\u044F\u0451\\w])("+e+")( | -|- )(\u0442\u043E|\u043B\u0438\u0431\u043E|\u043D\u0438\u0431\u0443\u0434\u044C)"+o("ru/dashAfter"),"g");return r.replace(a,function(t,n,u,i,s){var l=u+i+s;return l==="\u043A\u0430\u043A \u0442\u043E"||l==="\u041A\u0430\u043A \u0442\u043E"?t:n+u+"-"+s})}},Na={name:"ru/dash/kakto",handler:function(r){var e=new RegExp("(^|[^\u0410-\u042F\u0401\u0430-\u044F\u0451\\w])([\u041A\u043A]\u0430\u043A) \u0442\u043E"+o("ru/dashAfter"),"g");return r.replace(e,"$1$2-\u0442\u043E")}},Pa={name:"ru/dash/weekday",handler:function(r,e){var a="("+o("ru/weekday")+")",t=new RegExp(a+" ?("+o("common/dash")+") ?"+a,"gi");return r.replace(t,"$1"+e.dash+"$3")},settings:{dash:"\u2013"}},Oa={name:"ru/dash/years",handler:function(r,e){var a=o("common/dash"),t=new RegExp("(\\D|^)(\\d{4})[ \xA0]?("+a+")[ \xA0]?(\\d{4})(?=[ \xA0]?\u0433)","g");return r.replace(t,function(n,u,i,s,l){return parseInt(i,10)<parseInt(l,10)?u+i+e.dash+l:n})},settings:{dash:"\u2013"}};p.addRules([wa,qa,xa,ka,Ta,Ba,La,Sa,Da,Ca,Ia,Fa,za,Ma,_a,Na,Pa,Oa]);var H="(-|\\.|\\/)",W="(-|\\/)",Ua=new RegExp("(^|\\D)(\\d{4})"+H+"(\\d{2})"+H+"(\\d{2})(\\D|$)","gi"),Qa=new RegExp("(^|\\D)(\\d{2})"+W+"(\\d{2})"+W+"(\\d{4})(\\D|$)","gi"),ja={name:"ru/date/fromISO",handler:function(r){return r.replace(Ua,"$1$6.$4.$2$7").replace(Qa,"$1$4.$2.$6$7")}},Ha={name:"ru/date/weekday",handler:function(r){var e="( |\xA0)",a=o("ru/monthGenCase"),t=o("ru/weekday"),n=new RegExp("(\\d)"+e+"("+a+"),"+e+"("+t+")","gi");return r.replace(n,function(u,i,s,l,g,f){return i+s+l.toLowerCase()+","+g+f.toLowerCase()})}};p.addRules([ja,Ha]);var Wa={name:"ru/money/currency",handler:function(r){var e="([$\u20AC\xA5\u04B0\xA3\u20A4\u20BD])",a="[ \xA0\u2009\u202F]",t=new RegExp("(^|[\\D]{2})"+e+" ?("+N+"("+a+"\\d{3})*)("+a+"?(\u0442\u044B\u0441\\.|\u043C\u043B\u043D|\u043C\u043B\u0440\u0434|\u0442\u0440\u043B\u043D))?","gm"),n=new RegExp("(^|[\\D])("+N+") ?"+e,"gm");return r.replace(t,function(u,i,s,l,g,f,h,v){return i+l+(v?"\xA0"+v:"")+"\xA0"+s}).replace(n,"$1$2\xA0$4")},disabled:!0},Ga={name:"ru/money/ruble",handler:function(r){var e="$1\xA0\u20BD",a="(\\d+)( |\xA0)?(\u0440|\u0440\u0443\u0431)\\.",t=new RegExp("^"+a+"$","g"),n=new RegExp(a+"(?=[!?,:;])","g"),u=new RegExp(a+"(?=\\s+[A-\u042F\u0401])","g");return r.replace(t,e).replace(n,e).replace(u,e+".")},disabled:!0};p.addRules([Wa,Ga]);function G(r,e,a,t){return a==="\u0434\u0434"&&t==="\u043C\u043C"||["\u0440\u0444","\u0440\u0443","\u0440\u0443\u0441","\u043E\u0440\u0433","\u0443\u043A\u0440","\u0431\u0433","\u0441\u0440\u0431"].indexOf(t)>-1?r:e+a+".\xA0"+t+"."}var Xa={name:"ru/nbsp/abbr",handler:function(r){var e=new RegExp("(^|\\s|".concat(c,")([\u0430-\u044F\u0451]{1,3})\\. ?([\u0430-\u044F\u0451]{1,3})\\."),"g");return r.replace(e,G).replace(e,G)}},Ka={name:"ru/nbsp/addr",handler:function(r){return r.replace(/(\s|^)(дом|д\.|кв\.|под\.|п-д) *(\d+)/gi,"$1$2\xA0$3").replace(/(\s|^)(мкр-н|мк-н|мкр\.|мкрн)\s/gi,"$1$2\xA0").replace(/(\s|^)(эт\.) *(-?\d+)/gi,"$1$2\xA0$3").replace(/(\s|^)(\d+) +этаж([^а-яё]|$)/gi,"$1$2\xA0\u044D\u0442\u0430\u0436$3").replace(/(\s|^)литер\s([А-Я]|$)/gi,"$1\u043B\u0438\u0442\u0435\u0440\xA0$2").replace(/(\s|^)(обл|кр|ст|пос|с|д|ул|пер|пр|пр-т|просп|пл|бул|б-р|наб|ш|туп|оф|комн?|уч|вл|влад|стр|кор)\. *([а-яёa-z\d]+)/gi,"$1$2.\xA0$3").replace(/(\D[ \u00A0]|^)г\. ?([А-ЯЁ])/gm,"$1\u0433.\xA0$2")}},Va={name:"ru/nbsp/afterNumberSign",handler:function(r){return r.replace(/№[ \u00A0\u2009]?(\d|п\/п)/g,"\u2116\u202F$1")}},Ya={name:"ru/nbsp/beforeParticle",index:"+5",handler:function(r){var e="(\u043B\u0438|\u043B\u044C|\u0436\u0435|\u0436|\u0431\u044B|\u0431)",a=new RegExp("([\u0410-\u042F\u0401\u0430-\u044F\u0451]) "+e+'(?=[,;:?!"\u2018\u201C\xBB])',"g"),t=new RegExp("([\u0410-\u042F\u0401\u0430-\u044F\u0451])[ \xA0]"+e+"[ \xA0]","g");return r.replace(a,"$1\xA0$2").replace(t,"$1\xA0$2 ")}},Za={name:"ru/nbsp/centuries",handler:function(r){var e=o("common/dash"),a="(^|\\s)([VIX]+)",t='(?=[,;:?!"\u2018\u201C\xBB]|$)',n=new RegExp(a+"[ \xA0]?\u0432\\.?"+t,"gm"),u=new RegExp(a+"("+e+")([VIX]+)[ \xA0]?\u0432\\.?([ \xA0]?\u0432\\.?)?"+t,"gm");return r.replace(n,"$1$2\xA0\u0432.").replace(u,"$1$2$3$4\xA0\u0432\u0432.")}},Ja={name:"ru/nbsp/dayMonth",handler:function(r){var e=new RegExp("(\\d{1,2}) ("+o("ru/shortMonth")+")","gi");return r.replace(e,"$1\xA0$2")}},et={name:"ru/nbsp/initials",handler:function(r){var e="\xA0\u202F ",a=o("ru/quote"),t=new RegExp("(^|[("+e+a.left+c+'"])([\u0410-\u042F\u0401])\\.['+e+"]?([\u0410-\u042F\u0401])\\.["+e+"]?([\u0410-\u042F\u0401][\u0430-\u044F\u0451]+)","gm");return r.replace(t,"$1$2.\xA0$3.\xA0$4")}},rt={2:"\xB2","\xB2":"\xB2",3:"\xB3","\xB3":"\xB3","":""},at={name:"ru/nbsp/m",index:"+5",handler:function(r){var e=new RegExp("(^|[\\s,.\\("+c+"])(\\d+)[ \xA0]?(\u043C\u043C?|\u0441\u043C|\u043A\u043C|\u0434\u043C|\u0433\u043C|mm?|km|cm|dm)([23\xB2\xB3])?([\\s\\).!?,;"+c+"]|$)","gm");return r.replace(e,function(a,t,n,u,i,s){return t+n+"\xA0"+u+rt[i||""]+(s==="\xA0"?" ":s)})}},tt={name:"ru/nbsp/mln",handler:function(r){return r.replace(/(\d) ?(тыс|млн|млрд|трлн)(\.|\s|$)/gi,"$1\xA0$2$3")}},nt={name:"ru/nbsp/ooo",handler:function(r){return r.replace(/(^|[^a-яёA-ЯЁ])(ООО|ОАО|ЗАО|НИИ|ПБОЮЛ) /g,"$1$2\xA0")}},ut={name:"ru/nbsp/page",handler:function(r){var e=new RegExp("(^|[)\\s"+c+"])(\u0441\u0442\u0440|\u0433\u043B|\u0440\u0438\u0441|\u0438\u043B\u043B?|\u0441\u0442|\u043F|c)\\. *(\\d+)([\\s.,?!;:]|$)","gim");return r.replace(e,"$1$2.\xA0$3$4")}},it={name:"ru/nbsp/ps",handler:function(r){var e=new RegExp("(^|\\s|".concat(c,")[p\u0437]\\.[ \xA0]?([p\u0437]\\.[ \xA0]?)?[s\u044B]\\.:? "),"gim");return r.replace(e,function(a,t,n){return t+(n?"P.\xA0P.\xA0S. ":"P.\xA0S. ")})}},st={name:"ru/nbsp/rubleKopek",handler:function(r){return r.replace(/(\d) ?(?=(руб|коп)\.)/g,"$1\xA0")}},lt={name:"ru/nbsp/see",handler:function(r){var e=new RegExp("(^|\\s|".concat(c,"|\\()(\u0441\u043C|\u0438\u043C)\\.[ \xA0]?([\u0430-\u044F\u04510-9a-z]+)([\\s.,?!]|$)"),"gi");return r.replace(e,function(a,t,n,u,i){return(t==="\xA0"?" ":t)+n+".\xA0"+u+i})}},ot={name:"ru/nbsp/year",handler:function(r){return r.replace(/(^|\D)(\d{4}) ?г([ ,;.\n]|$)/g,"$1$2\xA0\u0433$3")}},ct={name:"ru/nbsp/years",index:"+5",handler:function(r){var e=o("common/dash"),a=new RegExp("(^|\\D)(\\d{4})("+e+')(\\d{4})[ \xA0]?\u0433\\.?([ \xA0]?\u0433\\.)?(?=[,;:?!"\u2018\u201C\xBB\\s]|$)',"gm");return r.replace(a,"$1$2$3$4\xA0\u0433\u0433.")}};p.addRules([Xa,Ka,Va,Ya,Za,Ja,et,at,tt,nt,ut,it,st,lt,ot,ct]);var pt={name:"ru/number/comma",handler:function(r){return r.replace(/(^|\s)(\d+)\.(\d+[\u00A0\u2009\u202F ]*?[%‰°×x])/gim,"$1$2,$3")}},ft={name:"ru/number/ordinals",handler:function(r,e,a){var t=a.getData("char"),n=new RegExp("(\\d[%\u2030]?)-(\u044B\u0439|\u043E\u0439|\u0430\u044F|\u043E\u0435|\u044B\u0435|\u044B\u043C|\u043E\u043C|\u044B\u0445|\u043E\u0433\u043E|\u043E\u043C\u0443|\u044B\u043C\u0438)(?!["+t+"])","g");return r.replace(n,function(u,i,s){var l={\u043E\u0439:"\u0439",\u044B\u0439:"\u0439",\u0430\u044F:"\u044F",\u043E\u0435:"\u0435",\u044B\u0435:"\u0435",\u044B\u043C:"\u043C",\u043E\u043C:"\u043C",\u044B\u0445:"\u0445",\u043E\u0433\u043E:"\u0433\u043E",\u043E\u043C\u0443:"\u043C\u0443",\u044B\u043C\u0438:"\u043C\u0438"};return i+"-"+l[s]})}};p.addRules([pt,ft]);function w(r,e){var a=new RegExp('<span class="('+e.join("|")+')">([^]*?)</span>',"g");return r.replace(a,"$2")}function C(r,e){return r.replace(/<title>[^]*?<\/title>/i,function(a){return w(a,e)})}var fe=["typograf-oa-lbracket","typograf-oa-n-lbracket","typograf-oa-sp-lbracket"],I="ru/optalign/bracket",ht={name:I,handler:function(r){return r.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},gt={name:I,queue:"start",handler:function(r){return w(r,fe)},htmlAttrs:!1},dt={name:I,queue:"end",handler:function(r){return C(r,fe)},htmlAttrs:!1},he=["typograf-oa-comma","typograf-oa-comma-sp"],F="ru/optalign/comma",vt={name:F,handler:function(r,e,a){var t=a.getData("char"),n=new RegExp("(["+t+"\\d\u0301]+), ","gi");return r.replace(n,'$1<span class="typograf-oa-comma">,</span><span class="typograf-oa-comma-sp"> </span>')},disabled:!0,htmlAttrs:!1},mt={name:F,queue:"start",handler:function(r){return w(r,he)},htmlAttrs:!1},Rt={name:F,queue:"end",handler:function(r){return C(r,he)},htmlAttrs:!1},ge=["typograf-oa-lquote","typograf-oa-n-lquote","typograf-oa-sp-lquote"],z="ru/optalign/quote",$t={name: