UNPKG

typographie

Version:

Library for preparation of russian texts to web publication

1,478 lines (1,306 loc) 147 kB
(function webpackUniversalModuleDefinition(root, factory) { if(typeof exports === 'object' && typeof module === 'object') module.exports = factory(); else if(typeof define === 'function' && define.amd) define("Typographie", [], factory); else if(typeof exports === 'object') exports["Typographie"] = factory(); else root["Typographie"] = factory(); })(this, function() { return /******/ (function(modules) { // webpackBootstrap /******/ // The module cache /******/ var installedModules = {}; /******/ /******/ // The require function /******/ function __webpack_require__(moduleId) { /******/ /******/ // Check if module is in cache /******/ if(installedModules[moduleId]) /******/ return installedModules[moduleId].exports; /******/ /******/ // Create a new module (and put it into the cache) /******/ var module = installedModules[moduleId] = { /******/ i: moduleId, /******/ l: false, /******/ exports: {} /******/ }; /******/ /******/ // Execute the module function /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); /******/ /******/ // Flag the module as loaded /******/ module.l = true; /******/ /******/ // Return the exports of the module /******/ return module.exports; /******/ } /******/ /******/ /******/ // expose the modules object (__webpack_modules__) /******/ __webpack_require__.m = modules; /******/ /******/ // expose the module cache /******/ __webpack_require__.c = installedModules; /******/ /******/ // identity function for calling harmony imports with the correct context /******/ __webpack_require__.i = function(value) { return value; }; /******/ /******/ // define getter function for harmony exports /******/ __webpack_require__.d = function(exports, name, getter) { /******/ if(!__webpack_require__.o(exports, name)) { /******/ Object.defineProperty(exports, name, { /******/ configurable: false, /******/ enumerable: true, /******/ get: getter /******/ }); /******/ } /******/ }; /******/ /******/ // getDefaultExport function for compatibility with non-harmony modules /******/ __webpack_require__.n = function(module) { /******/ var getter = module && module.__esModule ? /******/ function getDefault() { return module['default']; } : /******/ function getModuleExports() { return module; }; /******/ __webpack_require__.d(getter, 'a', getter); /******/ return getter; /******/ }; /******/ /******/ // Object.prototype.hasOwnProperty.call /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; /******/ /******/ // __webpack_public_path__ /******/ __webpack_require__.p = ""; /******/ /******/ // Load entry module and return exports /******/ return __webpack_require__(__webpack_require__.s = 76); /******/ }) /************************************************************************/ /******/ ([ /* 0 */ /***/ (function(module, exports, __webpack_require__) { var store = __webpack_require__(35)('wks') , uid = __webpack_require__(16) , Symbol = __webpack_require__(1).Symbol , USE_SYMBOL = typeof Symbol == 'function'; var $exports = module.exports = function(name){ return store[name] || (store[name] = USE_SYMBOL && Symbol[name] || (USE_SYMBOL ? Symbol : uid)('Symbol.' + name)); }; $exports.store = store; /***/ }), /* 1 */ /***/ (function(module, exports) { // https://github.com/zloirock/core-js/issues/86#issuecomment-115759028 var global = module.exports = typeof window != 'undefined' && window.Math == Math ? window : typeof self != 'undefined' && self.Math == Math ? self : Function('return this')(); if(typeof __g == 'number')__g = global; // eslint-disable-line no-undef /***/ }), /* 2 */ /***/ (function(module, exports, __webpack_require__) { // Thank's IE8 for his funny defineProperty module.exports = !__webpack_require__(14)(function(){ return Object.defineProperty({}, 'a', {get: function(){ return 7; }}).a != 7; }); /***/ }), /* 3 */ /***/ (function(module, exports) { var hasOwnProperty = {}.hasOwnProperty; module.exports = function(it, key){ return hasOwnProperty.call(it, key); }; /***/ }), /* 4 */ /***/ (function(module, exports) { module.exports = function(it){ return typeof it === 'object' ? it !== null : typeof it === 'function'; }; /***/ }), /* 5 */ /***/ (function(module, exports, __webpack_require__) { var isObject = __webpack_require__(4); module.exports = function(it){ if(!isObject(it))throw TypeError(it + ' is not an object!'); return it; }; /***/ }), /* 6 */ /***/ (function(module, exports, __webpack_require__) { var dP = __webpack_require__(7) , createDesc = __webpack_require__(20); module.exports = __webpack_require__(2) ? function(object, key, value){ return dP.f(object, key, createDesc(1, value)); } : function(object, key, value){ object[key] = value; return object; }; /***/ }), /* 7 */ /***/ (function(module, exports, __webpack_require__) { var anObject = __webpack_require__(5) , IE8_DOM_DEFINE = __webpack_require__(30) , toPrimitive = __webpack_require__(37) , dP = Object.defineProperty; exports.f = __webpack_require__(2) ? Object.defineProperty : function defineProperty(O, P, Attributes){ anObject(O); P = toPrimitive(P, true); anObject(Attributes); if(IE8_DOM_DEFINE)try { return dP(O, P, Attributes); } catch(e){ /* empty */ } if('get' in Attributes || 'set' in Attributes)throw TypeError('Accessors not supported!'); if('value' in Attributes)O[P] = Attributes.value; return O; }; /***/ }), /* 8 */ /***/ (function(module, exports, __webpack_require__) { var global = __webpack_require__(1) , hide = __webpack_require__(6) , has = __webpack_require__(3) , SRC = __webpack_require__(16)('src') , TO_STRING = 'toString' , $toString = Function[TO_STRING] , TPL = ('' + $toString).split(TO_STRING); __webpack_require__(9).inspectSource = function(it){ return $toString.call(it); }; (module.exports = function(O, key, val, safe){ var isFunction = typeof val == 'function'; if(isFunction)has(val, 'name') || hide(val, 'name', key); if(O[key] === val)return; if(isFunction)has(val, SRC) || hide(val, SRC, O[key] ? '' + O[key] : TPL.join(String(key))); if(O === global){ O[key] = val; } else { if(!safe){ delete O[key]; hide(O, key, val); } else { if(O[key])O[key] = val; else hide(O, key, val); } } // add fake Function#toString for correct work wrapped methods / constructors with methods like LoDash isNative })(Function.prototype, TO_STRING, function toString(){ return typeof this == 'function' && this[SRC] || $toString.call(this); }); /***/ }), /* 9 */ /***/ (function(module, exports) { var core = module.exports = {version: '2.4.0'}; if(typeof __e == 'number')__e = core; // eslint-disable-line no-undef /***/ }), /* 10 */ /***/ (function(module, exports) { module.exports = {}; /***/ }), /* 11 */ /***/ (function(module, exports, __webpack_require__) { // optional / simple context binding var aFunction = __webpack_require__(41); module.exports = function(fn, that, length){ aFunction(fn); if(that === undefined)return fn; switch(length){ case 1: return function(a){ return fn.call(that, a); }; case 2: return function(a, b){ return fn.call(that, a, b); }; case 3: return function(a, b, c){ return fn.call(that, a, b, c); }; } return function(/* ...args */){ return fn.apply(that, arguments); }; }; /***/ }), /* 12 */ /***/ (function(module, exports) { // 7.2.1 RequireObjectCoercible(argument) module.exports = function(it){ if(it == undefined)throw TypeError("Can't call method on " + it); return it; }; /***/ }), /* 13 */ /***/ (function(module, exports, __webpack_require__) { var global = __webpack_require__(1) , core = __webpack_require__(9) , hide = __webpack_require__(6) , redefine = __webpack_require__(8) , ctx = __webpack_require__(11) , PROTOTYPE = 'prototype'; var $export = function(type, name, source){ var IS_FORCED = type & $export.F , IS_GLOBAL = type & $export.G , IS_STATIC = type & $export.S , IS_PROTO = type & $export.P , IS_BIND = type & $export.B , target = IS_GLOBAL ? global : IS_STATIC ? global[name] || (global[name] = {}) : (global[name] || {})[PROTOTYPE] , exports = IS_GLOBAL ? core : core[name] || (core[name] = {}) , expProto = exports[PROTOTYPE] || (exports[PROTOTYPE] = {}) , key, own, out, exp; if(IS_GLOBAL)source = name; for(key in source){ // contains in native own = !IS_FORCED && target && target[key] !== undefined; // export native or passed out = (own ? target : source)[key]; // bind timers to global for call from export context exp = IS_BIND && own ? ctx(out, global) : IS_PROTO && typeof out == 'function' ? ctx(Function.call, out) : out; // extend global if(target)redefine(target, key, out, type & $export.U); // export if(exports[key] != out)hide(exports, key, exp); if(IS_PROTO && expProto[key] != out)expProto[key] = out; } }; global.core = core; // type bitmap $export.F = 1; // forced $export.G = 2; // global $export.S = 4; // static $export.P = 8; // proto $export.B = 16; // bind $export.W = 32; // wrap $export.U = 64; // safe $export.R = 128; // real proto method for `library` module.exports = $export; /***/ }), /* 14 */ /***/ (function(module, exports) { module.exports = function(exec){ try { return !!exec(); } catch(e){ return true; } }; /***/ }), /* 15 */ /***/ (function(module, exports, __webpack_require__) { // to indexed object, toObject with fallback for non-array-like ES3 strings var IObject = __webpack_require__(48) , defined = __webpack_require__(12); module.exports = function(it){ return IObject(defined(it)); }; /***/ }), /* 16 */ /***/ (function(module, exports) { var id = 0 , px = Math.random(); module.exports = function(key){ return 'Symbol('.concat(key === undefined ? '' : key, ')_', (++id + px).toString(36)); }; /***/ }), /* 17 */ /***/ (function(module, exports, __webpack_require__) { // getting tag from 19.1.3.6 Object.prototype.toString() var cof = __webpack_require__(27) , TAG = __webpack_require__(0)('toStringTag') // ES3 wrong here , ARG = cof(function(){ return arguments; }()) == 'Arguments'; // fallback for IE11 Script Access Denied error var tryGet = function(it, key){ try { return it[key]; } catch(e){ /* empty */ } }; module.exports = function(it){ var O, T, B; return it === undefined ? 'Undefined' : it === null ? 'Null' // @@toStringTag case : typeof (T = tryGet(O = Object(it), TAG)) == 'string' ? T // builtinTag case : ARG ? cof(O) // ES3 arguments fallback : (B = cof(O)) == 'Object' && typeof O.callee == 'function' ? 'Arguments' : B; }; /***/ }), /* 18 */ /***/ (function(module, exports, __webpack_require__) { var ctx = __webpack_require__(11) , call = __webpack_require__(50) , isArrayIter = __webpack_require__(49) , anObject = __webpack_require__(5) , toLength = __webpack_require__(36) , getIterFn = __webpack_require__(65) , BREAK = {} , RETURN = {}; var exports = module.exports = function(iterable, entries, fn, that, ITERATOR){ var iterFn = ITERATOR ? function(){ return iterable; } : getIterFn(iterable) , f = ctx(fn, that, entries ? 2 : 1) , index = 0 , length, step, iterator, result; if(typeof iterFn != 'function')throw TypeError(iterable + ' is not iterable!'); // fast case for arrays with default iterator if(isArrayIter(iterFn))for(length = toLength(iterable.length); length > index; index++){ result = entries ? f(anObject(step = iterable[index])[0], step[1]) : f(iterable[index]); if(result === BREAK || result === RETURN)return result; } else for(iterator = iterFn.call(iterable); !(step = iterator.next()).done; ){ result = call(iterator, f, step.value, entries); if(result === BREAK || result === RETURN)return result; } }; exports.BREAK = BREAK; exports.RETURN = RETURN; /***/ }), /* 19 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; var LIBRARY = __webpack_require__(53) , $export = __webpack_require__(13) , redefine = __webpack_require__(8) , hide = __webpack_require__(6) , has = __webpack_require__(3) , Iterators = __webpack_require__(10) , $iterCreate = __webpack_require__(51) , setToStringTag = __webpack_require__(21) , getPrototypeOf = __webpack_require__(56) , ITERATOR = __webpack_require__(0)('iterator') , BUGGY = !([].keys && 'next' in [].keys()) // Safari has buggy iterators w/o `next` , FF_ITERATOR = '@@iterator' , KEYS = 'keys' , VALUES = 'values'; var returnThis = function(){ return this; }; module.exports = function(Base, NAME, Constructor, next, DEFAULT, IS_SET, FORCED){ $iterCreate(Constructor, NAME, next); var getMethod = function(kind){ if(!BUGGY && kind in proto)return proto[kind]; switch(kind){ case KEYS: return function keys(){ return new Constructor(this, kind); }; case VALUES: return function values(){ return new Constructor(this, kind); }; } return function entries(){ return new Constructor(this, kind); }; }; var TAG = NAME + ' Iterator' , DEF_VALUES = DEFAULT == VALUES , VALUES_BUG = false , proto = Base.prototype , $native = proto[ITERATOR] || proto[FF_ITERATOR] || DEFAULT && proto[DEFAULT] , $default = $native || getMethod(DEFAULT) , $entries = DEFAULT ? !DEF_VALUES ? $default : getMethod('entries') : undefined , $anyNative = NAME == 'Array' ? proto.entries || $native : $native , methods, key, IteratorPrototype; // Fix native if($anyNative){ IteratorPrototype = getPrototypeOf($anyNative.call(new Base)); if(IteratorPrototype !== Object.prototype){ // Set @@toStringTag to native iterators setToStringTag(IteratorPrototype, TAG, true); // fix for some old engines if(!LIBRARY && !has(IteratorPrototype, ITERATOR))hide(IteratorPrototype, ITERATOR, returnThis); } } // fix Array#{values, @@iterator}.name in V8 / FF if(DEF_VALUES && $native && $native.name !== VALUES){ VALUES_BUG = true; $default = function values(){ return $native.call(this); }; } // Define iterator if((!LIBRARY || FORCED) && (BUGGY || VALUES_BUG || !proto[ITERATOR])){ hide(proto, ITERATOR, $default); } // Plug for library Iterators[NAME] = $default; Iterators[TAG] = returnThis; if(DEFAULT){ methods = { values: DEF_VALUES ? $default : getMethod(VALUES), keys: IS_SET ? $default : getMethod(KEYS), entries: $entries }; if(FORCED)for(key in methods){ if(!(key in proto))redefine(proto, key, methods[key]); } else $export($export.P + $export.F * (BUGGY || VALUES_BUG), NAME, methods); } return methods; }; /***/ }), /* 20 */ /***/ (function(module, exports) { module.exports = function(bitmap, value){ return { enumerable : !(bitmap & 1), configurable: !(bitmap & 2), writable : !(bitmap & 4), value : value }; }; /***/ }), /* 21 */ /***/ (function(module, exports, __webpack_require__) { var def = __webpack_require__(7).f , has = __webpack_require__(3) , TAG = __webpack_require__(0)('toStringTag'); module.exports = function(it, tag, stat){ if(it && !has(it = stat ? it : it.prototype, TAG))def(it, TAG, {configurable: true, value: tag}); }; /***/ }), /* 22 */ /***/ (function(module, exports, __webpack_require__) { var shared = __webpack_require__(35)('keys') , uid = __webpack_require__(16); module.exports = function(key){ return shared[key] || (shared[key] = uid(key)); }; /***/ }), /* 23 */ /***/ (function(module, exports) { // 7.1.4 ToInteger var ceil = Math.ceil , floor = Math.floor; module.exports = function(it){ return isNaN(it = +it) ? 0 : (it > 0 ? floor : ceil)(it); }; /***/ }), /* 24 */ /***/ (function(module, exports, __webpack_require__) { // 22.1.3.31 Array.prototype[@@unscopables] var UNSCOPABLES = __webpack_require__(0)('unscopables') , ArrayProto = Array.prototype; if(ArrayProto[UNSCOPABLES] == undefined)__webpack_require__(6)(ArrayProto, UNSCOPABLES, {}); module.exports = function(key){ ArrayProto[UNSCOPABLES][key] = true; }; /***/ }), /* 25 */ /***/ (function(module, exports) { module.exports = function(it, Constructor, name, forbiddenField){ if(!(it instanceof Constructor) || (forbiddenField !== undefined && forbiddenField in it)){ throw TypeError(name + ': incorrect invocation!'); } return it; }; /***/ }), /* 26 */ /***/ (function(module, exports, __webpack_require__) { // false -> Array#indexOf // true -> Array#includes var toIObject = __webpack_require__(15) , toLength = __webpack_require__(36) , toIndex = __webpack_require__(63); module.exports = function(IS_INCLUDES){ return function($this, el, fromIndex){ var O = toIObject($this) , length = toLength(O.length) , index = toIndex(fromIndex, length) , value; // Array#includes uses SameValueZero equality algorithm if(IS_INCLUDES && el != el)while(length > index){ value = O[index++]; if(value != value)return true; // Array#toIndex ignores holes, Array#includes - not } else for(;length > index; index++)if(IS_INCLUDES || index in O){ if(O[index] === el)return IS_INCLUDES || index || 0; } return !IS_INCLUDES && -1; }; }; /***/ }), /* 27 */ /***/ (function(module, exports) { var toString = {}.toString; module.exports = function(it){ return toString.call(it).slice(8, -1); }; /***/ }), /* 28 */ /***/ (function(module, exports, __webpack_require__) { var isObject = __webpack_require__(4) , document = __webpack_require__(1).document // in old IE typeof document.createElement is 'object' , is = isObject(document) && isObject(document.createElement); module.exports = function(it){ return is ? document.createElement(it) : {}; }; /***/ }), /* 29 */ /***/ (function(module, exports) { // IE 8- don't enum bug keys module.exports = ( 'constructor,hasOwnProperty,isPrototypeOf,propertyIsEnumerable,toLocaleString,toString,valueOf' ).split(','); /***/ }), /* 30 */ /***/ (function(module, exports, __webpack_require__) { module.exports = !__webpack_require__(2) && !__webpack_require__(14)(function(){ return Object.defineProperty(__webpack_require__(28)('div'), 'a', {get: function(){ return 7; }}).a != 7; }); /***/ }), /* 31 */ /***/ (function(module, exports) { module.exports = function(done, value){ return {value: value, done: !!done}; }; /***/ }), /* 32 */ /***/ (function(module, exports, __webpack_require__) { var META = __webpack_require__(16)('meta') , isObject = __webpack_require__(4) , has = __webpack_require__(3) , setDesc = __webpack_require__(7).f , id = 0; var isExtensible = Object.isExtensible || function(){ return true; }; var FREEZE = !__webpack_require__(14)(function(){ return isExtensible(Object.preventExtensions({})); }); var setMeta = function(it){ setDesc(it, META, {value: { i: 'O' + ++id, // object ID w: {} // weak collections IDs }}); }; var fastKey = function(it, create){ // return primitive with prefix if(!isObject(it))return typeof it == 'symbol' ? it : (typeof it == 'string' ? 'S' : 'P') + it; if(!has(it, META)){ // can't set metadata to uncaught frozen object if(!isExtensible(it))return 'F'; // not necessary to add metadata if(!create)return 'E'; // add missing metadata setMeta(it); // return object ID } return it[META].i; }; var getWeak = function(it, create){ if(!has(it, META)){ // can't set metadata to uncaught frozen object if(!isExtensible(it))return true; // not necessary to add metadata if(!create)return false; // add missing metadata setMeta(it); // return hash weak collections IDs } return it[META].w; }; // add metadata on freeze-family methods calling var onFreeze = function(it){ if(FREEZE && meta.NEED && isExtensible(it) && !has(it, META))setMeta(it); return it; }; var meta = module.exports = { KEY: META, NEED: false, fastKey: fastKey, getWeak: getWeak, onFreeze: onFreeze }; /***/ }), /* 33 */ /***/ (function(module, exports, __webpack_require__) { // 19.1.2.2 / 15.2.3.5 Object.create(O [, Properties]) var anObject = __webpack_require__(5) , dPs = __webpack_require__(54) , enumBugKeys = __webpack_require__(29) , IE_PROTO = __webpack_require__(22)('IE_PROTO') , Empty = function(){ /* empty */ } , PROTOTYPE = 'prototype'; // Create object with fake `null` prototype: use iframe Object with cleared prototype var createDict = function(){ // Thrash, waste and sodomy: IE GC bug var iframe = __webpack_require__(28)('iframe') , i = enumBugKeys.length , lt = '<' , gt = '>' , iframeDocument; iframe.style.display = 'none'; __webpack_require__(46).appendChild(iframe); iframe.src = 'javascript:'; // eslint-disable-line no-script-url // createDict = iframe.contentWindow.Object; // html.removeChild(iframe); iframeDocument = iframe.contentWindow.document; iframeDocument.open(); iframeDocument.write(lt + 'script' + gt + 'document.F=Object' + lt + '/script' + gt); iframeDocument.close(); createDict = iframeDocument.F; while(i--)delete createDict[PROTOTYPE][enumBugKeys[i]]; return createDict(); }; module.exports = Object.create || function create(O, Properties){ var result; if(O !== null){ Empty[PROTOTYPE] = anObject(O); result = new Empty; Empty[PROTOTYPE] = null; // add "__proto__" for Object.getPrototypeOf polyfill result[IE_PROTO] = O; } else result = createDict(); return Properties === undefined ? result : dPs(result, Properties); }; /***/ }), /* 34 */ /***/ (function(module, exports, __webpack_require__) { var redefine = __webpack_require__(8); module.exports = function(target, src, safe){ for(var key in src)redefine(target, key, src[key], safe); return target; }; /***/ }), /* 35 */ /***/ (function(module, exports, __webpack_require__) { var global = __webpack_require__(1) , SHARED = '__core-js_shared__' , store = global[SHARED] || (global[SHARED] = {}); module.exports = function(key){ return store[key] || (store[key] = {}); }; /***/ }), /* 36 */ /***/ (function(module, exports, __webpack_require__) { // 7.1.15 ToLength var toInteger = __webpack_require__(23) , min = Math.min; module.exports = function(it){ return it > 0 ? min(toInteger(it), 0x1fffffffffffff) : 0; // pow(2, 53) - 1 == 9007199254740991 }; /***/ }), /* 37 */ /***/ (function(module, exports, __webpack_require__) { // 7.1.1 ToPrimitive(input [, PreferredType]) var isObject = __webpack_require__(4); // instead of the ES6 spec version, we didn't implement @@toPrimitive case // and the second argument - flag - preferred type is a string module.exports = function(it, S){ if(!isObject(it))return it; var fn, val; if(S && typeof (fn = it.toString) == 'function' && !isObject(val = fn.call(it)))return val; if(typeof (fn = it.valueOf) == 'function' && !isObject(val = fn.call(it)))return val; if(!S && typeof (fn = it.toString) == 'function' && !isObject(val = fn.call(it)))return val; throw TypeError("Can't convert object to primitive value"); }; /***/ }), /* 38 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); /* * Typographie.js, v1.0.1 * (c) 2014–2017 Artyom "Sleepwalker" Fedosov <mail@asleepwalker.ru> * https://github.com/asleepwalker/typographie */ var _he = __webpack_require__(73); var _he2 = _interopRequireDefault(_he); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } var actions = ['quotes', 'inquot', 'dashes', 'angles', 'dblspace', 'specials', 'mathchars', 'punctuation', 'specialspaces', 'nbsp', 'hellip', 'paragraphs', 'safehtml']; var Typographie = function () { function Typographie() { var actionlist = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : actions; var input = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'plain'; var output = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'plain'; _classCallCheck(this, Typographie); this.actions(actionlist); this.mode(input, output); this._preserved = []; } _createClass(Typographie, [{ key: 'actions', value: function actions(actionlist) { this._actions = actionlist; } }, { key: 'mode', value: function mode(input, output) { this._in = input; this._out = output; } }, { key: 'requested', value: function requested(action) { return this._actions.includes(action); } }, { key: 'process', value: function process(raw) { var _prepare = this.prepare(raw), text = _prepare.text, preserved = _prepare.parts; if (this.requested('specials')) { text = this.processSpecials(text); } if (this.requested('mathchars')) { text = this.processMath(text); } if (this.requested('mathchars') || this.requested('dashes')) { text = this.processMinuses(text); } if (this.requested('punctuation')) { text = this.processPunctuation(text); } if (this.requested('specialspaces')) { text = this.processSpecialSpaces(text); } if (this.requested('angles')) { text = this.processAngles(text); } if (this.requested('dblspace')) { text = this.processMultipleSpaces(text); } if (this.requested('quotes')) { text = this.processQoutes(text); if (this.requested('inquot')) { text = this.processInnerQoutes(text); } else { text = this.processStackingQoutes(text); } } if (this.requested('dashes')) { text = this.processDashes(text); } if (this.requested('nbsp')) { text = this.processNbsps(text); } if (this.requested('hellip')) { text = this.processHellips(text); } return this.ready(text, preserved); } }, { key: 'processSpecials', value: function processSpecials(text) { var table = new Map([[/(\([cс]\))|(\{copy\})/gi, '\xA9'], [/(\(r\))|(\{reg\})/gi, '\xAE'], [/(\((тм|tm)\))|(\{(tm|trade)\})/gi, '\u2122'], [/\{(ss|sect)}/g, '\xA7'], [/\{(\*|deg)}/g, '\xB0'], [/\{euro}/g, '\u20AC'], [/\{cent}/g, '\xA2'], [/\{pound}/g, '\xA3'], [/\{(yen|yuan)}/g, '\xA5'], [/\{alpha\}/gi, '\u03B1'], [/\{beta\}/gi, '\u03B2'], [/\{gamma\}/gi, '\u03B3'], [/\{delta\}/gi, '\u03B4'], [/\{epsilon\}/gi, '\u03B5'], [/\{theta\}/gi, '\u03B8'], [/\{lambda\}/gi, '\u03BB'], [/\{mu\}/gi, '\u03BC'], [/\{nu\}/gi, '\u03BD'], [/\{pi\}/gi, '\u03C0'], [/\{rho\}/gi, '\u03C1'], [/\{sigma\}/gi, '\u03C3'], [/\{tau\}/gi, '\u03C4'], [/\{phi\}/gi, '\u03C6'], [/\{psi\}/gi, '\u03A8'], [/\{omega\}/gi, '\u03C9']]); return this.performReplace(text, table); } }, { key: 'processMath', value: function processMath(text) { var table = new Map([[/\{!=}/g, '\u2260'], [/\{~}/g, '\u2248'], [/\{equal}/g, '\u2261'], [/\{<=}/g, '\u2A7D'], [/\{=>}/g, '\u2A7E'], [/\+-/g, '\xB1'], [/\{-}/g, '\u2013'], [/\{multiple}/g, '\xD7'], [/\{divide}/g, '\xF7'], [/<->/g, '\u2194'], [/<=>/g, '\u21D4'], [/<-/g, '\u2190'], [/<=/g, '\u21D0'], [/->/g, '\u2192'], [/=>/g, '\u21D2'], [/\{\^1}/g, '\xB9'], [/\{\^2}/g, '\xB2'], [/\{\^3}/g, '\xB3'], [/\{1\/8}/g, '\u215B'], [/\{1\/6}/g, '\u2159'], [/\{1\/5}/g, '\u2155'], [/\{1\/4}/g, '\xBC'], [/\{1\/3}/g, '\u2153'], [/\{1\/2}/g, '\xBD'], [/\{2\/5}/g, '\u2156'], [/\{2\/3}/g, '\u2154'], [/\{3\/8}/g, '\u215C'], [/\{3\/5}/g, '\u2157'], [/\{3\/4}/g, '\xBE'], [/\{4\/5}/g, '\u2158'], [/\{5\/6}/g, '\u215A'], [/\{5\/8}/g, '\u215D'], [/\{7\/8}/g, '\u215E'], [/\{part}/g, '\u2202'], [/\{any}/g, '\u2200'], [/\{exist}/g, '\u2203'], [/\{sum}/g, '\u03A3'], [/\{empty}/g, '\u2205'], [/\{infinity}/g, '\u221E'], [/\{belong}/g, '\u2208'], [/\{!belong}/g, '\u2209'], [/\{union}/g, '\u222A'], [/\{intersection}/g, '\u2229'], [/\{v}/g, '\u221A'], [/\{v3}/g, '\u221B'], [/\{v4}/g, '\u221C'], [/\{ang}/g, '\u2220']]); return this.performReplace(text, table); } }, { key: 'processMinuses', value: function processMinuses(text) { return text.replace(/([ ])-(?=[\d])/g, '$1\u2013').replace(/^-(?=[\d])/gm, '\u2013'); } }, { key: 'processPunctuation', value: function processPunctuation(text) { var table = new Map(); if (this.requested('dashes')) { table.set(/[-]{2,5}/g, '\u2013'); } table.set(/(^|\s)([-\u2013])(?=[^\s])/gm, '$1$2 '); table.set(/([^\s])([-\u2013])($|\s)/gm, '$1 $2$3'); table.set(/([.,!?:)])(?=[^ \n"\'.,;!?&:\]\)<»{)])/g, '$1 '); table.set(/[ ]*(?=[.,;!?:])/g, ''); if (this.requested('nbsp')) { table.set(/ ([-\u2013])/g, '\xA0$1'); } var _preserveParts = this.preserveParts(text, [/[\d]+([.,][\d]+)+/g, /^[a-z0-9_.+-]+@[a-z0-9-]+\.[a-z0-9-.]+$/gi, /((([a-z]{3,9}:(?:\/\/)?)(?:[-;:&=\+\$,\w]+@)?[a-z0-9.-]+|(?:www.|[-;:&=\+\$,\w]+@)[a-z0-9.-]+)((?:\/[\+~%\/.\w-_]*)?\??(?:[-\+=&;%@.\w_]*)#?(?:[\w]*))?)/gi, /[:;.][\'_-]{0,2}[.,edpobnsu*#@|()&\$308ехорвъэ]/gi]), preservedText = _preserveParts.text, parts = _preserveParts.parts; preservedText = this.performReplace(preservedText, table); return this.restoreParts(preservedText, parts); } }, { key: 'processSpecialSpaces', value: function processSpecialSpaces(text) { var table = new Map([[/([\u2116\u00a7])[\s]*(?=[\d])/g, '$1 '], [/([\d])[\s]*(?=\u00b0[CСF])/g, '$1 '], [/([\d])[\s]*(?=%)/g, '$1']]); return this.performReplace(text, table); } }, { key: 'processAngles', value: function processAngles(text) { var table = new Map([[/(\d)\*/g, '$1\xB0'], [/(\d)\'/g, '$1\u2032'], [/(^[^"]*\d)"([^"]*$)/g, '$1\u2033$2'], [/("[^"]*\d)"([^"]*?")/g, '$1\u2033$2']]); return this.performReplace(text, table); } }, { key: 'processMultipleSpaces', value: function processMultipleSpaces(text) { return text.replace(/[ ]{2,}/g, ' '); } }, { key: 'processQoutes', value: function processQoutes(text) { var table = new Map([[/(^|[\s>};\(\[-])"/g, '$1\xAB'], [/"([\s-\.!,:;\?\)\]\n\r]|$)/g, '\xBB$1'], [/([^\s{])"([^\s}])/g, '$1\xBB$2'], [/(\u00ab[^\s\u00ab]*)\u00bb(.*?\u00bb.*?\u00bb)/g, '$1\xAB$2']]); return this.performReplace(text, table); } }, { key: 'processInnerQoutes', value: function processInnerQoutes(text) { while (text.match(/(\u00ab[^\u00ab\u00bb]*)\u00ab/m)) { text = text.replace(/(\u00ab[^\u00ab\u00bb]*)\u00ab/gm, '$1\u201E'); text = text.replace(/(\u201e[^\u201e\u201c\u00ab\u00bb]*)\u00bb/gm, '$1\u201C'); } return text; } }, { key: 'processStackingQoutes', value: function processStackingQoutes(text) { return text.replace(/\u00ab{2,}/g, '\xAB').replace(/\u00bb{2,}/g, '\xBB'); } }, { key: 'processDashes', value: function processDashes(text) { var table = new Map([[/(^|\n|["\u201e\u00ab])--?(\s)/gm, '$1\u2014$2'], [/([\d])-(?=[\d])/gm, '$1\u2013']]); if (this.requested('nbsp')) { table.set(/(\s)--?($|\s)/g, '\xA0\u2014$2'); } else { table.set(/(\s)--?($|\s)/g, ' \u2014$2'); } return this.performReplace(text, table); } }, { key: 'processNbsps', value: function processNbsps(text) { return text.replace(/((^|[\s])[a-zа-яёіїєґ\'′]{1,2})[ ]/gi, '$1\xA0'); } }, { key: 'processHellips', value: function processHellips(text) { return text.replace(/\.{2,5}/g, '\u2026'); } }, { key: 'performReplace', value: function performReplace(text, table) { table.forEach(function (o, i) { return text = text.replace(i, o); }); return text; } }, { key: 'preserveParts', value: function preserveParts(text, exceptions) { var parts = new Map(); exceptions.map(function (pattern) { return text = text.replace(pattern, function (match) { var code = String(Math.random()).substr(2); parts.set(code, match); return '{' + code + '}'; }); }); return { text: text, parts: parts }; } }, { key: 'restoreParts', value: function restoreParts(text, parts) { parts.forEach(function (o, i) { return text = text.replace('{' + i + '}', o); }); return text; } }, { key: 'prepare', value: function prepare(text) { if (this._in == 'html' && this._out == 'plain') { text = text.replace(/[\n]*<br[\s\/]*>[\n]*/gi, '\n'); text = text.replace(/<p[^>]*>(.*?)<\/p>[\s]*/gi, '$1\n\n'); text = text.replace(/<[^>]+>/gi, ''); } else if (this._in == 'plain' && this._out == 'html') { text = text.replace('<', '&lt;'); text = text.replace('>', '&gt;'); if (this.requested('paragraphs')) { text = text.replace(/^(.+?)$/gm, '<p>$1</p>'); text = text.replace(/<\/p>\n<p>/gi, '<br>\n'); } else { text = text.replace(/[\n]/gi, '<br>\n'); } } var preservations = []; if (this._out == 'html') { if (this._in == 'html') { if (this.requested('safehtml')) { preservations.push(/<(code|pre)(\s[^>]*)*>.*?<\/\1>/gi); } preservations.push(/<[^>]+>/gi); } else { preservations.push(/<[\/]{0,1}p>/gi); } } return this.preserveParts(text, preservations); } }, { key: 'ready', value: function ready(text, preserved) { if (this._in == 'html' && this._out == 'plain') { text = _he2.default.decode(text, { isAttributeValue: true }); } else if (this._out == 'html' && this.requested('entities')) { text = _he2.default.encode(text, { useNamedReferences: true }); } return this.restoreParts(text, preserved); } }]); return Typographie; }(); exports.default = Typographie; module.exports = exports['default']; /***/ }), /* 39 */ /***/ (function(module, exports, __webpack_require__) { __webpack_require__(70); module.exports = __webpack_require__(9).Array.includes; /***/ }), /* 40 */ /***/ (function(module, exports, __webpack_require__) { __webpack_require__(68); __webpack_require__(69); __webpack_require__(72); __webpack_require__(67); __webpack_require__(71); module.exports = __webpack_require__(9).Map; /***/ }), /* 41 */ /***/ (function(module, exports) { module.exports = function(it){ if(typeof it != 'function')throw TypeError(it + ' is not a function!'); return it; }; /***/ }), /* 42 */ /***/ (function(module, exports, __webpack_require__) { var forOf = __webpack_require__(18); module.exports = function(iter, ITERATOR){ var result = []; forOf(iter, false, result.push, result, ITERATOR); return result; }; /***/ }), /* 43 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; var dP = __webpack_require__(7).f , create = __webpack_require__(33) , redefineAll = __webpack_require__(34) , ctx = __webpack_require__(11) , anInstance = __webpack_require__(25) , defined = __webpack_require__(12) , forOf = __webpack_require__(18) , $iterDefine = __webpack_require__(19) , step = __webpack_require__(31) , setSpecies = __webpack_require__(61) , DESCRIPTORS = __webpack_require__(2) , fastKey = __webpack_require__(32).fastKey , SIZE = DESCRIPTORS ? '_s' : 'size'; var getEntry = function(that, key){ // fast case var index = fastKey(key), entry; if(index !== 'F')return that._i[index]; // frozen object case for(entry = that._f; entry; entry = entry.n){ if(entry.k == key)return entry; } }; module.exports = { getConstructor: function(wrapper, NAME, IS_MAP, ADDER){ var C = wrapper(function(that, iterable){ anInstance(that, C, NAME, '_i'); that._i = create(null); // index that._f = undefined; // first entry that._l = undefined; // last entry that[SIZE] = 0; // size if(iterable != undefined)forOf(iterable, IS_MAP, that[ADDER], that); }); redefineAll(C.prototype, { // 23.1.3.1 Map.prototype.clear() // 23.2.3.2 Set.prototype.clear() clear: function clear(){ for(var that = this, data = that._i, entry = that._f; entry; entry = entry.n){ entry.r = true; if(entry.p)entry.p = entry.p.n = undefined; delete data[entry.i]; } that._f = that._l = undefined; that[SIZE] = 0; }, // 23.1.3.3 Map.prototype.delete(key) // 23.2.3.4 Set.prototype.delete(value) 'delete': function(key){ var that = this , entry = getEntry(that, key); if(entry){ var next = entry.n , prev = entry.p; delete that._i[entry.i]; entry.r = true; if(prev)prev.n = next; if(next)next.p = prev; if(that._f == entry)that._f = next; if(that._l == entry)that._l = prev; that[SIZE]--; } return !!entry; }, // 23.2.3.6 Set.prototype.forEach(callbackfn, thisArg = undefined) // 23.1.3.5 Map.prototype.forEach(callbackfn, thisArg = undefined) forEach: function forEach(callbackfn /*, that = undefined */){ anInstance(this, C, 'forEach'); var f = ctx(callbackfn, arguments.length > 1 ? arguments[1] : undefined, 3) , entry; while(entry = entry ? entry.n : this._f){ f(entry.v, entry.k, this); // revert to the last existing entry while(entry && entry.r)entry = entry.p; } }, // 23.1.3.7 Map.prototype.has(key) // 23.2.3.7 Set.prototype.has(value) has: function has(key){ return !!getEntry(this, key); } }); if(DESCRIPTORS)dP(C.prototype, 'size', { get: function(){ return defined(this[SIZE]); } }); return C; }, def: function(that, key, value){ var entry = getEntry(that, key) , prev, index; // change existing entry if(entry){ entry.v = value; // create new entry } else { that._l = entry = { i: index = fastKey(key, true), // <- index k: key, // <- key v: value, // <- value p: prev = that._l, // <- previous entry n: undefined, // <- next entry r: false // <- removed }; if(!that._f)that._f = entry; if(prev)prev.n = entry; that[SIZE]++; // add to index if(index !== 'F')that._i[index] = entry; } return that; }, getEntry: getEntry, setStrong: function(C, NAME, IS_MAP){ // add .keys, .values, .entries, [@@iterator] // 23.1.3.4, 23.1.3.8, 23.1.3.11, 23.1.3.12, 23.2.3.5, 23.2.3.8, 23.2.3.10, 23.2.3.11 $iterDefine(C, NAME, function(iterated, kind){ this._t = iterated; // target this._k = kind; // kind this._l = undefined; // previous }, function(){ var that = this , kind = that._k , entry = that._l; // revert to the last existing entry while(entry && entry.r)entry = entry.p; // get next entry if(!that._t || !(that._l = entry = entry ? entry.n : that._t._f)){ // or finish the iteration that._t = undefined; return step(1); } // return step by kind if(kind == 'keys' )return step(0, entry.k); if(kind == 'values')return step(0, entry.v); return step(0, [entry.k, entry.v]); }, IS_MAP ? 'entries' : 'values' , !IS_MAP, true); // add [@@species], 23.1.2.2, 23.2.2.2 setSpecies(NAME); } }; /***/ }), /* 44 */ /***/ (function(module, exports, __webpack_require__) { // https://github.com/DavidBruant/Map-Set.prototype.toJSON var classof = __webpack_require__(17) , from = __webpack_require__(42); module.exports = function(NAME){ return function toJSON(){ if(classof(this) != NAME)throw TypeError(NAME + "#toJSON isn't generic"); return from(this); }; }; /***/ }), /* 45 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; var global = __webpack_require__(1) , $export = __webpack_require__(13) , redefine = __webpack_require__(8) , redefineAll = __webpack_require__(34) , meta = __webpack_require__(32) , forOf = __webpack_require__(18) , anInstance = __webpack_require__(25) , isObject = __webpack_require__(4) , fails = __webpack_require__(14) , $iterDetect = __webpack_require__(52) , setToStringTag = __webpack_require__(21) , inheritIfRequired = __webpack_require__(47); module.exports = function(NAME, wrapper, methods, common, IS_MAP, IS_WEAK){ var Base = global[NAME] , C = Base , ADDER = IS_MAP ? 'set' : 'add' , proto = C && C.prototype , O = {}; var fixMethod = function(KEY){ var fn = proto[KEY]; redefine(proto, KEY, KEY == 'delete' ? function(a){ return IS_WEAK && !isObject(a) ? false : fn.call(this, a === 0 ? 0 : a); } : KEY == 'has' ? function has(a){ return IS_WEAK && !isObject(a) ? false : fn.call(this, a === 0 ? 0 : a); } : KEY == 'get' ? function get(a){ return IS_WEAK && !isObject(a) ? undefined : fn.call(this, a === 0 ? 0 : a); } : KEY == 'add' ? function add(a){ fn.call(this, a === 0 ? 0 : a); return this; } : function set(a, b){ fn.call(this, a === 0 ? 0 : a, b); return this; } ); }; if(typeof C != 'function' || !(IS_WEAK || proto.forEach && !fails(function(){ new C().entries().next(); }))){ // create collection constructor C = common.getConstructor(wrapper, NAME, IS_MAP, ADDER); redefineAll(C.prototype, methods); meta.NEED = true; } else { var instance = new C // early implementations not supports chaining , HASNT_CHAINING = instance[ADDER](IS_WEAK ? {} : -0, 1) != instance // V8 ~ Chromium 40- weak-collections throws on primitives, but should return false , THROWS_ON_PRIMITIVES = fails(function(){ instance.has(1); }) // most early implementations doesn't supports iterables, most modern - not close it correctly , ACCEPT_ITERABLES = $iterDetect(function(iter){ new C(iter); }) // eslint-disable-line no-new // for early implementations -0 and +0 not the same , BUGGY_ZERO = !IS_WEAK && fails(function(){ // V8 ~ Chromium 42- fails only with 5+ elements var $instance = new C() , index = 5; while(index--)$instance[ADDER](index, index); return !$instance.has(-0); }); if(!ACCEPT_ITERABLES){ C = wrapper(function(target, iterable){ anInstance(target, C, NAME); var that = inheritIfRequired(new Base, target, C); if(iterable != undefined)forOf(iterable, IS_MAP, that[ADDER], that); return that; }); C.prototype = proto; proto.constructor = C; } if(THROWS_ON_PRIMITIVES || BUGGY_ZERO){ fixMethod('delete'); fixMethod('has'); IS_MAP && fixMethod('get'); } if(BUGGY_ZERO || HASNT_CHAINING)fixMethod(ADDER); // weak collections should not contains .clear method if(IS_WEAK && proto.clear)delete proto.clear; } setToStringTag(C, NAME); O[NAME] = C; $export($export.G + $export.W + $export.F * (C != Base), O); if(!IS_WEAK)common.setStrong(C, NAME, IS_MAP); return C; }; /***/ }), /* 46 */ /***/ (function(module, exports, __webpack_require__) { module.exports = __webpack_require__(1).document && document.documentElement; /***/ }), /* 47 */ /***/ (function(module, exports, __webpack_require__) { var isObject = __webpack_require__(4) , setPrototypeOf = __webpack_require__(60).set; module.exports = function(that, target, C){ var P, S = target.constructor; if(S !== C && typeof S == 'function' && (P = S.prototype) !== C.prototype && isObject(P) && setPrototypeOf){ setPrototypeOf(that, P); } return that; }; /***/ }), /* 48 */ /***/ (function(module, exports, __webpack_require__) { // fallback for non-array-like ES3 and non-enumerable old V8 strings var cof = __webpack_require__(27); module.exports = Object('z').propertyIsEnumerable(0) ? Object : function(it){ return cof(it) == 'String' ? it.split('') : Object(it); }; /***/ }), /* 49 */ /***/ (function(module, exports, __webpack_require__) { // check on default Array iterator var Iterators = __webpack_require__(10) , ITERATOR = __webpack_require__(0)('iterator') , ArrayProto = Array.prototype; module.exports = function(it){ return it !== undefined && (Iterators.Array === it || ArrayProto[ITERATOR] === it); }; /***/ }), /* 50 */ /***/ (function(module, exports, __webpack_require__) { // call something on iterator step with safe closing on error var anObject = __webpack_require__(5); module.exports = function(iterator, fn, value, entries){ try { return entries ? fn(anObject(value)[0], value[1]) : fn(value); // 7.4.6 IteratorClose(iterator, completion) } catch(e){ var ret = iterator['return']; if(ret !== undefined)anObject(ret.call(iterator)); throw e; } }; /***/ }), /* 51 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; var create = __webpack_require__(33) , descriptor = __webpack_require__(20) , setToStringTag = __webpack_require__(21) , IteratorPrototype = {}; // 25.1.2.1.1 %IteratorPrototype%[@@iterator]() __webpack_require__(6)(IteratorPrototype, __webpack_require__(0)('iterator'), function(){ return this; }); module.exports = function(Constructor, NAME, next){ Constructor.prototype = create(IteratorPrototype, {next: descriptor(1, next)}); setToStringTag(Constructor, NAME + ' Iterator'); }; /***/ }), /* 52 */ /***/ (function(module, exports, __webpack_require__) { var ITERATOR = __webpack_require__(0)('iterator') , SAFE_CLOSING = false; try { var riter = [7][ITERATOR](); riter['return'] = function(){ SAFE_CLOSING = true; }; Array.from(riter, function(){ throw 2; }); } catch(e){ /* empty */ } module.exports = function(exec, skipClosing){ if(!skipClosing && !SAFE_CLOSING)return false; var safe = false; try { var arr = [7] , iter = arr[ITERATOR](); iter.next = function(){ return {done: safe = true}; }; arr[ITERATOR] = function(){ return iter; }; exec(arr); } catch(e){ /* empty */ } return safe; }; /***/ }), /* 53 */ /***/ (function(module, exports) { module.exports = false; /***/ }), /* 54 */ /***/ (function(module, exports, __webpack_require__) { var dP = __webpack_require__(7) , anObject = __webpack_require__(5) , getKeys = __webpack_require__(58); module.exports = __webpack_require__(2) ? Object.defineProperties : function defineProperties(O, Properties){ anObject(O); var keys = getKeys(Properties) , length = keys.length , i = 0 , P; while(leng