# all files / browser/ pangu.js

93.15% Statements 204/219
75.21% Branches 88/117
94.12% Functions 32/34
94.97% Lines 170/179

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    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
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    274
    275
    276
    277
    278
    279
    280
    281
    282
    283
    284
    285
    286
    287
    288
    289
    290
    291
    292
    293
    294
    295
    296
    297
    298
    299
    300
    301
    302
    303
    304
    305
    306
    307
    308
    309
    310
    311
    312
    313
    314
    315
    316
    317
    318
    319
    320
    321
    322
    323
    324
    325
    326
    327
    328
    329
    330
    331
    332
    333
    334
    335
    336
    337
    338
    339
    340
    341
    342
    343
    344
    345
    346
    347
    348
    349
    350
    351
    352
    353
    354
    355
    356
    357
    358
    359
    360
    361
    362
    363
    364
    365
    366
    367
    368
    369
    370
    371
    372
    373
    374
    375
    376
    377
    378
    379
    380
    381
    382
    383
    384
    385
    386
    387
    388
    389
    390
    391
    392
    393
    394
    395
    396
    397
    398
    399
    400
    401
    402
    403
    404
    405
    406
    407
    408
    409
    410
    411
    412
    413
    414
    415
    416
    417
    418
    419
    420
    421
    422
    423
    424
    425
    426
    427
    428
    429
    430
    431
    432
    433
    434
    435
    436
    437
    438
    439
    440
    441
    442
    443
    444
    445
    446
    447
    448
    449
    450
    451
    452
    453
    454
    455
    456
    457
    458
    459
    460

    1×
    1×

    1×

    1×

    1×

    1×

    1×

    1×

    2×

    2×

    2×

    2×

    2×

    1×

    1×

    1×

    1×

    11×

    1×

    1×

    1×

    1×

    1×

    1×
    1×

    1×
    1×

    1×

    1×
    1×
    1×
    1×
    1×

    1×

    1×

    115×

    115×
    296×
    8×

    288×

    107×

    56×

    56×
    60×
    60×
    56×

    60×

    60×
    60×
    60×
    60×

    9×

    9×
    9×

    9×
    111×

    111×
    8×
    8×

    103×
    103×
    40×

    103×

    94×
    4×
    4×

    90×
    90×
    90×

    36×
    36×
    35×

    36×
    36×
    34×

    36×
    34×
    2×
    2×

    34×
    18×
    11×
    7×
    3×
    3×

    4×
    4×

    7×
    2×

    5×
    5×

    5×
    3×
    3×

    2×

    5×
    2×
    2×

    97×

    1×
    1×

    3×
    3×

    1×
    1×

    2×
    2×

    2×
    2×
    2×
    6×

    6×

    2×

    1×
    1×

    1×

    1×

    1×
    1×

    2×

    2×

    1×
    1×
    1×
    1×

    1×
    1×
    1×

    1×
    1×

    1×
    1×
    1×
    1×

    1×

    1×
    1×

    1×
    1×
    2×

    1×

    195×

    195×
    195×
    195×
    195×

    195×
    195×
    195×

    195×
    195×

    195×
    195×
    195×
    195×
    195×
    195×

    195×

    195×

    195×
    195×

    195×

    1×

    1×
    1×
    1×

    1×

    1×

    1×
    1×

     /*!
     * pangu.js
     * --------
     * @version: 3.2.0
     * @homepage: https://github.com/vinta/pangu.js
     * @license: MIT
     * @author: Vinta Chen <vinta.chen@gmail.com> (https://github.com/vinta)
     */
    (function webpackUniversalModuleDefinition(root, factory) {
    	Iif(typeof exports === 'object' && typeof module === 'object')
    		module.exports = factory();
    	else Iif(typeof define === 'function' && define.amd)
    		define("pangu", [], factory);
    	else Iif(typeof exports === 'object')
    		exports["pangu"] = factory();
    	else
    		root["pangu"] = 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
    /******/ 		Iif(installedModules[moduleId])
    /******/ 			return installedModules[moduleId].exports;
    /******/
    /******/ 		// Create a new module (and put it into the cache)
    /******/ 		var module = installedModules[moduleId] = {
    /******/ 			exports: {},
    /******/ 			id: moduleId,
    /******/ 			loaded: false
    /******/ 		};
    /******/
    /******/ 		// Execute the module function
    /******/ 		modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
    /******/
    /******/ 		// Flag the module as loaded
    /******/ 		module.loaded = 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;
    /******/
    /******/ 	// __webpack_public_path__
    /******/ 	__webpack_require__.p = "";
    /******/
    /******/ 	// Load entry module and return exports
    /******/ 	return __webpack_require__(0);
    /******/ })
    /************************************************************************/
    /******/ ([
    /* 0 */
    /***/ function(module, exports, __webpack_require__) {

    	'use strict';

    	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; Eif ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { Eif (protoProps) defineProperties(Constructor.prototype, protoProps); Iif (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();

    	function _classCallCheck(instance, Constructor) { Iif (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }

    	function _possibleConstructorReturn(self, call) { Iif (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }

    	function _inherits(subClass, superClass) { Iif (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); Eif (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }

    	var Pangu = __webpack_require__(1).Pangu;

    	// https://developer.mozilla.org/en/docs/Web/API/Node/nodeType
    	var COMMENT_NODE_TYPE = 8;

    	var BrowserPangu = function (_Pangu) {
    	  _inherits(BrowserPangu, _Pangu);

    	  function BrowserPangu() {
    	    _classCallCheck(this, BrowserPangu);

    	    var _this = _possibleConstructorReturn(this, Object.getPrototypeOf(BrowserPangu).call(this));

    	    _this.topTags = /^(html|head|body|#document)$/i;
    	    _this.ignoreTags = /^(code|pre|textarea)$/i;
    	    _this.spaceSensitiveTags = /^(a|del|pre|s|strike|u)$/i;
    	    _this.spaceLikeTags = /^(br|hr|i|img|pangu)$/i;
    	    _this.blockTags = /^(div|h1|h2|h3|h4|h5|h6|p)$/i;

    	    // TODO
    	    // this.ignoreClasses
    	    // this.ignoreAttributes
    	    return _this;
    	  }

    	  _createClass(BrowserPangu, [{
    	    key: 'canIgnoreNode',
    	    value: function canIgnoreNode(node) {
    	      var parentNode = node.parentNode;

    	      while (parentNode && parentNode.nodeName && parentNode.nodeName.search(this.topTags) === -1) {
    	        if (parentNode.nodeName.search(this.ignoreTags) >= 0 || parentNode.isContentEditable || parentNode.getAttribute('g_editable') === 'true') {
    	          return true;
    	        }

    	        parentNode = parentNode.parentNode;
    	      }

    	      return false;
    	    }
    	  }, {
    	    key: 'isFirstTextChild',
    	    value: function isFirstTextChild(parentNode, targetNode) {
    	      var childNodes = parentNode.childNodes;

    	      // 只判斷第一個含有 text 的 node
    	      for (var i = 0; i < childNodes.length; i++) {
    	        var childNode = childNodes[i];
    	        if (childNode.nodeType !== COMMENT_NODE_TYPE && childNode.textContent) {
    	          return childNode === targetNode;
    	        }
    	      }

    	      return false;
    	    }
    	  }, {
    	    key: 'isLastTextChild',
    	    value: function isLastTextChild(parentNode, targetNode) {
    	      var childNodes = parentNode.childNodes;

    	      // 只判斷倒數第一個含有 text 的 node
    	      for (var i = childNodes.length - 1; i > -1; i--) {
    	        var childNode = childNodes[i];
    	        Eif (childNode.nodeType !== COMMENT_NODE_TYPE && childNode.textContent) {
    	          return childNode === targetNode;
    	        }
    	      }

    	      return false;
    	    }
    	  }, {
    	    key: 'spacingNodeByXPath',
    	    value: function spacingNodeByXPath(xPathQuery, contextNode) {
    	      // 因為 xPathQuery 會是用 text() 結尾，所以這些 nodes 會是 text 而不是 DOM element
    	      // snapshotLength 要配合 XPathResult.ORDERED_NODE_SNAPSHOT_TYPE 使用
    	      // https://developer.mozilla.org/en-US/docs/DOM/document.evaluate
    	      // https://developer.mozilla.org/en-US/docs/Web/API/XPathResult
    	      var textNodes = document.evaluate(xPathQuery, contextNode, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);

    	      var currentTextNode = void 0;
    	      var nextTextNode = void 0;

    	      // 從最下面、最裡面的節點開始，所以是倒序的
    	      for (var i = textNodes.snapshotLength - 1; i > -1; --i) {
    	        currentTextNode = textNodes.snapshotItem(i);

    	        if (this.canIgnoreNode(currentTextNode)) {
    	          nextTextNode = currentTextNode;
    	          continue;
    	        }

    	        var newText = this.spacing(currentTextNode.data);
    	        if (currentTextNode.data !== newText) {
    	          currentTextNode.data = newText;
    	        }

    	        // 處理嵌套的 <tag> 中的文字
    	        if (nextTextNode) {
    	          // TODO
    	          // 現在只是簡單地判斷相鄰的下一個 node 是不是 <br>
    	          // 萬一遇上嵌套的標籤就不行了
    	          if (currentTextNode.nextSibling && currentTextNode.nextSibling.nodeName.search(this.spaceLikeTags) >= 0) {
    	            nextTextNode = currentTextNode;
    	            continue;
    	          }

    	          // currentTextNode 的最後一個字 + nextTextNode 的第一個字
    	          var testText = currentTextNode.data.toString().substr(-1) + nextTextNode.data.toString().substr(0, 1);
    	          var testNewText = this.spacing(testText);
    	          if (testNewText !== testText) {
    	            // 往上找 nextTextNode 的 parent node
    	            // 直到遇到 spaceSensitiveTags
    	            // 而且 nextTextNode 必須是第一個 text child
    	            // 才能把空格加在 nextTextNode 的前面
    	            var nextNode = nextTextNode;
    	            while (nextNode.parentNode && nextNode.nodeName.search(this.spaceSensitiveTags) === -1 && this.isFirstTextChild(nextNode.parentNode, nextNode)) {
    	              nextNode = nextNode.parentNode;
    	            }

    	            var currentNode = currentTextNode;
    	            while (currentNode.parentNode && currentNode.nodeName.search(this.spaceSensitiveTags) === -1 && this.isLastTextChild(currentNode.parentNode, currentNode)) {
    	              currentNode = currentNode.parentNode;
    	            }

    	            if (currentNode.nextSibling) {
    	              if (currentNode.nextSibling.nodeName.search(this.spaceLikeTags) >= 0) {
    	                nextTextNode = currentTextNode;
    	                continue;
    	              }
    	            }

    	            if (currentNode.nodeName.search(this.blockTags) === -1) {
    	              if (nextNode.nodeName.search(this.spaceSensitiveTags) === -1) {
    	                if (nextNode.nodeName.search(this.ignoreTags) === -1 && nextNode.nodeName.search(this.blockTags) === -1) {
    	                  if (nextTextNode.previousSibling) {
    	                    Eif (nextTextNode.previousSibling.nodeName.search(this.spaceLikeTags) === -1) {
    	                      nextTextNode.data = ' ' + nextTextNode.data;
    	                    }
    	                  } else {
    	                    // dirty hack
    	                    Eif (!this.canIgnoreNode(nextTextNode)) {
    	                      nextTextNode.data = ' ' + nextTextNode.data;
    	                    }
    	                  }
    	                }
    	              } else if (currentNode.nodeName.search(this.spaceSensitiveTags) === -1) {
    	                currentTextNode.data = currentTextNode.data + ' ';
    	              } else {
    	                var panguSpace = document.createElement('pangu');
    	                panguSpace.innerHTML = ' ';

    	                // 避免一直被加空格
    	                if (nextNode.previousSibling) {
    	                  Eif (nextNode.previousSibling.nodeName.search(this.spaceLikeTags) === -1) {
    	                    nextNode.parentNode.insertBefore(panguSpace, nextNode);
    	                  }
    	                } else {
    	                  nextNode.parentNode.insertBefore(panguSpace, nextNode);
    	                }

    	                // TODO
    	                // 主要是想要避免在元素（通常都是 <li>）的開頭加空格
    	                // 這個做法有點蠢，但是不管還是先硬上
    	                if (!panguSpace.previousElementSibling) {
    	                  Eif (panguSpace.parentNode) {
    	                    panguSpace.parentNode.removeChild(panguSpace);
    	                  }
    	                }
    	              }
    	            }
    	          }
    	        }

    	        nextTextNode = currentTextNode;
    	      }
    	    }
    	  }, {
    	    key: 'spacingNode',
    	    value: function spacingNode(contextNode) {
    	      var xPathQuery = './/*/text()[normalize-space(.)]';
    	      this.spacingNodeByXPath(xPathQuery, contextNode);
    	    }
    	  }, {
    	    key: 'spacingElementById',
    	    value: function spacingElementById(idName) {
    	      var xPathQuery = 'id("' + idName + '")//text()';
    	      this.spacingNodeByXPath(xPathQuery, document);
    	    }
    	  }, {
    	    key: 'spacingElementByClassName',
    	    value: function spacingElementByClassName(className) {
    	      var xPathQuery = '//*[contains(concat(" ", normalize-space(@class), " "), "' + className + '")]//text()';
    	      this.spacingNodeByXPath(xPathQuery, document);
    	    }
    	  }, {
    	    key: 'spacingElementByTagName',
    	    value: function spacingElementByTagName(tagName) {
    	      var xPathQuery = '//' + tagName + '//text()';
    	      this.spacingNodeByXPath(xPathQuery, document);
    	    }
    	  }, {
    	    key: 'spacingPageTitle',
    	    value: function spacingPageTitle() {
    	      var xPathQuery = '/html/head/title/text()';
    	      this.spacingNodeByXPath(xPathQuery, document);
    	    }
    	  }, {
    	    key: 'spacingPageBody',
    	    value: function spacingPageBody() {
    	      // // >> 任意位置的節點
    	      // . >> 當前節點
    	      // .. >> 父節點
    	      // [] >> 條件
    	      // text() >> 節點的文字內容，例如 hello 之於 <tag>hello</tag>
    	      //
    	      // [@contenteditable]
    	      // 帶有 contenteditable 屬性的節點
    	      //
    	      // normalize-space(.)
    	      // 當前節點的頭尾的空白字元都會被移除，大於兩個以上的空白字元會被置換成單一空白
    	      // https://developer.mozilla.org/en-US/docs/XPath/Functions/normalize-space
    	      //
    	      // name(..)
    	      // 父節點的名稱
    	      // https://developer.mozilla.org/en-US/docs/XPath/Functions/name
    	      //
    	      // translate(string, "ABCDEFGHIJKLMNOPQRSTUVWXYZ", "abcdefghijklmnopqrstuvwxyz")
    	      // 將 string 轉換成小寫，因為 XML 是 case-sensitive 的
    	      // https://developer.mozilla.org/en-US/docs/XPath/Functions/translate
    	      //
    	      // 1. 處理 <title>
    	      // 2. 處理 <body> 底下的節點
    	      // 3. 略過 contentEditable 的節點
    	      // 4. 略過特定節點，例如 <script> 和 <style>
    	      //
    	      // 注意，以下的 query 只會取出各節點的 text 內容！
    	      var xPathQuery = '/html/body//*/text()[normalize-space(.)]';
    	      var _arr = ['script', 'style', 'textarea'];
    	      for (var _i = 0; _i < _arr.length; _i++) {
    	        var tag = _arr[_i];
    	        // 理論上這幾個 tag 裡面不會包含其他 tag
    	        // 所以可以直接用 .. 取父節點
    	        // ex: [translate(name(..), "ABCDEFGHIJKLMNOPQRSTUVWXYZ", "abcdefghijklmnopqrstuvwxyz") != "script"]
    	        xPathQuery += '[translate(name(..),"ABCDEFGHIJKLMNOPQRSTUVWXYZ","abcdefghijklmnopqrstuvwxyz")!="' + tag + '"]';
    	      }
    	      this.spacingNodeByXPath(xPathQuery, document);
    	    }

    	    // TODO: 支援 callback 和 promise

    	  }, {
    	    key: 'spacingPage',
    	    value: function spacingPage() {
    	      this.spacingPageTitle();
    	      this.spacingPageBody();
    	    }
    	  }]);

    	  return BrowserPangu;
    	}(Pangu);

    	var pangu = new BrowserPangu();

    	exports = module.exports = pangu;
    	exports.Pangu = BrowserPangu;

    /***/ },
    /* 1 */
    /***/ function(module, exports) {

    	'use strict';

    	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; Eif ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { Eif (protoProps) defineProperties(Constructor.prototype, protoProps); Iif (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();

    	function _classCallCheck(instance, Constructor) { Iif (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }

    	// CJK is short for Chinese, Japanese and Korean.
    	//
    	// The constant cjk contains following Unicode blocks:
    	// 	\u2e80-\u2eff CJK Radicals Supplement
    	// 	\u2f00-\u2fdf Kangxi Radicals
    	// 	\u3040-\u309f Hiragana
    	// 	\u30a0-\u30ff Katakana
    	// 	\u3100-\u312f Bopomofo
    	// 	\u3200-\u32ff Enclosed CJK Letters and Months
    	// 	\u3400-\u4dbf CJK Unified Ideographs Extension A
    	// 	\u4e00-\u9fff CJK Unified Ideographs
    	// 	\uf900-\ufaff CJK Compatibility Ideographs
    	//
    	// For more information about Unicode blocks, see
    	// 	http://unicode-table.com/en/
    	//  https://github.com/vinta/pangu

    	// ANS is short for Alphabets, Numbers and Symbols (`~!@#$%^&*()-_=+[]{}\|;:'",<.>/?).
    	//
    	// CAUTION: those ANS in following constants do not contain all symbols above.

    	// cjkQuote >> 跟 Go 版差了一個 '
    	// quoteCJK >> 跟 Go 版差了一個 '
    	var cjkQuote = /([\u2e80-\u2eff\u2f00-\u2fdf\u3040-\u309f\u30a0-\u30ff\u3100-\u312f\u3200-\u32ff\u3400-\u4dbf\u4e00-\u9fff\uf900-\ufaff])(["])/g;
    	var quoteCJK = /(["])([\u2e80-\u2eff\u2f00-\u2fdf\u3040-\u309f\u30a0-\u30ff\u3100-\u312f\u3200-\u32ff\u3400-\u4dbf\u4e00-\u9fff\uf900-\ufaff])/g;
    	var fixQuote = /(["']+)(\s*)(.+?)(\s*)(["']+)/g;
    	var fixSingleQuote = /([\u2e80-\u2eff\u2f00-\u2fdf\u3040-\u309f\u30a0-\u30ff\u3100-\u312f\u3200-\u32ff\u3400-\u4dbf\u4e00-\u9fff\uf900-\ufaff])( )(')([A-Za-z])/g;

    	var hashANSCJKhash = /([\u2e80-\u2eff\u2f00-\u2fdf\u3040-\u309f\u30a0-\u30ff\u3100-\u312f\u3200-\u32ff\u3400-\u4dbf\u4e00-\u9fff\uf900-\ufaff])(#)([A-Za-z0-9\u2e80-\u2eff\u2f00-\u2fdf\u3040-\u309f\u30a0-\u30ff\u3100-\u312f\u3200-\u32ff\u3400-\u4dbf\u4e00-\u9fff\uf900-\ufaff]+)(#)([\u2e80-\u2eff\u2f00-\u2fdf\u3040-\u309f\u30a0-\u30ff\u3100-\u312f\u3200-\u32ff\u3400-\u4dbf\u4e00-\u9fff\uf900-\ufaff])/g;
    	var cjkHash = /([\u2e80-\u2eff\u2f00-\u2fdf\u3040-\u309f\u30a0-\u30ff\u3100-\u312f\u3200-\u32ff\u3400-\u4dbf\u4e00-\u9fff\uf900-\ufaff])(#([^ ]))/g;
    	var hashCJK = /(([^ ])#)([\u2e80-\u2eff\u2f00-\u2fdf\u3040-\u309f\u30a0-\u30ff\u3100-\u312f\u3200-\u32ff\u3400-\u4dbf\u4e00-\u9fff\uf900-\ufaff])/g;

    	var cjkOperatorANS = /([\u2e80-\u2eff\u2f00-\u2fdf\u3040-\u309f\u30a0-\u30ff\u3100-\u312f\u3200-\u32ff\u3400-\u4dbf\u4e00-\u9fff\uf900-\ufaff])([\+\-\*\/=&\\|<>])([A-Za-z0-9])/g;
    	var ansOperatorCJK = /([A-Za-z0-9])([\+\-\*\/=&\\|<>])([\u2e80-\u2eff\u2f00-\u2fdf\u3040-\u309f\u30a0-\u30ff\u3100-\u312f\u3200-\u32ff\u3400-\u4dbf\u4e00-\u9fff\uf900-\ufaff])/g;

    	var cjkBracketCJK = /([\u2e80-\u2eff\u2f00-\u2fdf\u3040-\u309f\u30a0-\u30ff\u3100-\u312f\u3200-\u32ff\u3400-\u4dbf\u4e00-\u9fff\uf900-\ufaff])([\(\[\{<\u201c]+(.*?)[\)\]\}>\u201d]+)([\u2e80-\u2eff\u2f00-\u2fdf\u3040-\u309f\u30a0-\u30ff\u3100-\u312f\u3200-\u32ff\u3400-\u4dbf\u4e00-\u9fff\uf900-\ufaff])/g;
    	var cjkBracket = /([\u2e80-\u2eff\u2f00-\u2fdf\u3040-\u309f\u30a0-\u30ff\u3100-\u312f\u3200-\u32ff\u3400-\u4dbf\u4e00-\u9fff\uf900-\ufaff])([\(\[\{<\u201c>])/g;
    	var bracketCJK = /([\)\]\}>\u201d<])([\u2e80-\u2eff\u2f00-\u2fdf\u3040-\u309f\u30a0-\u30ff\u3100-\u312f\u3200-\u32ff\u3400-\u4dbf\u4e00-\u9fff\uf900-\ufaff])/g;
    	var fixBracket = /([\(\[\{<\u201c]+)(\s*)(.+?)(\s*)([\)\]\}>\u201d]+)/;

    	var fixSymbol = /([\u2e80-\u2eff\u2f00-\u2fdf\u3040-\u309f\u30a0-\u30ff\u3100-\u312f\u3200-\u32ff\u3400-\u4dbf\u4e00-\u9fff\uf900-\ufaff])([~!;:,\.\?\u2026])([A-Za-z0-9])/g;

    	var cjkANS = /([\u2e80-\u2eff\u2f00-\u2fdf\u3040-\u309f\u30a0-\u30ff\u3100-\u312f\u3200-\u32ff\u3400-\u4dbf\u4e00-\u9fff\uf900-\ufaff])([A-Za-z0-9`\$%\^&\*\-=\+\\\|/@\u00a1-\u00ff\u2022\u2027\u2150-\u218f])/g;
    	var ansCJK = /([A-Za-z0-9`~\$%\^&\*\-=\+\\\|/!;:,\.\?\u00a1-\u00ff\u2022\u2026\u2027\u2150-\u218f])([\u2e80-\u2eff\u2f00-\u2fdf\u3040-\u309f\u30a0-\u30ff\u3100-\u312f\u3200-\u32ff\u3400-\u4dbf\u4e00-\u9fff\uf900-\ufaff])/g;

    	var Pangu = function () {
    	  function Pangu() {
    	    _classCallCheck(this, Pangu);
    	  }

    	  _createClass(Pangu, [{
    	    key: 'spacing',
    	    value: function spacing(text) {
    	      var newText = text;

    	      newText = newText.replace(cjkQuote, '$1 $2');
    	      newText = newText.replace(quoteCJK, '$1 $2');
    	      newText = newText.replace(fixQuote, '$1$3$5');
    	      newText = newText.replace(fixSingleQuote, '$1$3$4');

    	      newText = newText.replace(hashANSCJKhash, '$1 $2$3$4 $5');
    	      newText = newText.replace(cjkHash, '$1 $2');
    	      newText = newText.replace(hashCJK, '$1 $3');

    	      newText = newText.replace(cjkOperatorANS, '$1 $2 $3');
    	      newText = newText.replace(ansOperatorCJK, '$1 $2 $3');

    	      var oldText = newText;
    	      var tmpText = newText.replace(cjkBracketCJK, '$1 $2 $4');
    	      newText = tmpText;
    	      Eif (oldText === tmpText) {
    	        newText = newText.replace(cjkBracket, '$1 $2');
    	        newText = newText.replace(bracketCJK, '$1 $2');
    	      }
    	      newText = newText.replace(fixBracket, '$1$3$5');

    	      newText = newText.replace(fixSymbol, '$1$2 $3');

    	      newText = newText.replace(cjkANS, '$1 $2');
    	      newText = newText.replace(ansCJK, '$1 $2');

    	      return newText;
    	    }
    	  }, {
    	    key: 'spacingText',
    	    value: function spacingText(text) {
    	      var callback = arguments.length <= 1 || arguments[1] === undefined ? function () {} : arguments[1];

    	      try {
    	        var newText = this.spacing(text);
    	        callback(null, newText);
    	      } catch (err) {
    	        callback(err);
    	      }
    	    }
    	  }]);

    	  return Pangu;
    	}();

    	var pangu = new Pangu();

    	exports = module.exports = pangu;
    	exports.Pangu = Pangu;

    /***/ }
    /******/ ])
    });
    ;
    //# sourceMappingURL=pangu.js.map