Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

typograf

Package Overview
Dependencies
Maintainers
1
Versions
101
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

typograf - npm Package Compare versions

Comparing version 1.2.3 to 1.2.4

.travis.yml

12

bower.json
{
"name": "typograf",
"version": "1.2.3",
"version": "1.2.4",
"description": "The client and server typographer",

@@ -15,11 +15,3 @@ "bugs": "https://github.com/hcodes/typograf/issues/new",

"dist/typograf.min.js"
],
"ignore": [
"node_modules",
"libs"
],
"devDependencies": {
"jquery": ">= 2.1.1",
"qunit": ">= 1.15.0"
}
]
}

@@ -1,1 +0,1 @@

function Typograf(e){this._prefs="object"==typeof e?e:{},this._settings={},this._enabledRules={},this._rules.forEach(function(e){this._settings[e.name]=e.settings||{},this._enabledRules[e.name]=e.enabled},this)}Typograf.rule=function(e){return e.enabled=e.enabled===!1?!1:!0,Typograf.prototype._rules.push(e),Typograf._needSortRules&&this._sortRules(),this},Typograf.data=function(e,r){Typograf.prototype.data[e]=r},Typograf._sortRules=function(){Typograf.prototype._rules.sort(function(e,r){return e.sortIndex>r.sortIndex?1:-1})},Typograf.prototype={constructor:Typograf,execute:function(e){if(e=""+e,!e)return"";e=e.replace(/\r\n/g,"\n").replace(/\r/g,"\n");var r=-1!==e.search(/<|>/);return r&&(e=this._hideSafeTags(e)),e=this._utfication(e),this._rules.forEach(function(r){this.enabled(r.name)&&(e=r.func.call(this,e,this._settings[r.name]))},this),e=this._modification(e),r&&(e=this._showSafeTags(e)),e},setting:function(e,r,n){return arguments.length<=2?this._settings[e]?this._settings[e][r]:void 0:(this._settings[e]=this._settings[e]||{},this._settings[e][r]=n,this)},enabled:function(e){return this._enabledRules[e]},disabled:function(e){return!this._enabledRules[e]},enable:function(e){return this._enable(e,!0)},disable:function(e){return this._enable(e,!1)},data:{},_enable:function(e,r){return Array.isArray(e)?e.forEach(function(e){this._enabledRules[e]=r},this):this._enabledRules[e]=r,this},_rules:[],_hideSafeTags:function(e){this._hiddenSafeTags={};var r=this,n="",t=[["<!--","-->"],["<pre[^>]*>","<\\/pre>"],["<code[^>]*>","<\\/code>"],["<style[^>]*>","<\\/style>"],["<script[^>]*>","<\\/script>"],["<object>","<\\/object>"]];t.forEach(function(e){n+="("+e[0]+"(.|\\n)*?"+e[1]+")|"},this);var a=0;return e=e.replace(new RegExp("("+n+"<[^>]*[\\s][^>]*>)","gim"),function(e){var n="__typograf"+a+"__";return r._hiddenSafeTags[n]=e,a++,n})},_showSafeTags:function(e){return Object.keys(this._hiddenSafeTags).forEach(function(r){e=e.replace(new RegExp(r,"gim"),this._hiddenSafeTags[r])},this),delete this._hiddenSafeTags,e},_utfication:function(e){return-1===e.search("&")?e:(this.entities.forEach(function(r){e=e.replace(r[3],r[2])},this),e)},_modification:function(e){var r,n=this._prefs.mode;return("name"===n||"digit"===n)&&(r="name"===n?0:1,this.entities.forEach(function(n){var t=new RegExp(n[2],"g");e=e.replace(t,n[r])},this)),e}},"object"==typeof exports&&(module.exports=Typograf),Typograf.prototype.entities=[["\\&nbsp;","\\&\\#160;"," "],["\\&iexcl;","\\&\\#161;","¡"],["\\&cent;","\\&\\#162;","¢"],["\\&pound;","\\&\\#163;","£"],["\\&curren;","\\&\\#164;","¤"],["\\&yen;","\\&\\#165;","¥"],["\\&brvbar;","\\&\\#166;","¦"],["\\&sect;","\\&\\#167;","§"],["\\&uml;","\\&\\#168;","¨"],["\\&copy;","\\&\\#169;","©"],["\\&ordf;","\\&\\#170;","ª"],["\\&laquo;","\\&\\#171;","«"],["\\&not;","\\&\\#172;","¬"],["\\&shy;","\\&\\#173;","­"],["\\&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;","˜"],["\\&ensp;","\\&\\#8194;"," "],["\\&emsp;","\\&\\#8195;"," "],["\\&thinsp;","\\&\\#8201;"," "],["\\&zwnj;","\\&\\#8204;","‌"],["\\&zwj;","\\&\\#8205;","‍"],["\\&lrm;","\\&\\#8206;","‎"],["\\&rlm;","\\&\\#8207;","‏"],["\\&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;","€"]],Typograf.prototype.entities.forEach(function(e){e[3]=new RegExp("("+e[0]+"|"+e[1]+")","g")},this),Typograf.data("month",["январь","февраль","март","апрель","май","июнь","июль","август","сентябрь","октябрь","ноябрь","декабрь"]),Typograf.data("weekday",["понедельник","вторник","среда","четверг","пятница","суббота","воскресенье"]),Typograf.rule({title:"Удаление двойной пунктуации",name:"delDoublePunctiation",sortIndex:580,func:function(e){return e.replace(/(,|:|;|\?){2,}/g,"$1")}}),Typograf.rule({title:"!! → !",name:"exclamation",sortIndex:1150,func:function(e){return e.replace(/(^|[^!])\!{2}($|[^!])/,"$1!$2").replace(/(^|[^!])\!{4}?($|[^!])/,"$1!!!$2")}}),Typograf.rule({title:"!? → ?!",name:"exclamationQuestion",sortIndex:1140,func:function(e){var r=new RegExp("(^|[^!])!\\?([^?]|$)","g");return e.replace(r,"$1?!$2")}}),Typograf.rule({title:"Расстановка кавычек",name:"quot",sortIndex:700,func:function(e,r){var n="[\\w\\dа-яёА-ЯЁ]",t=r.lquot,a=r.rquot,u=r.lquot2,i=r.rquot2,o="(?:^|<\\w.*?>)*",l="(?:…|"+n+"|\\n)",c="(?:"+[n,"[)!?.:;#*]"].join("|")+")*",s='(«|»|„|“|”|‘|’|&quot;|")',p='(»|“|&quot;|")',g=new RegExp("("+o+")?"+s+"("+o+l+o+")","g"),f=new RegExp("("+o+c+o+")"+p+"("+c+")","g"),d=new RegExp("("+t+")(.*?)"+t+"(.*?)("+a+")","g"),$=new RegExp("("+t+")(.*?)"+a+"(.*?)("+a+")","g"),m=new RegExp(t+t,"g"),h=new RegExp(a+a,"g");return e=e.replace(g,"$1"+t+"$3").replace(f,"$1"+a+"$3"),e=t===u&&a===i?e.replace(m,"$1$2"+t+"$3$4").replace(h,"$1$2"+a+"$3$4"):e.replace(d,"$1$2"+u+"$3$4").replace($,"$1$2"+i+"$3$4")},settings:{lquot:"«",rquot:"»",lquot2:"„",rquot2:"“"}}),function(){var e="(^| |\\n)",r="( |,|\\.|\\?|\\:|\\!|$)";Typograf.rule({title:"Дефис перед то, либо, нибудь, ка, де, кась",name:"dash/to",sortIndex:30,func:function(e){var n=new RegExp("( | ?- ?)(то|либо|нибудь|ка|де|кась)"+r,"g");return e.replace(n,"-$2$3")}}),Typograf.rule({title:"Дефис между из-за",name:"dash/izza",sortIndex:33,func:function(n){var t=new RegExp(e+"(И|и)з за"+r,"g");return n.replace(t,"$1$2з-за$3")}}),Typograf.rule({title:"Дефис между из-под",name:"dash/izpod",sortIndex:35,func:function(n){var t=new RegExp(e+"(И|и)з под"+r,"g");return n.replace(t,"$1$2з-под$3")}}),Typograf.rule({title:"Дефис после кое и кой",name:"dash/koe",sortIndex:38,func:function(n){var t=new RegExp(e+"(К|к)ое\\s([а-яё]{3,})"+r,"g");n=n.replace(t,"$1$2ое-$3$4");var a=new RegExp(e+"(К|к)ой\\s([а-я]{3,})"+r,"g");return n.replace(a,"$1$2ой-$3$4")}}),Typograf.rule({title:"Дефис между верно-таки и т.д.",name:"dash/taki",sortIndex:39,func:function(e){var n=new RegExp("(верно|довольно|опять|прямо|так|всё|действительно|неужели)\\s(таки)"+r,"g");return e.replace(n,"$1-$2$3")}})}(),Typograf.rule({title:"Дефис на тире",name:"dash/main",sortIndex:620,func:function(e){var r=new RegExp("(\\s| )(-|—)(\\s|\\n)","g");return e.replace(r," —$3").replace(/(X|I|V)(?: |\u00A0)?(-|—)(?: |\u00A0)?(X|I|V)/g,"$1—$3")},settings:{dash:"—",dashInterval:"—"}}),Typograf.rule({title:"Дефис между месяцами",name:"dash/month",sortIndex:610,func:function(e){var r="("+this.data.month.join("|")+")",n=new RegExp(r+" ?(-|—) ?"+r,"gi");return e.replace(n,"$1"+this.setting("dash/main","dashInterval")+"$3")}}),Typograf.rule({title:"Дефис между днями недели",name:"dash/weekday",sortIndex:600,func:function(e){var r="("+this.data.weekday.join("|")+")",n=new RegExp(r+" ?(-|—) ?"+r,"gi");return e.replace(n,"$1"+this.setting("dash/main","dashInterval")+"$3")}}),Typograf.rule({title:"Преобразование дат к виду DD.MM.YYYY",name:"date/main",sortIndex:1300,func:function(e){var r="(-|\\.|\\/)",n="(-|\\/)",t=new RegExp("(^|\\D)(\\d{4})"+r+"(\\d{2})"+r+"(\\d{2})(\\D|$)","gi"),a=new RegExp("(^|\\D)(\\d{2})"+n+"(\\d{2})"+n+"(\\d{4})(\\D|$)","gi");return e.replace(t,"$1$6.$4.$2$7").replace(a,"$1$4.$2.$6$7")}}),Typograf.rule({title:"Замена перевода строки на <br/>",name:"html/nbr",sortIndex:710,func:function(e){return e.replace(/\n/g,"<br/>")},enabled:!1}),Typograf.rule({title:"Расстановка <p> и <br/>",name:"html/pbr",sortIndex:700,func:function(e){return-1===e.search(/\n/)?e="<p>"+e+"</p>":(e="<p>"+e.replace(/\n\n/g,"</p>\n<p>")+"</p>",e=e.replace(/([^>])\n/g,"$1<br/>\n")),e},enabled:!1}),Typograf.rule({title:"Удаление HTML-тегов",name:"html/stripTags",sortIndex:5,func:function(e){return e.replace(/<\/?[^>]+>/g,"")},enabled:!1}),Typograf.rule({title:"Расстановка ссылок",name:"html/url",sortIndex:200,func:function(e){var r="(http|https|ftp|telnet|news|gopher|file|wais)://",n="([a-zA-Z0-9/\\n+-=%&:_.~?]+[a-zA-Z0-9#+]*)",t=new RegExp(r+n,"g");return e.replace(t,function(e,r,n){var t=n,a=r+"://"+n,u='<a href="'+a+'">';return"http"===r?(t=t.replace(/^www\./,"").replace(/^([^\/]+)\/$/,"$1"),u+t+"</a>"):u+a+"</a>"})}}),Typograf.rule({title:"$100 → 100 $",name:"money/dollar",sortIndex:1140,func:function(e){var r=new RegExp("(^|[\\D]{2,})\\$ ?([\\d.,]+)","g"),n=new RegExp("(^|[\\D])([\\d.,]+) ?\\$"),t="$1$2 $";return e.replace(r,t).replace(n,t)}}),Typograf.rule({title:"€100 → 100 €",name:"money/euro",sortIndex:1140,func:function(e){var r=new RegExp("(^|[\\D]{2,})€ ?([\\d.]+)","g"),n=new RegExp("(^|[\\D])([\\d.,]+) ?€"),t="$1$2 €";return e.replace(r,t).replace(n,t)}}),Typograf.rule({title:"Неразрывный пробел после № и §",name:"nbsp/afterNum",sortIndex:610,func:function(e){return e.replace(/№ ?(\d)/g,"№ $1").replace(/§ ?(\d|I|V|X)/g,"§ $1")}}),Typograf.rule({title:"Неразрывный пробел после короткого слова",name:"nbsp/afterShortWord",sortIndex:590,func:function(e,r){var n=r.lengthShortWord,t=new RegExp("( [а-яёА-ЯЁ\\w]{1,"+n+"}) ","g");return n>0?e.replace(t,"$1 "):e},settings:{lengthShortWord:2}}),Typograf.rule({title:"Неразрывный пробел перед ли, ль, же, бы, б",name:"nbsp/beforeParticle",sortIndex:570,func:function(e){return e.replace(/ (ли|ль|же|ж|бы|б)([^а-яёА-ЯЁ])/g," $1$2")}}),Typograf.rule({title:"Неразрывный пробел перед последним коротким словом в предложении",name:"nbsp/beforeShortLastWord",sortIndex:620,func:function(e,r){var n=r.lengthLastWord,t=new RegExp(" ([а-яёА-ЯЁ\\w]{1,"+n+"})(\\.|\\?|:|!|,)","g");return n>0?e.replace(t," $1$2"):e},settings:{lengthLastWord:3}}),Typograf.rule({title:"Расстановка запятых и неразрывного пробела перед а и но",name:"nbsp/but",sortIndex:1110,func:function(e){var r=new RegExp("([,])?( | |\n)(а|но)( | |\n)","g");return e.replace(r,",$2$3$4")}}),Typograf.rule({title:"m2 → м², m3 → м³ и неразрывный пробел",name:"nbsp/m",sortIndex:1030,func:function(e){var r="(км|м|дм|см|мм)",n=new RegExp("(^|\\D)(\\d+) ?"+r+"2(\\D|$)","g"),t=new RegExp("(^|\\D)(\\d+) ?"+r+"3(\\D|$)","g");return e=e.replace(n,"$1$2 $3²$4"),e.replace(t,"$1$2 $3³$4")}}),Typograf.rule({title:"Неразрывный пробел после OOO или ОАО",name:"nbsp/ooo",sortIndex:1100,func:function(e){return e.replace(/(ООО|ОАО) /g,"$1 ")}}),Typograf.rule({title:"Неразрывный пробел после XXXX",name:"nbsp/xxxx",sortIndex:1060,func:function(e){return e.replace(/(^|\D)(\d{4}) ?г( |,|;|\.|\n|$)/g,"$1$2 г$3")}}),Typograf.rule({title:"г.г. → гг. и неразрывный пробел",name:"nbsp/yy",sortIndex:1080,func:function(e){return e.replace(/(^|\d) ?г\. ?г\./g,"$1 гг.")}}),Typograf.rule({title:"Пробел после знаков пунктуации",name:"space/afterPunctuation",sortIndex:560,func:function(e){return e.replace(/(\!|;|\?)([^ \n\t\!;\?])/g,"$1 $2").replace(/(\D)(,|\:)([^ \/\d\n\t\!;,\?\.\:])/g,"$1$2 $3")}}),Typograf.rule({title:"Удаление пробела перед %",name:"space/delBeforePercent",sortIndex:600,func:function(e){return e.replace(/(\d)( |\u00A0)%/g,"$1%")}}),Typograf.rule({title:"Удаление пробелов перед знаками пунктуации",name:"space/delBeforePunctuation",sortIndex:550,func:function(e){return e.replace(/ (\!|;|,|\?|\.|\:)/g,"$1").replace(/\( /g,"(").replace(/([^ ])\(/g,"$1 (").replace(/ \)/g,")").replace(/\)([^\!;,\?\.\:])/g,") $1")}}),Typograf.rule({title:"Удаление повторяющихся переносов строки (не более двух)",name:"space/delRepeatN",sortIndex:545,func:function(e){return e.replace(/\n{3,}/g,"\n\n")}}),Typograf.rule({title:"Удаление повторяющихся пробелов",name:"space/delRepeatSpace",sortIndex:540,func:function(e){return e.replace(/( |\t){2,}/g,"$1")}}),Typograf.rule({title:"Удаление пробелов в конце строк",name:"space/delTrailingBlanks",sortIndex:505,func:function(e){return e.replace(/\s+\n/g,"\n")}}),Typograf.rule({title:"Замена табов на пробелы",name:"space/replaceTab",sortIndex:510,func:function(e){return e.replace(/\t/g," ")}}),Typograf.rule({title:"Удаление пробелов в начале и в конце текста",name:"space/trim",sortIndex:530,func:function(e){return e.trim()}}),Typograf.rule({title:"-> → →, <- → ←",name:"sym/arrow",sortIndex:1130,func:function(e){return e.replace(/(^|[^-])->(?!>)/g,"$1→").replace(/(^|[^<])<-(?!-)/g,"$1←")}}),Typograf.rule({title:"Удаление лишних точек и пробелов в вв.",name:"sym/cc",sortIndex:1090,func:function(e){return e=e.replace(/(^|\d|V|I|X) ?в(в)?( |,|;|\n|$)/g,"$1 в$2.$3"),e.replace(/(^|\d|[IVX]) ?в\.? ?в\./g,"$1 вв.")}}),Typograf.rule({title:"Добавление ° к C и F",name:"sym/cf",sortIndex:1020,func:function(e){var r=new RegExp('(\\d+)( | )?(C|F)([\\W \\.,:\\!\\?"\\]\\)]|$)',"g");return e.replace(r,"$1 °$3$4")}}),Typograf.rule({title:"(c) → ©, (tm) → ©, (r) → ™",name:"sym/copy",sortIndex:10,func:function(e){return e.replace(/\(r\)/gi,"®").replace(/\((c|с)\)/gi,"©").replace(/\(tm\)/gi,"™")}}),Typograf.rule({title:"1/2 → ½, 1/4 → ¼, 3/3 → ¾",name:"sym/fraction",sortIndex:1120,func: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")}}),Typograf.rule({title:"... → …",name:"sym/hellip",sortIndex:20,func:function(e){return e.replace(/(^|[^.])\.{3,4}([^.]|$)/g,"$1…$2")}}),Typograf.rule({title:"+- → ±",name:"sym/plusMinus",sortIndex:1010,func:function(e){var r=new RegExp("(^| |\\>| )\\+-(\\d)","g");return e.replace(r,"$1±$2").replace(/(^\s*)\+-(\s*$)/g,"$1±$2")}}),Typograf.rule({title:"x → ×",name:"sym/times",sortIndex:1050,func:function(e){return e.replace(/(\d) ?(x|х) ?(\d)/g,"$1×$3")}}),Typograf._sortRules(),Typograf._needSortRules=!0;
function Typograf(e){this._prefs="object"==typeof e?e:{},this._settings={},this._enabledRules={},this._rules.forEach(function(e){this._settings[e.name]=e.settings||{},this._enabledRules[e.name]=e.enabled},this)}Typograf.rule=function(e){return e.enabled=e.enabled===!1?!1:!0,Typograf.prototype._rules.push(e),Typograf._needSortRules&&this._sortRules(),this},Typograf.data=function(e,r){Typograf.prototype.data[e]=r},Typograf._sortRules=function(){Typograf.prototype._rules.sort(function(e,r){return e.sortIndex>r.sortIndex?1:-1})},Typograf.prototype={constructor:Typograf,execute:function(e){if(e=""+e,!e)return"";e=e.replace(/\r\n/g,"\n").replace(/\r/g,"\n");var r=-1!==e.search(/<|>/);return r&&(e=this._hideSafeTags(e)),e=this._utfication(e),this._rules.forEach(function(r){this.enabled(r.name)&&(e=r.func.call(this,e,this._settings[r.name]))},this),e=this._modification(e),r&&(e=this._showSafeTags(e)),e},setting:function(e,r,n){return arguments.length<=2?this._settings[e]?this._settings[e][r]:void 0:(this._settings[e]=this._settings[e]||{},this._settings[e][r]=n,this)},enabled:function(e){return this._enabledRules[e]},disabled:function(e){return!this._enabledRules[e]},enable:function(e){return this._enable(e,!0)},disable:function(e){return this._enable(e,!1)},data:{},_enable:function(e,r){return Array.isArray(e)?e.forEach(function(e){this._enabledRules[e]=r},this):this._enabledRules[e]=r,this},_rules:[],_hideSafeTags:function(e){this._hiddenSafeTags={};var r=this,n="",t=[["<!--","-->"],["<pre[^>]*>","<\\/pre>"],["<code[^>]*>","<\\/code>"],["<style[^>]*>","<\\/style>"],["<script[^>]*>","<\\/script>"],["<object>","<\\/object>"]];t.forEach(function(e){n+="("+e[0]+"(.|\\n)*?"+e[1]+")|"},this);var a=0;return e=e.replace(new RegExp("("+n+"<[^>]*[\\s][^>]*>)","gim"),function(e){var n="__typograf"+a+"__";return r._hiddenSafeTags[n]=e,a++,n})},_showSafeTags:function(e){return Object.keys(this._hiddenSafeTags).forEach(function(r){e=e.replace(new RegExp(r,"gim"),this._hiddenSafeTags[r])},this),delete this._hiddenSafeTags,e},_utfication:function(e){return-1===e.search("&")?e:(this.entities.forEach(function(r){e=e.replace(r[3],r[2])},this),e)},_modification:function(e){var r,n=this._prefs.mode;return("name"===n||"digit"===n)&&(r="name"===n?0:1,this.entities.forEach(function(n){var t=new RegExp(n[2],"g");e=e.replace(t,n[r])},this)),e}},"object"==typeof exports&&(module.exports=Typograf),Typograf.prototype.entities=[["\\&nbsp;","\\&\\#160;"," "],["\\&iexcl;","\\&\\#161;","¡"],["\\&cent;","\\&\\#162;","¢"],["\\&pound;","\\&\\#163;","£"],["\\&curren;","\\&\\#164;","¤"],["\\&yen;","\\&\\#165;","¥"],["\\&brvbar;","\\&\\#166;","¦"],["\\&sect;","\\&\\#167;","§"],["\\&uml;","\\&\\#168;","¨"],["\\&copy;","\\&\\#169;","©"],["\\&ordf;","\\&\\#170;","ª"],["\\&laquo;","\\&\\#171;","«"],["\\&not;","\\&\\#172;","¬"],["\\&shy;","\\&\\#173;","­"],["\\&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;","˜"],["\\&ensp;","\\&\\#8194;"," "],["\\&emsp;","\\&\\#8195;"," "],["\\&thinsp;","\\&\\#8201;"," "],["\\&zwnj;","\\&\\#8204;","‌"],["\\&zwj;","\\&\\#8205;","‍"],["\\&lrm;","\\&\\#8206;","‎"],["\\&rlm;","\\&\\#8207;","‏"],["\\&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;","€"]],Typograf.prototype.entities.forEach(function(e){e[3]=new RegExp("("+e[0]+"|"+e[1]+")","g")},this),Typograf.data("month",["январь","февраль","март","апрель","май","июнь","июль","август","сентябрь","октябрь","ноябрь","декабрь"]),Typograf.data("weekday",["понедельник","вторник","среда","четверг","пятница","суббота","воскресенье"]),Typograf.rule({title:"Удаление двойной пунктуации",name:"delDoublePunctiation",sortIndex:580,func:function(e){return e.replace(/(,|:|;|\?){2,}/g,"$1")}}),Typograf.rule({title:"!! → !",name:"exclamation",sortIndex:1150,func:function(e){return e.replace(/(^|[^!])\!{2}($|[^!])/,"$1!$2").replace(/(^|[^!])\!{4}?($|[^!])/,"$1!!!$2")}}),Typograf.rule({title:"!? → ?!",name:"exclamationQuestion",sortIndex:1140,func:function(e){var r=new RegExp("(^|[^!])!\\?([^?]|$)","g");return e.replace(r,"$1?!$2")}}),Typograf.rule({title:"Расстановка кавычек",name:"quot",sortIndex:700,func:function(e,r){var n="[\\w\\dа-яёА-ЯЁ]",t=r.lquot,a=r.rquot,u=r.lquot2,i=r.rquot2,o="(?:^|<\\w.*?>)*",l="(?:…|"+n+"|\\n)",c="(?:"+[n,"[)!?.:;#*]"].join("|")+")*",s='(«|»|„|“|”|‘|’|&quot;|")',p='(»|“|&quot;|")',g=new RegExp("("+o+")?"+s+"("+o+l+o+")","g"),f=new RegExp("("+o+c+o+")"+p+"("+c+")","g"),d=new RegExp("("+t+")(.*?)"+t+"(.*?)("+a+")","g"),$=new RegExp("("+t+")(.*?)"+a+"(.*?)("+a+")","g"),m=new RegExp(t+t,"g"),h=new RegExp(a+a,"g");return e=e.replace(g,"$1"+t+"$3").replace(f,"$1"+a+"$3"),e=t===u&&a===i?e.replace(m,"$1$2"+t+"$3$4").replace(h,"$1$2"+a+"$3$4"):e.replace(d,"$1$2"+u+"$3$4").replace($,"$1$2"+i+"$3$4")},settings:{lquot:"«",rquot:"»",lquot2:"„",rquot2:"“"}}),function(){var e="(^| |\\n)",r="( |,|\\.|\\?|\\:|\\!|$)";Typograf.rule({title:"Дефис перед то, либо, нибудь, ка, де, кась",name:"dash/to",sortIndex:30,func:function(e){var n=new RegExp("( | ?- ?)(то|либо|нибудь|ка|де|кась)"+r,"g");return e.replace(n,"-$2$3")}}),Typograf.rule({title:"Дефис между из-за",name:"dash/izza",sortIndex:33,func:function(n){var t=new RegExp(e+"(И|и)з за"+r,"g");return n.replace(t,"$1$2з-за$3")}}),Typograf.rule({title:"Дефис между из-под",name:"dash/izpod",sortIndex:35,func:function(n){var t=new RegExp(e+"(И|и)з под"+r,"g");return n.replace(t,"$1$2з-под$3")}}),Typograf.rule({title:"Дефис после кое и кой",name:"dash/koe",sortIndex:38,func:function(n){var t=new RegExp(e+"(К|к)ое\\s([а-яё]{3,})"+r,"g");n=n.replace(t,"$1$2ое-$3$4");var a=new RegExp(e+"(К|к)ой\\s([а-я]{3,})"+r,"g");return n.replace(a,"$1$2ой-$3$4")}}),Typograf.rule({title:"Дефис между верно-таки и т.д.",name:"dash/taki",sortIndex:39,func:function(e){var n=new RegExp("(верно|довольно|опять|прямо|так|всё|действительно|неужели)\\s(таки)"+r,"g");return e.replace(n,"$1-$2$3")}})}(),Typograf.rule({title:"Дефис на тире",name:"dash/main",sortIndex:620,func:function(e){var r=new RegExp("(\\s| )(-|—)(\\s|\\n)","g");return e.replace(r," —$3").replace(/(X|I|V)(?: |\u00A0)?(-|—)(?: |\u00A0)?(X|I|V)/g,"$1—$3")},settings:{dash:"—",dashInterval:"—"}}),Typograf.rule({title:"Дефис между месяцами",name:"dash/month",sortIndex:610,func:function(e){var r="("+this.data.month.join("|")+")",n=new RegExp(r+" ?(-|—) ?"+r,"gi");return e.replace(n,"$1"+this.setting("dash/main","dashInterval")+"$3")}}),Typograf.rule({title:"Дефис между днями недели",name:"dash/weekday",sortIndex:600,func:function(e){var r="("+this.data.weekday.join("|")+")",n=new RegExp(r+" ?(-|—) ?"+r,"gi");return e.replace(n,"$1"+this.setting("dash/main","dashInterval")+"$3")}}),Typograf.rule({title:"Преобразование дат к виду DD.MM.YYYY",name:"date/main",sortIndex:1300,func:function(e){var r="(-|\\.|\\/)",n="(-|\\/)",t=new RegExp("(^|\\D)(\\d{4})"+r+"(\\d{2})"+r+"(\\d{2})(\\D|$)","gi"),a=new RegExp("(^|\\D)(\\d{2})"+n+"(\\d{2})"+n+"(\\d{4})(\\D|$)","gi");return e.replace(t,"$1$6.$4.$2$7").replace(a,"$1$4.$2.$6$7")}}),Typograf.rule({title:"Замена перевода строки на <br/>",name:"html/nbr",sortIndex:710,func:function(e){return e.replace(/\n/g,"<br/>")},enabled:!1}),Typograf.rule({title:"Расстановка <p> и <br/>",name:"html/pbr",sortIndex:700,func:function(e){return-1===e.search(/\n/)?e="<p>"+e+"</p>":(e="<p>"+e.replace(/\n\n/g,"</p>\n<p>")+"</p>",e=e.replace(/([^>])\n/g,"$1<br/>\n")),e},enabled:!1}),Typograf.rule({title:"Удаление HTML-тегов",name:"html/stripTags",sortIndex:5,func:function(e){return e.replace(/<\/?[^>]+>/g,"")},enabled:!1}),Typograf.rule({title:"Расстановка ссылок",name:"html/url",sortIndex:200,func:function(e){var r="(http|https|ftp|telnet|news|gopher|file|wais)://",n="([a-zA-Z0-9/\\n+-=%&:_.~?]+[a-zA-Z0-9#+]*)",t=new RegExp(r+n,"g");return e.replace(t,function(e,r,n){var t=n,a=r+"://"+n,u='<a href="'+a+'">';return"http"===r?(t=t.replace(/^www\./,"").replace(/^([^\/]+)\/$/,"$1"),u+t+"</a>"):u+a+"</a>"})}}),Typograf.rule({title:"$100 → 100 $",name:"money/dollar",sortIndex:1140,func:function(e){var r=new RegExp("(^|[\\D]{2,})\\$ ?([\\d.,]+)","g"),n=new RegExp("(^|[\\D])([\\d.,]+) ?\\$"),t="$1$2 $";return e.replace(r,t).replace(n,t)}}),Typograf.rule({title:"€100 → 100 €",name:"money/euro",sortIndex:1140,func:function(e){var r=new RegExp("(^|[\\D]{2,})€ ?([\\d.]+)","g"),n=new RegExp("(^|[\\D])([\\d.,]+) ?€"),t="$1$2 €";return e.replace(r,t).replace(n,t)}}),Typograf.rule({title:"Неразрывный пробел после № и §",name:"nbsp/afterNum",sortIndex:610,func:function(e){return e.replace(/№ ?(\d)/g,"№ $1").replace(/§ ?(\d|I|V|X)/g,"§ $1")}}),Typograf.rule({title:"Неразрывный пробел после короткого слова",name:"nbsp/afterShortWord",sortIndex:590,func:function(e,r){var n=r.lengthShortWord,t=new RegExp("( [а-яёА-ЯЁ\\w]{1,"+n+"}) ","g");return n>0?e.replace(t,"$1 "):e},settings:{lengthShortWord:2}}),Typograf.rule({title:"Неразрывный пробел перед ли, ль, же, бы, б",name:"nbsp/beforeParticle",sortIndex:570,func:function(e){return e.replace(/ (ли|ль|же|ж|бы|б)([^а-яёА-ЯЁ])/g," $1$2")}}),Typograf.rule({title:"Неразрывный пробел перед последним коротким словом в предложении",name:"nbsp/beforeShortLastWord",sortIndex:620,func:function(e,r){var n=r.lengthLastWord,t=new RegExp(" ([а-яёА-ЯЁ\\w]{1,"+n+"})(\\.|\\?|:|!|,)","g");return n>0?e.replace(t," $1$2"):e},settings:{lengthLastWord:3}}),Typograf.rule({title:"Расстановка запятых и неразрывного пробела перед а и но",name:"nbsp/but",sortIndex:1110,func:function(e){var r=new RegExp("([,])?( | |\n)(а|но)( | |\n)","g");return e.replace(r,",$2$3$4")}}),Typograf.rule({title:"m2 → м², m3 → м³ и неразрывный пробел",name:"nbsp/m",sortIndex:1030,func:function(e){var r="(км|м|дм|см|мм)",n=new RegExp("(^|\\D)(\\d+) ?"+r+"2(\\D|$)","g"),t=new RegExp("(^|\\D)(\\d+) ?"+r+"3(\\D|$)","g");return e=e.replace(n,"$1$2 $3²$4"),e.replace(t,"$1$2 $3³$4")}}),Typograf.rule({title:"Неразрывный пробел после OOO или ОАО",name:"nbsp/ooo",sortIndex:1100,func:function(e){return e.replace(/(ООО|ОАО) /g,"$1 ")}}),Typograf.rule({title:"Неразрывный пробел после XXXX",name:"nbsp/xxxx",sortIndex:1060,func:function(e){return e.replace(/(^|\D)(\d{4}) ?г( |,|;|\.|\n|$)/g,"$1$2 г$3")}}),Typograf.rule({title:"г.г. → гг. и неразрывный пробел",name:"nbsp/yy",sortIndex:1080,func:function(e){return e.replace(/(^|\d) ?г\. ?г\./g,"$1 гг.")}}),Typograf.rule({title:"Пробел после знаков пунктуации",name:"space/afterPunctuation",sortIndex:560,func:function(e){return e.replace(/(\!|;|\?)([^ \n\t\!;\?])/g,"$1 $2").replace(/(\D)(,|\:)([^ \/\d\n\t\!;,\?\.\:])/g,"$1$2 $3")}}),Typograf.rule({title:"Удаление пробела перед %",name:"space/delBeforePercent",sortIndex:600,func:function(e){return e.replace(/(\d)( |\u00A0)%/g,"$1%")}}),Typograf.rule({title:"Удаление пробелов перед знаками пунктуации",name:"space/delBeforePunctuation",sortIndex:550,func:function(e){return e.replace(/ (\!|;|,|\?|\.|\:)/g,"$1").replace(/\( /g,"(").replace(/([^ ])\(/g,"$1 (").replace(/ \)/g,")").replace(/\)([^\!;,\?\.\:])/g,") $1")}}),Typograf.rule({title:"Удаление повторяющихся переносов строки (не более двух)",name:"space/delRepeatN",sortIndex:545,func:function(e){return e.replace(/\n{3,}/g,"\n\n")}}),Typograf.rule({title:"Удаление повторяющихся пробелов",name:"space/delRepeatSpace",sortIndex:540,func:function(e){return e.replace(/( |\t){2,}/g,"$1")}}),Typograf.rule({title:"Удаление пробелов в конце строк",name:"space/delTrailingBlanks",sortIndex:505,func:function(e){return e.replace(/( |\t)+\n/g,"\n")}}),Typograf.rule({title:"Замена табов на пробелы",name:"space/replaceTab",sortIndex:510,func:function(e){return e.replace(/\t/g," ")}}),Typograf.rule({title:"Удаление пробелов в начале и в конце текста",name:"space/trim",sortIndex:530,func:function(e){return e.trim()}}),Typograf.rule({title:"-> → →, <- → ←",name:"sym/arrow",sortIndex:1130,func:function(e){return e.replace(/(^|[^-])->(?!>)/g,"$1→").replace(/(^|[^<])<-(?!-)/g,"$1←")}}),Typograf.rule({title:"Удаление лишних точек и пробелов в вв.",name:"sym/cc",sortIndex:1090,func:function(e){return e=e.replace(/(^|\d|V|I|X) ?в(в)?( |,|;|\n|$)/g,"$1 в$2.$3"),e.replace(/(^|\d|[IVX]) ?в\.? ?в\./g,"$1 вв.")}}),Typograf.rule({title:"Добавление ° к C и F",name:"sym/cf",sortIndex:1020,func:function(e){var r=new RegExp('(\\d+)( | )?(C|F)([\\W \\.,:\\!\\?"\\]\\)]|$)',"g");return e.replace(r,"$1 °$3$4")}}),Typograf.rule({title:"(c) → ©, (tm) → ©, (r) → ™",name:"sym/copy",sortIndex:10,func:function(e){return e.replace(/\(r\)/gi,"®").replace(/\((c|с)\)/gi,"©").replace(/\(tm\)/gi,"™")}}),Typograf.rule({title:"1/2 → ½, 1/4 → ¼, 3/3 → ¾",name:"sym/fraction",sortIndex:1120,func: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")}}),Typograf.rule({title:"... → …",name:"sym/hellip",sortIndex:20,func:function(e){return e.replace(/(^|[^.])\.{3,4}([^.]|$)/g,"$1…$2")}}),Typograf.rule({title:"+- → ±",name:"sym/plusMinus",sortIndex:1010,func:function(e){var r=new RegExp("(^| |\\>| )\\+-(\\d)","g");return e.replace(r,"$1±$2").replace(/(^\s*)\+-(\s*$)/g,"$1±$2")}}),Typograf.rule({title:"x → ×",name:"sym/times",sortIndex:1050,func:function(e){return e.replace(/(\d) ?(x|х) ?(\d)/g,"$1×$3")}}),Typograf._sortRules(),Typograf._needSortRules=!0;
{
"name": "typograf",
"description": "The client and server typographer",
"version": "1.2.3",
"version": "1.2.4",
"author": {

@@ -20,5 +20,8 @@ "name": "Denis Seleznev",

"engines": {
"node": "*"
"node": ">= 0.10"
},
"devDependencies": {
"mocha": "2.0.x",
"chai": "1.x",
"istanbul": "0.3.x",
"gulp": "~3.8.5",

@@ -31,5 +34,12 @@ "gulp-concat": "~2.2.0",

"gulp-uglify": "~0.2.1",
"jscs": "^1.5.2",
"jshint": "^2.5.1"
"jscs": "^1.7.x",
"jshint": "2.x"
},
"scripts": {
"test": "npm run-script jshint && npm run-script check-style && npm run-script unit-test-coverage",
"jshint": "./node_modules/.bin/jshint .",
"unit-test": "./node_modules/.bin/mocha -u bdd -R spec --recursive test",
"unit-test-coverage": "./node_modules/.bin/istanbul cover ./node_modules/mocha/bin/_mocha -- -u bdd -R spec --recursive test",
"check-style": "./node_modules/.bin/jscs ."
}
}

@@ -0,1 +1,3 @@

[![Build Status](https://travis-ci.org/hcodes/typograf.png?branch=master)](https://travis-ci.org/hcodes/typograf)
Типограф на JavaScript

@@ -2,0 +4,0 @@ ======================

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc