Comparing version 1.2.3 to 1.2.4
{ | ||
"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=[["\\ ","\\&\\#160;"," "],["\\¡","\\&\\#161;","¡"],["\\¢","\\&\\#162;","¢"],["\\£","\\&\\#163;","£"],["\\¤","\\&\\#164;","¤"],["\\¥","\\&\\#165;","¥"],["\\¦","\\&\\#166;","¦"],["\\§","\\&\\#167;","§"],["\\¨","\\&\\#168;","¨"],["\\©","\\&\\#169;","©"],["\\ª","\\&\\#170;","ª"],["\\«","\\&\\#171;","«"],["\\¬","\\&\\#172;","¬"],["\\­","\\&\\#173;",""],["\\®","\\&\\#174;","®"],["\\¯","\\&\\#175;","¯"],["\\°","\\&\\#176;","°"],["\\±","\\&\\#177;","±"],["\\²","\\&\\#178;","²"],["\\³","\\&\\#179;","³"],["\\´","\\&\\#180;","´"],["\\µ","\\&\\#181;","µ"],["\\¶","\\&\\#182;","¶"],["\\·","\\&\\#183;","·"],["\\¸","\\&\\#184;","¸"],["\\¹","\\&\\#185;","¹"],["\\º","\\&\\#186;","º"],["\\»","\\&\\#187;","»"],["\\¼","\\&\\#188;","¼"],["\\½","\\&\\#189;","½"],["\\¾","\\&\\#190;","¾"],["\\¿","\\&\\#191;","¿"],["\\À","\\&\\#192;","À"],["\\Á","\\&\\#193;","Á"],["\\Â","\\&\\#194;","Â"],["\\Ã","\\&\\#195;","Ã"],["\\Ä","\\&\\#196;","Ä"],["\\Å","\\&\\#197;","Å"],["\\Æ","\\&\\#198;","Æ"],["\\Ç","\\&\\#199;","Ç"],["\\È","\\&\\#200;","È"],["\\É","\\&\\#201;","É"],["\\Ê","\\&\\#202;","Ê"],["\\Ë","\\&\\#203;","Ë"],["\\Ì","\\&\\#204;","Ì"],["\\Í","\\&\\#205;","Í"],["\\Î","\\&\\#206;","Î"],["\\Ï","\\&\\#207;","Ï"],["\\Ð","\\&\\#208;","Ð"],["\\Ñ","\\&\\#209;","Ñ"],["\\Ò","\\&\\#210;","Ò"],["\\Ó","\\&\\#211;","Ó"],["\\Ô","\\&\\#212;","Ô"],["\\Õ","\\&\\#213;","Õ"],["\\Ö","\\&\\#214;","Ö"],["\\×","\\&\\#215;","×"],["\\Ø","\\&\\#216;","Ø"],["\\Ù","\\&\\#217;","Ù"],["\\Ú","\\&\\#218;","Ú"],["\\Û","\\&\\#219;","Û"],["\\Ü","\\&\\#220;","Ü"],["\\Ý","\\&\\#221;","Ý"],["\\Þ","\\&\\#222;","Þ"],["\\ß","\\&\\#223;","ß"],["\\à","\\&\\#224;","à"],["\\á","\\&\\#225;","á"],["\\â","\\&\\#226;","â"],["\\ã","\\&\\#227;","ã"],["\\ä","\\&\\#228;","ä"],["\\å","\\&\\#229;","å"],["\\æ","\\&\\#230;","æ"],["\\ç","\\&\\#231;","ç"],["\\è","\\&\\#232;","è"],["\\é","\\&\\#233;","é"],["\\ê","\\&\\#234;","ê"],["\\ë","\\&\\#235;","ë"],["\\ì","\\&\\#236;","ì"],["\\í","\\&\\#237;","í"],["\\î","\\&\\#238;","î"],["\\ï","\\&\\#239;","ï"],["\\ð","\\&\\#240;","ð"],["\\ñ","\\&\\#241;","ñ"],["\\ò","\\&\\#242;","ò"],["\\ó","\\&\\#243;","ó"],["\\ô","\\&\\#244;","ô"],["\\õ","\\&\\#245;","õ"],["\\ö","\\&\\#246;","ö"],["\\÷","\\&\\#247;","÷"],["\\ø","\\&\\#248;","ø"],["\\ù","\\&\\#249;","ù"],["\\ú","\\&\\#250;","ú"],["\\û","\\&\\#251;","û"],["\\ü","\\&\\#252;","ü"],["\\ý","\\&\\#253;","ý"],["\\þ","\\&\\#254;","þ"],["\\ÿ","\\&\\#255;","ÿ"],["\\ƒ","\\&\\#402;","ƒ"],["\\Α","\\&\\#913;","Α"],["\\Β","\\&\\#914;","Β"],["\\Γ","\\&\\#915;","Γ"],["\\Δ","\\&\\#916;","Δ"],["\\Ε","\\&\\#917;","Ε"],["\\Ζ","\\&\\#918;","Ζ"],["\\Η","\\&\\#919;","Η"],["\\Θ","\\&\\#920;","Θ"],["\\Ι","\\&\\#921;","Ι"],["\\Κ","\\&\\#922;","Κ"],["\\Λ","\\&\\#923;","Λ"],["\\Μ","\\&\\#924;","Μ"],["\\Ν","\\&\\#925;","Ν"],["\\Ξ","\\&\\#926;","Ξ"],["\\Ο","\\&\\#927;","Ο"],["\\Π","\\&\\#928;","Π"],["\\Ρ","\\&\\#929;","Ρ"],["\\Σ","\\&\\#931;","Σ"],["\\Τ","\\&\\#932;","Τ"],["\\Υ","\\&\\#933;","Υ"],["\\Φ","\\&\\#934;","Φ"],["\\Χ","\\&\\#935;","Χ"],["\\Ψ","\\&\\#936;","Ψ"],["\\Ω","\\&\\#937;","Ω"],["\\α","\\&\\#945;","α"],["\\β","\\&\\#946;","β"],["\\γ","\\&\\#947;","γ"],["\\δ","\\&\\#948;","δ"],["\\ε","\\&\\#949;","ε"],["\\ζ","\\&\\#950;","ζ"],["\\η","\\&\\#951;","η"],["\\θ","\\&\\#952;","θ"],["\\ι","\\&\\#953;","ι"],["\\κ","\\&\\#954;","κ"],["\\λ","\\&\\#955;","λ"],["\\μ","\\&\\#956;","μ"],["\\ν","\\&\\#957;","ν"],["\\ξ","\\&\\#958;","ξ"],["\\ο","\\&\\#959;","ο"],["\\π","\\&\\#960;","π"],["\\ρ","\\&\\#961;","ρ"],["\\ς","\\&\\#962;","ς"],["\\σ","\\&\\#963;","σ"],["\\τ","\\&\\#964;","τ"],["\\υ","\\&\\#965;","υ"],["\\φ","\\&\\#966;","φ"],["\\χ","\\&\\#967;","χ"],["\\ψ","\\&\\#968;","ψ"],["\\ω","\\&\\#969;","ω"],["\\ϑ","\\&\\#977;","ϑ"],["\\ϒ","\\&\\#978;","ϒ"],["\\ϖ","\\&\\#982;","ϖ"],["\\•","\\&\\#8226;","•"],["\\…","\\&\\#8230;","…"],["\\′","\\&\\#8242;","′"],["\\″","\\&\\#8243;","″"],["\\‾","\\&\\#8254;","‾"],["\\⁄","\\&\\#8260;","⁄"],["\\℘","\\&\\#8472;","℘"],["\\ℑ","\\&\\#8465;","ℑ"],["\\ℜ","\\&\\#8476;","ℜ"],["\\™","\\&\\#8482;","™"],["\\ℵ","\\&\\#8501;","ℵ"],["\\←","\\&\\#8592;","←"],["\\↑","\\&\\#8593;","↑"],["\\→","\\&\\#8594;","→"],["\\↓","\\&\\#8595;","↓"],["\\↔","\\&\\#8596;","↔"],["\\↵","\\&\\#8629;","↵"],["\\⇐","\\&\\#8656;","⇐"],["\\⇑","\\&\\#8657;","⇑"],["\\⇒","\\&\\#8658;","⇒"],["\\⇓","\\&\\#8659;","⇓"],["\\⇔","\\&\\#8660;","⇔"],["\\∀","\\&\\#8704;","∀"],["\\∂","\\&\\#8706;","∂"],["\\∃","\\&\\#8707;","∃"],["\\∅","\\&\\#8709;","∅"],["\\∇","\\&\\#8711;","∇"],["\\∈","\\&\\#8712;","∈"],["\\∉","\\&\\#8713;","∉"],["\\∋","\\&\\#8715;","∋"],["\\∏","\\&\\#8719;","∏"],["\\∑","\\&\\#8721;","∑"],["\\−","\\&\\#8722;","−"],["\\∗","\\&\\#8727;","∗"],["\\√","\\&\\#8730;","√"],["\\∝","\\&\\#8733;","∝"],["\\∞","\\&\\#8734;","∞"],["\\∠","\\&\\#8736;","∠"],["\\∧","\\&\\#8743;","∧"],["\\∨","\\&\\#8744;","∨"],["\\∩","\\&\\#8745;","∩"],["\\∪","\\&\\#8746;","∪"],["\\∫","\\&\\#8747;","∫"],["\\∴","\\&\\#8756;","∴"],["\\∼","\\&\\#8764;","∼"],["\\≅","\\&\\#8773;","≅"],["\\≈","\\&\\#8776;","≈"],["\\≠","\\&\\#8800;","≠"],["\\≡","\\&\\#8801;","≡"],["\\≤","\\&\\#8804;","≤"],["\\≥","\\&\\#8805;","≥"],["\\⊂","\\&\\#8834;","⊂"],["\\⊃","\\&\\#8835;","⊃"],["\\⊄","\\&\\#8836;","⊄"],["\\⊆","\\&\\#8838;","⊆"],["\\⊇","\\&\\#8839;","⊇"],["\\⊕","\\&\\#8853;","⊕"],["\\⊗","\\&\\#8855;","⊗"],["\\⊥","\\&\\#8869;","⊥"],["\\⋅","\\&\\#8901;","⋅"],["\\⌈","\\&\\#8968;","⌈"],["\\⌉","\\&\\#8969;","⌉"],["\\⌊","\\&\\#8970;","⌊"],["\\⌋","\\&\\#8971;","⌋"],["\\⟨","\\&\\#9001;","〈"],["\\⟩","\\&\\#9002;","〉"],["\\♠","\\&\\#9824;","♠"],["\\♣","\\&\\#9827;","♣"],["\\♥","\\&\\#9829;","♥"],["\\♦","\\&\\#9830;","♦"],["\\◊","\\&\\#9674;","◊"],["\\Œ","\\&\\#338;","Œ"],["\\œ","\\&\\#339;","œ"],["\\Š","\\&\\#352;","Š"],["\\š","\\&\\#353;","š"],["\\Ÿ","\\&\\#376;","Ÿ"],["\\ˆ","\\&\\#710;","ˆ"],["\\˜","\\&\\#732;","˜"],["\\ ","\\&\\#8194;"," "],["\\ ","\\&\\#8195;"," "],["\\ ","\\&\\#8201;"," "],["\\‌","\\&\\#8204;",""],["\\‍","\\&\\#8205;",""],["\\‎","\\&\\#8206;",""],["\\‏","\\&\\#8207;",""],["\\–","\\&\\#8211;","–"],["\\—","\\&\\#8212;","—"],["\\‘","\\&\\#8216;","‘"],["\\’","\\&\\#8217;","’"],["\\‚","\\&\\#8218;","‚"],["\\“","\\&\\#8220;","“"],["\\”","\\&\\#8221;","”"],["\\„","\\&\\#8222;","„"],["\\†","\\&\\#8224;","†"],["\\‡","\\&\\#8225;","‡"],["\\‰","\\&\\#8240;","‰"],["\\‹","\\&\\#8249;","‹"],["\\›","\\&\\#8250;","›"],["\\€","\\&\\#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='(«|»|„|“|”|‘|’|"|")',p='(»|“|"|")',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=[["\\ ","\\&\\#160;"," "],["\\¡","\\&\\#161;","¡"],["\\¢","\\&\\#162;","¢"],["\\£","\\&\\#163;","£"],["\\¤","\\&\\#164;","¤"],["\\¥","\\&\\#165;","¥"],["\\¦","\\&\\#166;","¦"],["\\§","\\&\\#167;","§"],["\\¨","\\&\\#168;","¨"],["\\©","\\&\\#169;","©"],["\\ª","\\&\\#170;","ª"],["\\«","\\&\\#171;","«"],["\\¬","\\&\\#172;","¬"],["\\­","\\&\\#173;",""],["\\®","\\&\\#174;","®"],["\\¯","\\&\\#175;","¯"],["\\°","\\&\\#176;","°"],["\\±","\\&\\#177;","±"],["\\²","\\&\\#178;","²"],["\\³","\\&\\#179;","³"],["\\´","\\&\\#180;","´"],["\\µ","\\&\\#181;","µ"],["\\¶","\\&\\#182;","¶"],["\\·","\\&\\#183;","·"],["\\¸","\\&\\#184;","¸"],["\\¹","\\&\\#185;","¹"],["\\º","\\&\\#186;","º"],["\\»","\\&\\#187;","»"],["\\¼","\\&\\#188;","¼"],["\\½","\\&\\#189;","½"],["\\¾","\\&\\#190;","¾"],["\\¿","\\&\\#191;","¿"],["\\À","\\&\\#192;","À"],["\\Á","\\&\\#193;","Á"],["\\Â","\\&\\#194;","Â"],["\\Ã","\\&\\#195;","Ã"],["\\Ä","\\&\\#196;","Ä"],["\\Å","\\&\\#197;","Å"],["\\Æ","\\&\\#198;","Æ"],["\\Ç","\\&\\#199;","Ç"],["\\È","\\&\\#200;","È"],["\\É","\\&\\#201;","É"],["\\Ê","\\&\\#202;","Ê"],["\\Ë","\\&\\#203;","Ë"],["\\Ì","\\&\\#204;","Ì"],["\\Í","\\&\\#205;","Í"],["\\Î","\\&\\#206;","Î"],["\\Ï","\\&\\#207;","Ï"],["\\Ð","\\&\\#208;","Ð"],["\\Ñ","\\&\\#209;","Ñ"],["\\Ò","\\&\\#210;","Ò"],["\\Ó","\\&\\#211;","Ó"],["\\Ô","\\&\\#212;","Ô"],["\\Õ","\\&\\#213;","Õ"],["\\Ö","\\&\\#214;","Ö"],["\\×","\\&\\#215;","×"],["\\Ø","\\&\\#216;","Ø"],["\\Ù","\\&\\#217;","Ù"],["\\Ú","\\&\\#218;","Ú"],["\\Û","\\&\\#219;","Û"],["\\Ü","\\&\\#220;","Ü"],["\\Ý","\\&\\#221;","Ý"],["\\Þ","\\&\\#222;","Þ"],["\\ß","\\&\\#223;","ß"],["\\à","\\&\\#224;","à"],["\\á","\\&\\#225;","á"],["\\â","\\&\\#226;","â"],["\\ã","\\&\\#227;","ã"],["\\ä","\\&\\#228;","ä"],["\\å","\\&\\#229;","å"],["\\æ","\\&\\#230;","æ"],["\\ç","\\&\\#231;","ç"],["\\è","\\&\\#232;","è"],["\\é","\\&\\#233;","é"],["\\ê","\\&\\#234;","ê"],["\\ë","\\&\\#235;","ë"],["\\ì","\\&\\#236;","ì"],["\\í","\\&\\#237;","í"],["\\î","\\&\\#238;","î"],["\\ï","\\&\\#239;","ï"],["\\ð","\\&\\#240;","ð"],["\\ñ","\\&\\#241;","ñ"],["\\ò","\\&\\#242;","ò"],["\\ó","\\&\\#243;","ó"],["\\ô","\\&\\#244;","ô"],["\\õ","\\&\\#245;","õ"],["\\ö","\\&\\#246;","ö"],["\\÷","\\&\\#247;","÷"],["\\ø","\\&\\#248;","ø"],["\\ù","\\&\\#249;","ù"],["\\ú","\\&\\#250;","ú"],["\\û","\\&\\#251;","û"],["\\ü","\\&\\#252;","ü"],["\\ý","\\&\\#253;","ý"],["\\þ","\\&\\#254;","þ"],["\\ÿ","\\&\\#255;","ÿ"],["\\ƒ","\\&\\#402;","ƒ"],["\\Α","\\&\\#913;","Α"],["\\Β","\\&\\#914;","Β"],["\\Γ","\\&\\#915;","Γ"],["\\Δ","\\&\\#916;","Δ"],["\\Ε","\\&\\#917;","Ε"],["\\Ζ","\\&\\#918;","Ζ"],["\\Η","\\&\\#919;","Η"],["\\Θ","\\&\\#920;","Θ"],["\\Ι","\\&\\#921;","Ι"],["\\Κ","\\&\\#922;","Κ"],["\\Λ","\\&\\#923;","Λ"],["\\Μ","\\&\\#924;","Μ"],["\\Ν","\\&\\#925;","Ν"],["\\Ξ","\\&\\#926;","Ξ"],["\\Ο","\\&\\#927;","Ο"],["\\Π","\\&\\#928;","Π"],["\\Ρ","\\&\\#929;","Ρ"],["\\Σ","\\&\\#931;","Σ"],["\\Τ","\\&\\#932;","Τ"],["\\Υ","\\&\\#933;","Υ"],["\\Φ","\\&\\#934;","Φ"],["\\Χ","\\&\\#935;","Χ"],["\\Ψ","\\&\\#936;","Ψ"],["\\Ω","\\&\\#937;","Ω"],["\\α","\\&\\#945;","α"],["\\β","\\&\\#946;","β"],["\\γ","\\&\\#947;","γ"],["\\δ","\\&\\#948;","δ"],["\\ε","\\&\\#949;","ε"],["\\ζ","\\&\\#950;","ζ"],["\\η","\\&\\#951;","η"],["\\θ","\\&\\#952;","θ"],["\\ι","\\&\\#953;","ι"],["\\κ","\\&\\#954;","κ"],["\\λ","\\&\\#955;","λ"],["\\μ","\\&\\#956;","μ"],["\\ν","\\&\\#957;","ν"],["\\ξ","\\&\\#958;","ξ"],["\\ο","\\&\\#959;","ο"],["\\π","\\&\\#960;","π"],["\\ρ","\\&\\#961;","ρ"],["\\ς","\\&\\#962;","ς"],["\\σ","\\&\\#963;","σ"],["\\τ","\\&\\#964;","τ"],["\\υ","\\&\\#965;","υ"],["\\φ","\\&\\#966;","φ"],["\\χ","\\&\\#967;","χ"],["\\ψ","\\&\\#968;","ψ"],["\\ω","\\&\\#969;","ω"],["\\ϑ","\\&\\#977;","ϑ"],["\\ϒ","\\&\\#978;","ϒ"],["\\ϖ","\\&\\#982;","ϖ"],["\\•","\\&\\#8226;","•"],["\\…","\\&\\#8230;","…"],["\\′","\\&\\#8242;","′"],["\\″","\\&\\#8243;","″"],["\\‾","\\&\\#8254;","‾"],["\\⁄","\\&\\#8260;","⁄"],["\\℘","\\&\\#8472;","℘"],["\\ℑ","\\&\\#8465;","ℑ"],["\\ℜ","\\&\\#8476;","ℜ"],["\\™","\\&\\#8482;","™"],["\\ℵ","\\&\\#8501;","ℵ"],["\\←","\\&\\#8592;","←"],["\\↑","\\&\\#8593;","↑"],["\\→","\\&\\#8594;","→"],["\\↓","\\&\\#8595;","↓"],["\\↔","\\&\\#8596;","↔"],["\\↵","\\&\\#8629;","↵"],["\\⇐","\\&\\#8656;","⇐"],["\\⇑","\\&\\#8657;","⇑"],["\\⇒","\\&\\#8658;","⇒"],["\\⇓","\\&\\#8659;","⇓"],["\\⇔","\\&\\#8660;","⇔"],["\\∀","\\&\\#8704;","∀"],["\\∂","\\&\\#8706;","∂"],["\\∃","\\&\\#8707;","∃"],["\\∅","\\&\\#8709;","∅"],["\\∇","\\&\\#8711;","∇"],["\\∈","\\&\\#8712;","∈"],["\\∉","\\&\\#8713;","∉"],["\\∋","\\&\\#8715;","∋"],["\\∏","\\&\\#8719;","∏"],["\\∑","\\&\\#8721;","∑"],["\\−","\\&\\#8722;","−"],["\\∗","\\&\\#8727;","∗"],["\\√","\\&\\#8730;","√"],["\\∝","\\&\\#8733;","∝"],["\\∞","\\&\\#8734;","∞"],["\\∠","\\&\\#8736;","∠"],["\\∧","\\&\\#8743;","∧"],["\\∨","\\&\\#8744;","∨"],["\\∩","\\&\\#8745;","∩"],["\\∪","\\&\\#8746;","∪"],["\\∫","\\&\\#8747;","∫"],["\\∴","\\&\\#8756;","∴"],["\\∼","\\&\\#8764;","∼"],["\\≅","\\&\\#8773;","≅"],["\\≈","\\&\\#8776;","≈"],["\\≠","\\&\\#8800;","≠"],["\\≡","\\&\\#8801;","≡"],["\\≤","\\&\\#8804;","≤"],["\\≥","\\&\\#8805;","≥"],["\\⊂","\\&\\#8834;","⊂"],["\\⊃","\\&\\#8835;","⊃"],["\\⊄","\\&\\#8836;","⊄"],["\\⊆","\\&\\#8838;","⊆"],["\\⊇","\\&\\#8839;","⊇"],["\\⊕","\\&\\#8853;","⊕"],["\\⊗","\\&\\#8855;","⊗"],["\\⊥","\\&\\#8869;","⊥"],["\\⋅","\\&\\#8901;","⋅"],["\\⌈","\\&\\#8968;","⌈"],["\\⌉","\\&\\#8969;","⌉"],["\\⌊","\\&\\#8970;","⌊"],["\\⌋","\\&\\#8971;","⌋"],["\\⟨","\\&\\#9001;","〈"],["\\⟩","\\&\\#9002;","〉"],["\\♠","\\&\\#9824;","♠"],["\\♣","\\&\\#9827;","♣"],["\\♥","\\&\\#9829;","♥"],["\\♦","\\&\\#9830;","♦"],["\\◊","\\&\\#9674;","◊"],["\\Œ","\\&\\#338;","Œ"],["\\œ","\\&\\#339;","œ"],["\\Š","\\&\\#352;","Š"],["\\š","\\&\\#353;","š"],["\\Ÿ","\\&\\#376;","Ÿ"],["\\ˆ","\\&\\#710;","ˆ"],["\\˜","\\&\\#732;","˜"],["\\ ","\\&\\#8194;"," "],["\\ ","\\&\\#8195;"," "],["\\ ","\\&\\#8201;"," "],["\\‌","\\&\\#8204;",""],["\\‍","\\&\\#8205;",""],["\\‎","\\&\\#8206;",""],["\\‏","\\&\\#8207;",""],["\\–","\\&\\#8211;","–"],["\\—","\\&\\#8212;","—"],["\\‘","\\&\\#8216;","‘"],["\\’","\\&\\#8217;","’"],["\\‚","\\&\\#8218;","‚"],["\\“","\\&\\#8220;","“"],["\\”","\\&\\#8221;","”"],["\\„","\\&\\#8222;","„"],["\\†","\\&\\#8224;","†"],["\\‡","\\&\\#8225;","‡"],["\\‰","\\&\\#8240;","‰"],["\\‹","\\&\\#8249;","‹"],["\\›","\\&\\#8250;","›"],["\\€","\\&\\#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='(«|»|„|“|”|‘|’|"|")',p='(»|“|"|")',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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Mixed license
License(Experimental) Package contains multiple licenses.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1197908
133
22439
106
12
2
1