| [ Index ] |
PHP Cross Reference of Moodle 310 |
[Summary view] [Print] [Text view]
1 YUI.add('moodle-atto_html-beautify', function (Y, NAME) { 2 3 // JSBeautify adds itself to the exports object if one exists. 4 // Define exports here and it will work as if by magic. 5 // This is safe to put in a function and will not be exported to the global 6 // namespace. Note, we'll have to remove this when YUI supports, and we move to ES6. 7 var exports = {}; 8 9 var define = null; // Remove require.js support in this context. 10 11 // JSBeautify calls require() in order to get the existing exported modules. 12 var require = function() { 13 return exports; 14 }; 15 require(); 16 17 // Actually define beautify in our namespace. 18 Y.namespace('M.atto_html').beautify = exports; 19 /*jshint curly:false, eqeqeq:true, laxbreak:true, noempty:false */ 20 /* AUTO-GENERATED. DO NOT MODIFY. */ 21 /* see js/src/javascript/index.js */ 22 /* 23 24 The MIT License (MIT) 25 26 Copyright (c) 2007-2017 Einar Lielmanis, Liam Newman, and contributors. 27 28 Permission is hereby granted, free of charge, to any person 29 obtaining a copy of this software and associated documentation files 30 (the "Software"), to deal in the Software without restriction, 31 including without limitation the rights to use, copy, modify, merge, 32 publish, distribute, sublicense, and/or sell copies of the Software, 33 and to permit persons to whom the Software is furnished to do so, 34 subject to the following conditions: 35 36 The above copyright notice and this permission notice shall be 37 included in all copies or substantial portions of the Software. 38 39 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 40 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 41 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 42 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 43 BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 44 ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 45 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 46 SOFTWARE. 47 48 JS Beautifier 49 --------------- 50 51 52 Written by Einar Lielmanis, <einar@jsbeautifier.org> 53 http://jsbeautifier.org/ 54 55 Originally converted to javascript by Vital, <vital76@gmail.com> 56 "End braces on own line" added by Chris J. Shull, <chrisjshull@gmail.com> 57 Parsing improvements for brace-less statements by Liam Newman <bitwiseman@gmail.com> 58 59 60 Usage: 61 js_beautify(js_source_text); 62 js_beautify(js_source_text, options); 63 64 The options are: 65 indent_size (default 4) - indentation size, 66 indent_char (default space) - character to indent with, 67 preserve_newlines (default true) - whether existing line breaks should be preserved, 68 max_preserve_newlines (default unlimited) - maximum number of line breaks to be preserved in one chunk, 69 70 jslint_happy (default false) - if true, then jslint-stricter mode is enforced. 71 72 jslint_happy !jslint_happy 73 --------------------------------- 74 function () function() 75 76 switch () { switch() { 77 case 1: case 1: 78 break; break; 79 } } 80 81 space_after_anon_function (default false) - should the space before an anonymous function's parens be added, "function()" vs "function ()", 82 NOTE: This option is overriden by jslint_happy (i.e. if jslint_happy is true, space_after_anon_function is true by design) 83 84 brace_style (default "collapse") - "collapse" | "expand" | "end-expand" | "none" | any of the former + ",preserve-inline" 85 put braces on the same line as control statements (default), or put braces on own line (Allman / ANSI style), or just put end braces on own line, or attempt to keep them where they are. 86 preserve-inline will try to preserve inline blocks of curly braces 87 88 space_before_conditional (default true) - should the space before conditional statement be added, "if(true)" vs "if (true)", 89 90 unescape_strings (default false) - should printable characters in strings encoded in \xNN notation be unescaped, "example" vs "\x65\x78\x61\x6d\x70\x6c\x65" 91 92 wrap_line_length (default unlimited) - lines should wrap at next opportunity after this number of characters. 93 NOTE: This is not a hard limit. Lines will continue until a point where a newline would 94 be preserved if it were present. 95 96 end_with_newline (default false) - end output with a newline 97 98 99 e.g 100 101 js_beautify(js_source_text, { 102 'indent_size': 1, 103 'indent_char': '\t' 104 }); 105 106 */ 107 108 (function() { 109 var legacy_beautify_js = 110 /******/ (function(modules) { // webpackBootstrap 111 /******/ // The module cache 112 /******/ var installedModules = {}; 113 /******/ 114 /******/ // The require function 115 /******/ function __webpack_require__(moduleId) { 116 /******/ 117 /******/ // Check if module is in cache 118 /******/ if(installedModules[moduleId]) { 119 /******/ return installedModules[moduleId].exports; 120 /******/ } 121 /******/ // Create a new module (and put it into the cache) 122 /******/ var module = installedModules[moduleId] = { 123 /******/ i: moduleId, 124 /******/ l: false, 125 /******/ exports: {} 126 /******/ }; 127 /******/ 128 /******/ // Execute the module function 129 /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); 130 /******/ 131 /******/ // Flag the module as loaded 132 /******/ module.l = true; 133 /******/ 134 /******/ // Return the exports of the module 135 /******/ return module.exports; 136 /******/ } 137 /******/ 138 /******/ 139 /******/ // expose the modules object (__webpack_modules__) 140 /******/ __webpack_require__.m = modules; 141 /******/ 142 /******/ // expose the module cache 143 /******/ __webpack_require__.c = installedModules; 144 /******/ 145 /******/ // identity function for calling harmony imports with the correct context 146 /******/ __webpack_require__.i = function(value) { return value; }; 147 /******/ 148 /******/ // define getter function for harmony exports 149 /******/ __webpack_require__.d = function(exports, name, getter) { 150 /******/ if(!__webpack_require__.o(exports, name)) { 151 /******/ Object.defineProperty(exports, name, { 152 /******/ configurable: false, 153 /******/ enumerable: true, 154 /******/ get: getter 155 /******/ }); 156 /******/ } 157 /******/ }; 158 /******/ 159 /******/ // getDefaultExport function for compatibility with non-harmony modules 160 /******/ __webpack_require__.n = function(module) { 161 /******/ var getter = module && module.__esModule ? 162 /******/ function getDefault() { return module['default']; } : 163 /******/ function getModuleExports() { return module; }; 164 /******/ __webpack_require__.d(getter, 'a', getter); 165 /******/ return getter; 166 /******/ }; 167 /******/ 168 /******/ // Object.prototype.hasOwnProperty.call 169 /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; 170 /******/ 171 /******/ // __webpack_public_path__ 172 /******/ __webpack_require__.p = ""; 173 /******/ 174 /******/ // Load entry module and return exports 175 /******/ return __webpack_require__(__webpack_require__.s = 6); 176 /******/ }) 177 /************************************************************************/ 178 /******/ ([ 179 /* 0 */ 180 /***/ (function(module, exports) { 181 182 /* jshint curly: false */ 183 // This section of code is taken from acorn. 184 // 185 // Acorn was written by Marijn Haverbeke and released under an MIT 186 // license. The Unicode regexps (for identifiers and whitespace) were 187 // taken from [Esprima](http://esprima.org) by Ariya Hidayat. 188 // 189 // Git repositories for Acorn are available at 190 // 191 // http://marijnhaverbeke.nl/git/acorn 192 // https://github.com/marijnh/acorn.git 193 194 // ## Character categories 195 196 // Big ugly regular expressions that match characters in the 197 // whitespace, identifier, and identifier-start categories. These 198 // are only applied when a character is found to actually have a 199 // code point above 128. 200 201 var nonASCIIwhitespace = /[\u1680\u180e\u2000-\u200a\u202f\u205f\u3000\ufeff]/; // jshint ignore:line 202 var nonASCIIidentifierStartChars = "\xaa\xb5\xba\xc0-\xd6\xd8-\xf6\xf8-\u02c1\u02c6-\u02d1\u02e0-\u02e4\u02ec\u02ee\u0370-\u0374\u0376\u0377\u037a-\u037d\u0386\u0388-\u038a\u038c\u038e-\u03a1\u03a3-\u03f5\u03f7-\u0481\u048a-\u0527\u0531-\u0556\u0559\u0561-\u0587\u05d0-\u05ea\u05f0-\u05f2\u0620-\u064a\u066e\u066f\u0671-\u06d3\u06d5\u06e5\u06e6\u06ee\u06ef\u06fa-\u06fc\u06ff\u0710\u0712-\u072f\u074d-\u07a5\u07b1\u07ca-\u07ea\u07f4\u07f5\u07fa\u0800-\u0815\u081a\u0824\u0828\u0840-\u0858\u08a0\u08a2-\u08ac\u0904-\u0939\u093d\u0950\u0958-\u0961\u0971-\u0977\u0979-\u097f\u0985-\u098c\u098f\u0990\u0993-\u09a8\u09aa-\u09b0\u09b2\u09b6-\u09b9\u09bd\u09ce\u09dc\u09dd\u09df-\u09e1\u09f0\u09f1\u0a05-\u0a0a\u0a0f\u0a10\u0a13-\u0a28\u0a2a-\u0a30\u0a32\u0a33\u0a35\u0a36\u0a38\u0a39\u0a59-\u0a5c\u0a5e\u0a72-\u0a74\u0a85-\u0a8d\u0a8f-\u0a91\u0a93-\u0aa8\u0aaa-\u0ab0\u0ab2\u0ab3\u0ab5-\u0ab9\u0abd\u0ad0\u0ae0\u0ae1\u0b05-\u0b0c\u0b0f\u0b10\u0b13-\u0b28\u0b2a-\u0b30\u0b32\u0b33\u0b35-\u0b39\u0b3d\u0b5c\u0b5d\u0b5f-\u0b61\u0b71\u0b83\u0b85-\u0b8a\u0b8e-\u0b90\u0b92-\u0b95\u0b99\u0b9a\u0b9c\u0b9e\u0b9f\u0ba3\u0ba4\u0ba8-\u0baa\u0bae-\u0bb9\u0bd0\u0c05-\u0c0c\u0c0e-\u0c10\u0c12-\u0c28\u0c2a-\u0c33\u0c35-\u0c39\u0c3d\u0c58\u0c59\u0c60\u0c61\u0c85-\u0c8c\u0c8e-\u0c90\u0c92-\u0ca8\u0caa-\u0cb3\u0cb5-\u0cb9\u0cbd\u0cde\u0ce0\u0ce1\u0cf1\u0cf2\u0d05-\u0d0c\u0d0e-\u0d10\u0d12-\u0d3a\u0d3d\u0d4e\u0d60\u0d61\u0d7a-\u0d7f\u0d85-\u0d96\u0d9a-\u0db1\u0db3-\u0dbb\u0dbd\u0dc0-\u0dc6\u0e01-\u0e30\u0e32\u0e33\u0e40-\u0e46\u0e81\u0e82\u0e84\u0e87\u0e88\u0e8a\u0e8d\u0e94-\u0e97\u0e99-\u0e9f\u0ea1-\u0ea3\u0ea5\u0ea7\u0eaa\u0eab\u0ead-\u0eb0\u0eb2\u0eb3\u0ebd\u0ec0-\u0ec4\u0ec6\u0edc-\u0edf\u0f00\u0f40-\u0f47\u0f49-\u0f6c\u0f88-\u0f8c\u1000-\u102a\u103f\u1050-\u1055\u105a-\u105d\u1061\u1065\u1066\u106e-\u1070\u1075-\u1081\u108e\u10a0-\u10c5\u10c7\u10cd\u10d0-\u10fa\u10fc-\u1248\u124a-\u124d\u1250-\u1256\u1258\u125a-\u125d\u1260-\u1288\u128a-\u128d\u1290-\u12b0\u12b2-\u12b5\u12b8-\u12be\u12c0\u12c2-\u12c5\u12c8-\u12d6\u12d8-\u1310\u1312-\u1315\u1318-\u135a\u1380-\u138f\u13a0-\u13f4\u1401-\u166c\u166f-\u167f\u1681-\u169a\u16a0-\u16ea\u16ee-\u16f0\u1700-\u170c\u170e-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176c\u176e-\u1770\u1780-\u17b3\u17d7\u17dc\u1820-\u1877\u1880-\u18a8\u18aa\u18b0-\u18f5\u1900-\u191c\u1950-\u196d\u1970-\u1974\u1980-\u19ab\u19c1-\u19c7\u1a00-\u1a16\u1a20-\u1a54\u1aa7\u1b05-\u1b33\u1b45-\u1b4b\u1b83-\u1ba0\u1bae\u1baf\u1bba-\u1be5\u1c00-\u1c23\u1c4d-\u1c4f\u1c5a-\u1c7d\u1ce9-\u1cec\u1cee-\u1cf1\u1cf5\u1cf6\u1d00-\u1dbf\u1e00-\u1f15\u1f18-\u1f1d\u1f20-\u1f45\u1f48-\u1f4d\u1f50-\u1f57\u1f59\u1f5b\u1f5d\u1f5f-\u1f7d\u1f80-\u1fb4\u1fb6-\u1fbc\u1fbe\u1fc2-\u1fc4\u1fc6-\u1fcc\u1fd0-\u1fd3\u1fd6-\u1fdb\u1fe0-\u1fec\u1ff2-\u1ff4\u1ff6-\u1ffc\u2071\u207f\u2090-\u209c\u2102\u2107\u210a-\u2113\u2115\u2119-\u211d\u2124\u2126\u2128\u212a-\u212d\u212f-\u2139\u213c-\u213f\u2145-\u2149\u214e\u2160-\u2188\u2c00-\u2c2e\u2c30-\u2c5e\u2c60-\u2ce4\u2ceb-\u2cee\u2cf2\u2cf3\u2d00-\u2d25\u2d27\u2d2d\u2d30-\u2d67\u2d6f\u2d80-\u2d96\u2da0-\u2da6\u2da8-\u2dae\u2db0-\u2db6\u2db8-\u2dbe\u2dc0-\u2dc6\u2dc8-\u2dce\u2dd0-\u2dd6\u2dd8-\u2dde\u2e2f\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303c\u3041-\u3096\u309d-\u309f\u30a1-\u30fa\u30fc-\u30ff\u3105-\u312d\u3131-\u318e\u31a0-\u31ba\u31f0-\u31ff\u3400-\u4db5\u4e00-\u9fcc\ua000-\ua48c\ua4d0-\ua4fd\ua500-\ua60c\ua610-\ua61f\ua62a\ua62b\ua640-\ua66e\ua67f-\ua697\ua6a0-\ua6ef\ua717-\ua71f\ua722-\ua788\ua78b-\ua78e\ua790-\ua793\ua7a0-\ua7aa\ua7f8-\ua801\ua803-\ua805\ua807-\ua80a\ua80c-\ua822\ua840-\ua873\ua882-\ua8b3\ua8f2-\ua8f7\ua8fb\ua90a-\ua925\ua930-\ua946\ua960-\ua97c\ua984-\ua9b2\ua9cf\uaa00-\uaa28\uaa40-\uaa42\uaa44-\uaa4b\uaa60-\uaa76\uaa7a\uaa80-\uaaaf\uaab1\uaab5\uaab6\uaab9-\uaabd\uaac0\uaac2\uaadb-\uaadd\uaae0-\uaaea\uaaf2-\uaaf4\uab01-\uab06\uab09-\uab0e\uab11-\uab16\uab20-\uab26\uab28-\uab2e\uabc0-\uabe2\uac00-\ud7a3\ud7b0-\ud7c6\ud7cb-\ud7fb\uf900-\ufa6d\ufa70-\ufad9\ufb00-\ufb06\ufb13-\ufb17\ufb1d\ufb1f-\ufb28\ufb2a-\ufb36\ufb38-\ufb3c\ufb3e\ufb40\ufb41\ufb43\ufb44\ufb46-\ufbb1\ufbd3-\ufd3d\ufd50-\ufd8f\ufd92-\ufdc7\ufdf0-\ufdfb\ufe70-\ufe74\ufe76-\ufefc\uff21-\uff3a\uff41-\uff5a\uff66-\uffbe\uffc2-\uffc7\uffca-\uffcf\uffd2-\uffd7\uffda-\uffdc"; 203 var nonASCIIidentifierChars = "\u0300-\u036f\u0483-\u0487\u0591-\u05bd\u05bf\u05c1\u05c2\u05c4\u05c5\u05c7\u0610-\u061a\u0620-\u0649\u0672-\u06d3\u06e7-\u06e8\u06fb-\u06fc\u0730-\u074a\u0800-\u0814\u081b-\u0823\u0825-\u0827\u0829-\u082d\u0840-\u0857\u08e4-\u08fe\u0900-\u0903\u093a-\u093c\u093e-\u094f\u0951-\u0957\u0962-\u0963\u0966-\u096f\u0981-\u0983\u09bc\u09be-\u09c4\u09c7\u09c8\u09d7\u09df-\u09e0\u0a01-\u0a03\u0a3c\u0a3e-\u0a42\u0a47\u0a48\u0a4b-\u0a4d\u0a51\u0a66-\u0a71\u0a75\u0a81-\u0a83\u0abc\u0abe-\u0ac5\u0ac7-\u0ac9\u0acb-\u0acd\u0ae2-\u0ae3\u0ae6-\u0aef\u0b01-\u0b03\u0b3c\u0b3e-\u0b44\u0b47\u0b48\u0b4b-\u0b4d\u0b56\u0b57\u0b5f-\u0b60\u0b66-\u0b6f\u0b82\u0bbe-\u0bc2\u0bc6-\u0bc8\u0bca-\u0bcd\u0bd7\u0be6-\u0bef\u0c01-\u0c03\u0c46-\u0c48\u0c4a-\u0c4d\u0c55\u0c56\u0c62-\u0c63\u0c66-\u0c6f\u0c82\u0c83\u0cbc\u0cbe-\u0cc4\u0cc6-\u0cc8\u0cca-\u0ccd\u0cd5\u0cd6\u0ce2-\u0ce3\u0ce6-\u0cef\u0d02\u0d03\u0d46-\u0d48\u0d57\u0d62-\u0d63\u0d66-\u0d6f\u0d82\u0d83\u0dca\u0dcf-\u0dd4\u0dd6\u0dd8-\u0ddf\u0df2\u0df3\u0e34-\u0e3a\u0e40-\u0e45\u0e50-\u0e59\u0eb4-\u0eb9\u0ec8-\u0ecd\u0ed0-\u0ed9\u0f18\u0f19\u0f20-\u0f29\u0f35\u0f37\u0f39\u0f41-\u0f47\u0f71-\u0f84\u0f86-\u0f87\u0f8d-\u0f97\u0f99-\u0fbc\u0fc6\u1000-\u1029\u1040-\u1049\u1067-\u106d\u1071-\u1074\u1082-\u108d\u108f-\u109d\u135d-\u135f\u170e-\u1710\u1720-\u1730\u1740-\u1750\u1772\u1773\u1780-\u17b2\u17dd\u17e0-\u17e9\u180b-\u180d\u1810-\u1819\u1920-\u192b\u1930-\u193b\u1951-\u196d\u19b0-\u19c0\u19c8-\u19c9\u19d0-\u19d9\u1a00-\u1a15\u1a20-\u1a53\u1a60-\u1a7c\u1a7f-\u1a89\u1a90-\u1a99\u1b46-\u1b4b\u1b50-\u1b59\u1b6b-\u1b73\u1bb0-\u1bb9\u1be6-\u1bf3\u1c00-\u1c22\u1c40-\u1c49\u1c5b-\u1c7d\u1cd0-\u1cd2\u1d00-\u1dbe\u1e01-\u1f15\u200c\u200d\u203f\u2040\u2054\u20d0-\u20dc\u20e1\u20e5-\u20f0\u2d81-\u2d96\u2de0-\u2dff\u3021-\u3028\u3099\u309a\ua640-\ua66d\ua674-\ua67d\ua69f\ua6f0-\ua6f1\ua7f8-\ua800\ua806\ua80b\ua823-\ua827\ua880-\ua881\ua8b4-\ua8c4\ua8d0-\ua8d9\ua8f3-\ua8f7\ua900-\ua909\ua926-\ua92d\ua930-\ua945\ua980-\ua983\ua9b3-\ua9c0\uaa00-\uaa27\uaa40-\uaa41\uaa4c-\uaa4d\uaa50-\uaa59\uaa7b\uaae0-\uaae9\uaaf2-\uaaf3\uabc0-\uabe1\uabec\uabed\uabf0-\uabf9\ufb20-\ufb28\ufe00-\ufe0f\ufe20-\ufe26\ufe33\ufe34\ufe4d-\ufe4f\uff10-\uff19\uff3f"; 204 var nonASCIIidentifierStart = new RegExp("[" + nonASCIIidentifierStartChars + "]"); 205 var nonASCIIidentifier = new RegExp("[" + nonASCIIidentifierStartChars + nonASCIIidentifierChars + "]"); 206 207 // Whether a single character denotes a newline. 208 209 exports.newline = /[\n\r\u2028\u2029]/; 210 211 // Matches a whole line break (where CRLF is considered a single 212 // line break). Used to count lines. 213 214 // in javascript, these two differ 215 // in python they are the same, different methods are called on them 216 exports.lineBreak = new RegExp('\r\n|' + exports.newline.source); 217 exports.allLineBreaks = new RegExp(exports.lineBreak.source, 'g'); 218 219 220 // Test whether a given character code starts an identifier. 221 222 exports.isIdentifierStart = function(code) { 223 // permit $ (36) and @ (64). @ is used in ES7 decorators. 224 if (code < 65) return code === 36 || code === 64; 225 // 65 through 91 are uppercase letters. 226 if (code < 91) return true; 227 // permit _ (95). 228 if (code < 97) return code === 95; 229 // 97 through 123 are lowercase letters. 230 if (code < 123) return true; 231 return code >= 0xaa && nonASCIIidentifierStart.test(String.fromCharCode(code)); 232 }; 233 234 // Test whether a given character is part of an identifier. 235 236 exports.isIdentifierChar = function(code) { 237 if (code < 48) return code === 36; 238 if (code < 58) return true; 239 if (code < 65) return false; 240 if (code < 91) return true; 241 if (code < 97) return code === 95; 242 if (code < 123) return true; 243 return code >= 0xaa && nonASCIIidentifier.test(String.fromCharCode(code)); 244 }; 245 246 247 /***/ }), 248 /* 1 */ 249 /***/ (function(module, exports, __webpack_require__) { 250 251 /*jshint curly:true, eqeqeq:true, laxbreak:true, noempty:false */ 252 /* 253 254 The MIT License (MIT) 255 256 Copyright (c) 2007-2017 Einar Lielmanis, Liam Newman, and contributors. 257 258 Permission is hereby granted, free of charge, to any person 259 obtaining a copy of this software and associated documentation files 260 (the "Software"), to deal in the Software without restriction, 261 including without limitation the rights to use, copy, modify, merge, 262 publish, distribute, sublicense, and/or sell copies of the Software, 263 and to permit persons to whom the Software is furnished to do so, 264 subject to the following conditions: 265 266 The above copyright notice and this permission notice shall be 267 included in all copies or substantial portions of the Software. 268 269 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 270 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 271 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 272 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 273 BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 274 ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 275 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 276 SOFTWARE. 277 */ 278 279 var mergeOpts = __webpack_require__(3).mergeOpts; 280 var acorn = __webpack_require__(0); 281 var Output = __webpack_require__(4).Output; 282 var Tokenizer = __webpack_require__(7).Tokenizer; 283 284 function remove_redundant_indentation(output, frame) { 285 // This implementation is effective but has some issues: 286 // - can cause line wrap to happen too soon due to indent removal 287 // after wrap points are calculated 288 // These issues are minor compared to ugly indentation. 289 290 if (frame.multiline_frame || 291 frame.mode === MODE.ForInitializer || 292 frame.mode === MODE.Conditional) { 293 return; 294 } 295 296 // remove one indent from each line inside this section 297 var start_index = frame.start_line_index; 298 299 output.remove_indent(start_index); 300 } 301 302 function in_array(what, arr) { 303 for (var i = 0; i < arr.length; i += 1) { 304 if (arr[i] === what) { 305 return true; 306 } 307 } 308 return false; 309 } 310 311 function trim(s) { 312 return s.replace(/^\s+|\s+$/g, ''); 313 } 314 315 function ltrim(s) { 316 return s.replace(/^\s+/g, ''); 317 } 318 319 // function rtrim(s) { 320 // return s.replace(/\s+$/g, ''); 321 // } 322 323 324 function generateMapFromStrings(list) { 325 var result = {}; 326 for (var x = 0; x < list.length; x++) { 327 // make the mapped names underscored instead of dash 328 result[list[x].replace(/-/g, '_')] = list[x]; 329 } 330 return result; 331 } 332 333 function sanitizeOperatorPosition(opPosition) { 334 opPosition = opPosition || OPERATOR_POSITION.before_newline; 335 336 if (!in_array(opPosition, validPositionValues)) { 337 throw new Error("Invalid Option Value: The option 'operator_position' must be one of the following values\n" + 338 validPositionValues + 339 "\nYou passed in: '" + opPosition + "'"); 340 } 341 342 return opPosition; 343 } 344 345 var validPositionValues = ['before-newline', 'after-newline', 'preserve-newline']; 346 347 // Generate map from array 348 var OPERATOR_POSITION = generateMapFromStrings(validPositionValues); 349 350 var OPERATOR_POSITION_BEFORE_OR_PRESERVE = [OPERATOR_POSITION.before_newline, OPERATOR_POSITION.preserve_newline]; 351 352 var MODE = { 353 BlockStatement: 'BlockStatement', // 'BLOCK' 354 Statement: 'Statement', // 'STATEMENT' 355 ObjectLiteral: 'ObjectLiteral', // 'OBJECT', 356 ArrayLiteral: 'ArrayLiteral', //'[EXPRESSION]', 357 ForInitializer: 'ForInitializer', //'(FOR-EXPRESSION)', 358 Conditional: 'Conditional', //'(COND-EXPRESSION)', 359 Expression: 'Expression' //'(EXPRESSION)' 360 }; 361 362 function Beautifier(js_source_text, options) { 363 "use strict"; 364 var output; 365 var tokens = [], 366 token_pos; 367 var tokenizer; 368 var current_token; 369 var last_type, last_last_text, indent_string; 370 var flags, previous_flags, flag_store; 371 var prefix; 372 373 var handlers, opt; 374 var baseIndentString = ''; 375 376 handlers = { 377 'TK_START_EXPR': handle_start_expr, 378 'TK_END_EXPR': handle_end_expr, 379 'TK_START_BLOCK': handle_start_block, 380 'TK_END_BLOCK': handle_end_block, 381 'TK_WORD': handle_word, 382 'TK_RESERVED': handle_word, 383 'TK_SEMICOLON': handle_semicolon, 384 'TK_STRING': handle_string, 385 'TK_EQUALS': handle_equals, 386 'TK_OPERATOR': handle_operator, 387 'TK_COMMA': handle_comma, 388 'TK_BLOCK_COMMENT': handle_block_comment, 389 'TK_COMMENT': handle_comment, 390 'TK_DOT': handle_dot, 391 'TK_UNKNOWN': handle_unknown, 392 'TK_EOF': handle_eof 393 }; 394 395 function create_flags(flags_base, mode) { 396 var next_indent_level = 0; 397 if (flags_base) { 398 next_indent_level = flags_base.indentation_level; 399 if (!output.just_added_newline() && 400 flags_base.line_indent_level > next_indent_level) { 401 next_indent_level = flags_base.line_indent_level; 402 } 403 } 404 405 var next_flags = { 406 mode: mode, 407 parent: flags_base, 408 last_text: flags_base ? flags_base.last_text : '', // last token text 409 last_word: flags_base ? flags_base.last_word : '', // last 'TK_WORD' passed 410 declaration_statement: false, 411 declaration_assignment: false, 412 multiline_frame: false, 413 inline_frame: false, 414 if_block: false, 415 else_block: false, 416 do_block: false, 417 do_while: false, 418 import_block: false, 419 in_case_statement: false, // switch(..){ INSIDE HERE } 420 in_case: false, // we're on the exact line with "case 0:" 421 case_body: false, // the indented case-action block 422 indentation_level: next_indent_level, 423 line_indent_level: flags_base ? flags_base.line_indent_level : next_indent_level, 424 start_line_index: output.get_line_number(), 425 ternary_depth: 0 426 }; 427 return next_flags; 428 } 429 430 // Some interpreters have unexpected results with foo = baz || bar; 431 options = options ? options : {}; 432 433 // Allow the setting of language/file-type specific options 434 // with inheritance of overall settings 435 options = mergeOpts(options, 'js'); 436 437 opt = {}; 438 439 // compatibility, re 440 if (options.brace_style === "expand-strict") { //graceful handling of deprecated option 441 options.brace_style = "expand"; 442 } else if (options.brace_style === "collapse-preserve-inline") { //graceful handling of deprecated option 443 options.brace_style = "collapse,preserve-inline"; 444 } else if (options.braces_on_own_line !== undefined) { //graceful handling of deprecated option 445 options.brace_style = options.braces_on_own_line ? "expand" : "collapse"; 446 } else if (!options.brace_style) { //Nothing exists to set it 447 options.brace_style = "collapse"; 448 } 449 450 //preserve-inline in delimited string will trigger brace_preserve_inline, everything 451 //else is considered a brace_style and the last one only will have an effect 452 var brace_style_split = options.brace_style.split(/[^a-zA-Z0-9_\-]+/); 453 opt.brace_preserve_inline = false; //Defaults in case one or other was not specified in meta-option 454 opt.brace_style = "collapse"; 455 for (var bs = 0; bs < brace_style_split.length; bs++) { 456 if (brace_style_split[bs] === "preserve-inline") { 457 opt.brace_preserve_inline = true; 458 } else { 459 opt.brace_style = brace_style_split[bs]; 460 } 461 } 462 463 opt.indent_size = options.indent_size ? parseInt(options.indent_size, 10) : 4; 464 opt.indent_char = options.indent_char ? options.indent_char : ' '; 465 opt.eol = options.eol ? options.eol : 'auto'; 466 opt.preserve_newlines = (options.preserve_newlines === undefined) ? true : options.preserve_newlines; 467 opt.unindent_chained_methods = (options.unindent_chained_methods === undefined) ? false : options.unindent_chained_methods; 468 opt.break_chained_methods = (options.break_chained_methods === undefined) ? false : options.break_chained_methods; 469 opt.max_preserve_newlines = (options.max_preserve_newlines === undefined) ? 0 : parseInt(options.max_preserve_newlines, 10); 470 opt.space_in_paren = (options.space_in_paren === undefined) ? false : options.space_in_paren; 471 opt.space_in_empty_paren = (options.space_in_empty_paren === undefined) ? false : options.space_in_empty_paren; 472 opt.jslint_happy = (options.jslint_happy === undefined) ? false : options.jslint_happy; 473 opt.space_after_anon_function = (options.space_after_anon_function === undefined) ? false : options.space_after_anon_function; 474 opt.keep_array_indentation = (options.keep_array_indentation === undefined) ? false : options.keep_array_indentation; 475 opt.space_before_conditional = (options.space_before_conditional === undefined) ? true : options.space_before_conditional; 476 opt.unescape_strings = (options.unescape_strings === undefined) ? false : options.unescape_strings; 477 opt.wrap_line_length = (options.wrap_line_length === undefined) ? 0 : parseInt(options.wrap_line_length, 10); 478 opt.e4x = (options.e4x === undefined) ? false : options.e4x; 479 opt.end_with_newline = (options.end_with_newline === undefined) ? false : options.end_with_newline; 480 opt.comma_first = (options.comma_first === undefined) ? false : options.comma_first; 481 opt.operator_position = sanitizeOperatorPosition(options.operator_position); 482 483 // For testing of beautify ignore:start directive 484 opt.test_output_raw = (options.test_output_raw === undefined) ? false : options.test_output_raw; 485 486 // force opt.space_after_anon_function to true if opt.jslint_happy 487 if (opt.jslint_happy) { 488 opt.space_after_anon_function = true; 489 } 490 491 if (options.indent_with_tabs) { 492 opt.indent_char = '\t'; 493 opt.indent_size = 1; 494 } 495 496 if (opt.eol === 'auto') { 497 opt.eol = '\n'; 498 if (js_source_text && acorn.lineBreak.test(js_source_text || '')) { 499 opt.eol = js_source_text.match(acorn.lineBreak)[0]; 500 } 501 } 502 503 opt.eol = opt.eol.replace(/\\r/, '\r').replace(/\\n/, '\n'); 504 505 //---------------------------------- 506 indent_string = ''; 507 while (opt.indent_size > 0) { 508 indent_string += opt.indent_char; 509 opt.indent_size -= 1; 510 } 511 512 var preindent_index = 0; 513 if (js_source_text && js_source_text.length) { 514 while ((js_source_text.charAt(preindent_index) === ' ' || 515 js_source_text.charAt(preindent_index) === '\t')) { 516 preindent_index += 1; 517 } 518 baseIndentString = js_source_text.substring(0, preindent_index); 519 js_source_text = js_source_text.substring(preindent_index); 520 } 521 522 last_type = 'TK_START_BLOCK'; // last token type 523 last_last_text = ''; // pre-last token text 524 output = new Output(indent_string, baseIndentString); 525 526 // If testing the ignore directive, start with output disable set to true 527 output.raw = opt.test_output_raw; 528 529 530 // Stack of parsing/formatting states, including MODE. 531 // We tokenize, parse, and output in an almost purely a forward-only stream of token input 532 // and formatted output. This makes the beautifier less accurate than full parsers 533 // but also far more tolerant of syntax errors. 534 // 535 // For example, the default mode is MODE.BlockStatement. If we see a '{' we push a new frame of type 536 // MODE.BlockStatement on the the stack, even though it could be object literal. If we later 537 // encounter a ":", we'll switch to to MODE.ObjectLiteral. If we then see a ";", 538 // most full parsers would die, but the beautifier gracefully falls back to 539 // MODE.BlockStatement and continues on. 540 flag_store = []; 541 set_mode(MODE.BlockStatement); 542 543 this.beautify = function() { 544 545 /*jshint onevar:true */ 546 var sweet_code; 547 tokenizer = new Tokenizer(js_source_text, opt, indent_string); 548 tokens = tokenizer.tokenize(); 549 token_pos = 0; 550 551 current_token = get_token(); 552 while (current_token) { 553 handlers[current_token.type](); 554 555 last_last_text = flags.last_text; 556 last_type = current_token.type; 557 flags.last_text = current_token.text; 558 559 token_pos += 1; 560 current_token = get_token(); 561 } 562 563 sweet_code = output.get_code(opt.end_with_newline, opt.eol); 564 565 return sweet_code; 566 }; 567 568 function handle_whitespace_and_comments(local_token, preserve_statement_flags) { 569 var newlines = local_token.newlines; 570 var keep_whitespace = opt.keep_array_indentation && is_array(flags.mode); 571 var temp_token = current_token; 572 573 for (var h = 0; h < local_token.comments_before.length; h++) { 574 // The cleanest handling of inline comments is to treat them as though they aren't there. 575 // Just continue formatting and the behavior should be logical. 576 // Also ignore unknown tokens. Again, this should result in better behavior. 577 current_token = local_token.comments_before[h]; 578 handle_whitespace_and_comments(current_token, preserve_statement_flags); 579 handlers[current_token.type](preserve_statement_flags); 580 } 581 current_token = temp_token; 582 583 if (keep_whitespace) { 584 for (var i = 0; i < newlines; i += 1) { 585 print_newline(i > 0, preserve_statement_flags); 586 } 587 } else { 588 if (opt.max_preserve_newlines && newlines > opt.max_preserve_newlines) { 589 newlines = opt.max_preserve_newlines; 590 } 591 592 if (opt.preserve_newlines) { 593 if (local_token.newlines > 1) { 594 print_newline(false, preserve_statement_flags); 595 for (var j = 1; j < newlines; j += 1) { 596 print_newline(true, preserve_statement_flags); 597 } 598 } 599 } 600 } 601 602 } 603 604 // we could use just string.split, but 605 // IE doesn't like returning empty strings 606 function split_linebreaks(s) { 607 //return s.split(/\x0d\x0a|\x0a/); 608 609 s = s.replace(acorn.allLineBreaks, '\n'); 610 var out = [], 611 idx = s.indexOf("\n"); 612 while (idx !== -1) { 613 out.push(s.substring(0, idx)); 614 s = s.substring(idx + 1); 615 idx = s.indexOf("\n"); 616 } 617 if (s.length) { 618 out.push(s); 619 } 620 return out; 621 } 622 623 var newline_restricted_tokens = ['break', 'continue', 'return', 'throw', 'yield']; 624 625 function allow_wrap_or_preserved_newline(force_linewrap) { 626 force_linewrap = (force_linewrap === undefined) ? false : force_linewrap; 627 628 // Never wrap the first token on a line 629 if (output.just_added_newline()) { 630 return; 631 } 632 633 var shouldPreserveOrForce = (opt.preserve_newlines && current_token.wanted_newline) || force_linewrap; 634 var operatorLogicApplies = in_array(flags.last_text, tokenizer.positionable_operators) || in_array(current_token.text, tokenizer.positionable_operators); 635 636 if (operatorLogicApplies) { 637 var shouldPrintOperatorNewline = ( 638 in_array(flags.last_text, tokenizer.positionable_operators) && 639 in_array(opt.operator_position, OPERATOR_POSITION_BEFORE_OR_PRESERVE) 640 ) || 641 in_array(current_token.text, tokenizer.positionable_operators); 642 shouldPreserveOrForce = shouldPreserveOrForce && shouldPrintOperatorNewline; 643 } 644 645 if (shouldPreserveOrForce) { 646 print_newline(false, true); 647 } else if (opt.wrap_line_length) { 648 if (last_type === 'TK_RESERVED' && in_array(flags.last_text, newline_restricted_tokens)) { 649 // These tokens should never have a newline inserted 650 // between them and the following expression. 651 return; 652 } 653 var proposed_line_length = output.current_line.get_character_count() + current_token.text.length + 654 (output.space_before_token ? 1 : 0); 655 if (proposed_line_length >= opt.wrap_line_length) { 656 print_newline(false, true); 657 } 658 } 659 } 660 661 function print_newline(force_newline, preserve_statement_flags) { 662 if (!preserve_statement_flags) { 663 if (flags.last_text !== ';' && flags.last_text !== ',' && flags.last_text !== '=' && last_type !== 'TK_OPERATOR') { 664 var next_token = get_token(1); 665 while (flags.mode === MODE.Statement && 666 !(flags.if_block && next_token && next_token.type === 'TK_RESERVED' && next_token.text === 'else') && 667 !flags.do_block) { 668 restore_mode(); 669 } 670 } 671 } 672 673 if (output.add_new_line(force_newline)) { 674 flags.multiline_frame = true; 675 } 676 } 677 678 function print_token_line_indentation() { 679 if (output.just_added_newline()) { 680 if (opt.keep_array_indentation && is_array(flags.mode) && current_token.wanted_newline) { 681 output.current_line.push(current_token.whitespace_before); 682 output.space_before_token = false; 683 } else if (output.set_indent(flags.indentation_level)) { 684 flags.line_indent_level = flags.indentation_level; 685 } 686 } 687 } 688 689 function print_token(printable_token) { 690 if (output.raw) { 691 output.add_raw_token(current_token); 692 return; 693 } 694 695 if (opt.comma_first && last_type === 'TK_COMMA' && 696 output.just_added_newline()) { 697 if (output.previous_line.last() === ',') { 698 var popped = output.previous_line.pop(); 699 // if the comma was already at the start of the line, 700 // pull back onto that line and reprint the indentation 701 if (output.previous_line.is_empty()) { 702 output.previous_line.push(popped); 703 output.trim(true); 704 output.current_line.pop(); 705 output.trim(); 706 } 707 708 // add the comma in front of the next token 709 print_token_line_indentation(); 710 output.add_token(','); 711 output.space_before_token = true; 712 } 713 } 714 715 printable_token = printable_token || current_token.text; 716 print_token_line_indentation(); 717 output.add_token(printable_token); 718 } 719 720 function indent() { 721 flags.indentation_level += 1; 722 } 723 724 function deindent() { 725 if (flags.indentation_level > 0 && 726 ((!flags.parent) || flags.indentation_level > flags.parent.indentation_level)) { 727 flags.indentation_level -= 1; 728 729 } 730 } 731 732 function set_mode(mode) { 733 if (flags) { 734 flag_store.push(flags); 735 previous_flags = flags; 736 } else { 737 previous_flags = create_flags(null, mode); 738 } 739 740 flags = create_flags(previous_flags, mode); 741 } 742 743 function is_array(mode) { 744 return mode === MODE.ArrayLiteral; 745 } 746 747 function is_expression(mode) { 748 return in_array(mode, [MODE.Expression, MODE.ForInitializer, MODE.Conditional]); 749 } 750 751 function restore_mode() { 752 if (flag_store.length > 0) { 753 previous_flags = flags; 754 flags = flag_store.pop(); 755 if (previous_flags.mode === MODE.Statement && !opt.unindent_chained_methods) { 756 remove_redundant_indentation(output, previous_flags); 757 } 758 } 759 } 760 761 function start_of_object_property() { 762 return flags.parent.mode === MODE.ObjectLiteral && flags.mode === MODE.Statement && ( 763 (flags.last_text === ':' && flags.ternary_depth === 0) || (last_type === 'TK_RESERVED' && in_array(flags.last_text, ['get', 'set']))); 764 } 765 766 function start_of_statement() { 767 if ( 768 (last_type === 'TK_RESERVED' && in_array(flags.last_text, ['var', 'let', 'const']) && current_token.type === 'TK_WORD') || 769 (last_type === 'TK_RESERVED' && flags.last_text === 'do') || 770 (last_type === 'TK_RESERVED' && in_array(flags.last_text, newline_restricted_tokens) && !current_token.wanted_newline) || 771 (last_type === 'TK_RESERVED' && flags.last_text === 'else' && 772 !(current_token.type === 'TK_RESERVED' && current_token.text === 'if' && !current_token.comments_before.length)) || 773 (last_type === 'TK_END_EXPR' && (previous_flags.mode === MODE.ForInitializer || previous_flags.mode === MODE.Conditional)) || 774 (last_type === 'TK_WORD' && flags.mode === MODE.BlockStatement && 775 !flags.in_case && 776 !(current_token.text === '--' || current_token.text === '++') && 777 last_last_text !== 'function' && 778 current_token.type !== 'TK_WORD' && current_token.type !== 'TK_RESERVED') || 779 (flags.mode === MODE.ObjectLiteral && ( 780 (flags.last_text === ':' && flags.ternary_depth === 0) || (last_type === 'TK_RESERVED' && in_array(flags.last_text, ['get', 'set'])))) 781 ) { 782 783 set_mode(MODE.Statement); 784 if (!opt.unindent_chained_methods) { 785 indent(); 786 } 787 788 handle_whitespace_and_comments(current_token, true); 789 790 // Issue #276: 791 // If starting a new statement with [if, for, while, do], push to a new line. 792 // if (a) if (b) if(c) d(); else e(); else f(); 793 if (!start_of_object_property()) { 794 allow_wrap_or_preserved_newline( 795 current_token.type === 'TK_RESERVED' && in_array(current_token.text, ['do', 'for', 'if', 'while'])); 796 } 797 798 return true; 799 } 800 return false; 801 } 802 803 function all_lines_start_with(lines, c) { 804 for (var i = 0; i < lines.length; i++) { 805 var line = trim(lines[i]); 806 if (line.charAt(0) !== c) { 807 return false; 808 } 809 } 810 return true; 811 } 812 813 function each_line_matches_indent(lines, indent) { 814 var i = 0, 815 len = lines.length, 816 line; 817 for (; i < len; i++) { 818 line = lines[i]; 819 // allow empty lines to pass through 820 if (line && line.indexOf(indent) !== 0) { 821 return false; 822 } 823 } 824 return true; 825 } 826 827 function is_special_word(word) { 828 return in_array(word, ['case', 'return', 'do', 'if', 'throw', 'else']); 829 } 830 831 function get_token(offset) { 832 var index = token_pos + (offset || 0); 833 return (index < 0 || index >= tokens.length) ? null : tokens[index]; 834 } 835 836 function handle_start_expr() { 837 // The conditional starts the statement if appropriate. 838 if (!start_of_statement()) { 839 handle_whitespace_and_comments(current_token); 840 } 841 842 var next_mode = MODE.Expression; 843 if (current_token.text === '[') { 844 845 if (last_type === 'TK_WORD' || flags.last_text === ')') { 846 // this is array index specifier, break immediately 847 // a[x], fn()[x] 848 if (last_type === 'TK_RESERVED' && in_array(flags.last_text, tokenizer.line_starters)) { 849 output.space_before_token = true; 850 } 851 set_mode(next_mode); 852 print_token(); 853 indent(); 854 if (opt.space_in_paren) { 855 output.space_before_token = true; 856 } 857 return; 858 } 859 860 next_mode = MODE.ArrayLiteral; 861 if (is_array(flags.mode)) { 862 if (flags.last_text === '[' || 863 (flags.last_text === ',' && (last_last_text === ']' || last_last_text === '}'))) { 864 // ], [ goes to new line 865 // }, [ goes to new line 866 if (!opt.keep_array_indentation) { 867 print_newline(); 868 } 869 } 870 } 871 872 } else { 873 if (last_type === 'TK_RESERVED' && flags.last_text === 'for') { 874 next_mode = MODE.ForInitializer; 875 } else if (last_type === 'TK_RESERVED' && in_array(flags.last_text, ['if', 'while'])) { 876 next_mode = MODE.Conditional; 877 } else { 878 // next_mode = MODE.Expression; 879 } 880 } 881 882 if (flags.last_text === ';' || last_type === 'TK_START_BLOCK') { 883 print_newline(); 884 } else if (last_type === 'TK_END_EXPR' || last_type === 'TK_START_EXPR' || last_type === 'TK_END_BLOCK' || flags.last_text === '.') { 885 // TODO: Consider whether forcing this is required. Review failing tests when removed. 886 allow_wrap_or_preserved_newline(current_token.wanted_newline); 887 // do nothing on (( and )( and ][ and ]( and .( 888 } else if (!(last_type === 'TK_RESERVED' && current_token.text === '(') && last_type !== 'TK_WORD' && last_type !== 'TK_OPERATOR') { 889 output.space_before_token = true; 890 } else if ((last_type === 'TK_RESERVED' && (flags.last_word === 'function' || flags.last_word === 'typeof')) || 891 (flags.last_text === '*' && 892 (in_array(last_last_text, ['function', 'yield']) || 893 (flags.mode === MODE.ObjectLiteral && in_array(last_last_text, ['{', ',']))))) { 894 // function() vs function () 895 // yield*() vs yield* () 896 // function*() vs function* () 897 if (opt.space_after_anon_function) { 898 output.space_before_token = true; 899 } 900 } else if (last_type === 'TK_RESERVED' && (in_array(flags.last_text, tokenizer.line_starters) || flags.last_text === 'catch')) { 901 if (opt.space_before_conditional) { 902 output.space_before_token = true; 903 } 904 } 905 906 // Should be a space between await and an IIFE, or async and an arrow function 907 if (current_token.text === '(' && last_type === 'TK_RESERVED' && in_array(flags.last_word, ['await', 'async'])) { 908 output.space_before_token = true; 909 } 910 911 // Support of this kind of newline preservation. 912 // a = (b && 913 // (c || d)); 914 if (current_token.text === '(') { 915 if (last_type === 'TK_EQUALS' || last_type === 'TK_OPERATOR') { 916 if (!start_of_object_property()) { 917 allow_wrap_or_preserved_newline(); 918 } 919 } 920 } 921 922 // Support preserving wrapped arrow function expressions 923 // a.b('c', 924 // () => d.e 925 // ) 926 if (current_token.text === '(' && last_type !== 'TK_WORD' && last_type !== 'TK_RESERVED') { 927 allow_wrap_or_preserved_newline(); 928 } 929 930 set_mode(next_mode); 931 print_token(); 932 if (opt.space_in_paren) { 933 output.space_before_token = true; 934 } 935 936 // In all cases, if we newline while inside an expression it should be indented. 937 indent(); 938 } 939 940 function handle_end_expr() { 941 // statements inside expressions are not valid syntax, but... 942 // statements must all be closed when their container closes 943 while (flags.mode === MODE.Statement) { 944 restore_mode(); 945 } 946 947 handle_whitespace_and_comments(current_token); 948 949 if (flags.multiline_frame) { 950 allow_wrap_or_preserved_newline(current_token.text === ']' && is_array(flags.mode) && !opt.keep_array_indentation); 951 } 952 953 if (opt.space_in_paren) { 954 if (last_type === 'TK_START_EXPR' && !opt.space_in_empty_paren) { 955 // () [] no inner space in empty parens like these, ever, ref #320 956 output.trim(); 957 output.space_before_token = false; 958 } else { 959 output.space_before_token = true; 960 } 961 } 962 if (current_token.text === ']' && opt.keep_array_indentation) { 963 print_token(); 964 restore_mode(); 965 } else { 966 restore_mode(); 967 print_token(); 968 } 969 remove_redundant_indentation(output, previous_flags); 970 971 // do {} while () // no statement required after 972 if (flags.do_while && previous_flags.mode === MODE.Conditional) { 973 previous_flags.mode = MODE.Expression; 974 flags.do_block = false; 975 flags.do_while = false; 976 977 } 978 } 979 980 function handle_start_block() { 981 handle_whitespace_and_comments(current_token); 982 983 // Check if this is should be treated as a ObjectLiteral 984 var next_token = get_token(1); 985 var second_token = get_token(2); 986 if (second_token && ( 987 (in_array(second_token.text, [':', ',']) && in_array(next_token.type, ['TK_STRING', 'TK_WORD', 'TK_RESERVED'])) || 988 (in_array(next_token.text, ['get', 'set', '...']) && in_array(second_token.type, ['TK_WORD', 'TK_RESERVED'])) 989 )) { 990 // We don't support TypeScript,but we didn't break it for a very long time. 991 // We'll try to keep not breaking it. 992 if (!in_array(last_last_text, ['class', 'interface'])) { 993 set_mode(MODE.ObjectLiteral); 994 } else { 995 set_mode(MODE.BlockStatement); 996 } 997 } else if (last_type === 'TK_OPERATOR' && flags.last_text === '=>') { 998 // arrow function: (param1, paramN) => { statements } 999 set_mode(MODE.BlockStatement); 1000 } else if (in_array(last_type, ['TK_EQUALS', 'TK_START_EXPR', 'TK_COMMA', 'TK_OPERATOR']) || 1001 (last_type === 'TK_RESERVED' && in_array(flags.last_text, ['return', 'throw', 'import', 'default'])) 1002 ) { 1003 // Detecting shorthand function syntax is difficult by scanning forward, 1004 // so check the surrounding context. 1005 // If the block is being returned, imported, export default, passed as arg, 1006 // assigned with = or assigned in a nested object, treat as an ObjectLiteral. 1007 set_mode(MODE.ObjectLiteral); 1008 } else { 1009 set_mode(MODE.BlockStatement); 1010 } 1011 1012 var empty_braces = !next_token.comments_before.length && next_token.text === '}'; 1013 var empty_anonymous_function = empty_braces && flags.last_word === 'function' && 1014 last_type === 'TK_END_EXPR'; 1015 1016 if (opt.brace_preserve_inline) // check for inline, set inline_frame if so 1017 { 1018 // search forward for a newline wanted inside this block 1019 var index = 0; 1020 var check_token = null; 1021 flags.inline_frame = true; 1022 do { 1023 index += 1; 1024 check_token = get_token(index); 1025 if (check_token.wanted_newline) { 1026 flags.inline_frame = false; 1027 break; 1028 } 1029 } while (check_token.type !== 'TK_EOF' && 1030 !(check_token.type === 'TK_END_BLOCK' && check_token.opened === current_token)); 1031 } 1032 1033 if ((opt.brace_style === "expand" || 1034 (opt.brace_style === "none" && current_token.wanted_newline)) && 1035 !flags.inline_frame) { 1036 if (last_type !== 'TK_OPERATOR' && 1037 (empty_anonymous_function || 1038 last_type === 'TK_EQUALS' || 1039 (last_type === 'TK_RESERVED' && is_special_word(flags.last_text) && flags.last_text !== 'else'))) { 1040 output.space_before_token = true; 1041 } else { 1042 print_newline(false, true); 1043 } 1044 } else { // collapse || inline_frame 1045 if (is_array(previous_flags.mode) && (last_type === 'TK_START_EXPR' || last_type === 'TK_COMMA')) { 1046 if (last_type === 'TK_COMMA' || opt.space_in_paren) { 1047 output.space_before_token = true; 1048 } 1049 1050 if (last_type === 'TK_COMMA' || (last_type === 'TK_START_EXPR' && flags.inline_frame)) { 1051 allow_wrap_or_preserved_newline(); 1052 previous_flags.multiline_frame = previous_flags.multiline_frame || flags.multiline_frame; 1053 flags.multiline_frame = false; 1054 } 1055 } 1056 if (last_type !== 'TK_OPERATOR' && last_type !== 'TK_START_EXPR') { 1057 if (last_type === 'TK_START_BLOCK' && !flags.inline_frame) { 1058 print_newline(); 1059 } else { 1060 output.space_before_token = true; 1061 } 1062 } 1063 } 1064 print_token(); 1065 indent(); 1066 } 1067 1068 function handle_end_block() { 1069 // statements must all be closed when their container closes 1070 handle_whitespace_and_comments(current_token); 1071 1072 while (flags.mode === MODE.Statement) { 1073 restore_mode(); 1074 } 1075 1076 var empty_braces = last_type === 'TK_START_BLOCK'; 1077 1078 if (flags.inline_frame && !empty_braces) { // try inline_frame (only set if opt.braces-preserve-inline) first 1079 output.space_before_token = true; 1080 } else if (opt.brace_style === "expand") { 1081 if (!empty_braces) { 1082 print_newline(); 1083 } 1084 } else { 1085 // skip {} 1086 if (!empty_braces) { 1087 if (is_array(flags.mode) && opt.keep_array_indentation) { 1088 // we REALLY need a newline here, but newliner would skip that 1089 opt.keep_array_indentation = false; 1090 print_newline(); 1091 opt.keep_array_indentation = true; 1092 1093 } else { 1094 print_newline(); 1095 } 1096 } 1097 } 1098 restore_mode(); 1099 print_token(); 1100 } 1101 1102 function handle_word() { 1103 if (current_token.type === 'TK_RESERVED') { 1104 if (in_array(current_token.text, ['set', 'get']) && flags.mode !== MODE.ObjectLiteral) { 1105 current_token.type = 'TK_WORD'; 1106 } else if (in_array(current_token.text, ['as', 'from']) && !flags.import_block) { 1107 current_token.type = 'TK_WORD'; 1108 } else if (flags.mode === MODE.ObjectLiteral) { 1109 var next_token = get_token(1); 1110 if (next_token.text === ':') { 1111 current_token.type = 'TK_WORD'; 1112 } 1113 } 1114 } 1115 1116 if (start_of_statement()) { 1117 // The conditional starts the statement if appropriate. 1118 if (last_type === 'TK_RESERVED' && in_array(flags.last_text, ['var', 'let', 'const']) && current_token.type === 'TK_WORD') { 1119 flags.declaration_statement = true; 1120 } 1121 } else if (current_token.wanted_newline && !is_expression(flags.mode) && 1122 (last_type !== 'TK_OPERATOR' || (flags.last_text === '--' || flags.last_text === '++')) && 1123 last_type !== 'TK_EQUALS' && 1124 (opt.preserve_newlines || !(last_type === 'TK_RESERVED' && in_array(flags.last_text, ['var', 'let', 'const', 'set', 'get'])))) { 1125 handle_whitespace_and_comments(current_token); 1126 print_newline(); 1127 } else { 1128 handle_whitespace_and_comments(current_token); 1129 } 1130 1131 if (flags.do_block && !flags.do_while) { 1132 if (current_token.type === 'TK_RESERVED' && current_token.text === 'while') { 1133 // do {} ## while () 1134 output.space_before_token = true; 1135 print_token(); 1136 output.space_before_token = true; 1137 flags.do_while = true; 1138 return; 1139 } else { 1140 // do {} should always have while as the next word. 1141 // if we don't see the expected while, recover 1142 print_newline(); 1143 flags.do_block = false; 1144 } 1145 } 1146 1147 // if may be followed by else, or not 1148 // Bare/inline ifs are tricky 1149 // Need to unwind the modes correctly: if (a) if (b) c(); else d(); else e(); 1150 if (flags.if_block) { 1151 if (!flags.else_block && (current_token.type === 'TK_RESERVED' && current_token.text === 'else')) { 1152 flags.else_block = true; 1153 } else { 1154 while (flags.mode === MODE.Statement) { 1155 restore_mode(); 1156 } 1157 flags.if_block = false; 1158 flags.else_block = false; 1159 } 1160 } 1161 1162 if (current_token.type === 'TK_RESERVED' && (current_token.text === 'case' || (current_token.text === 'default' && flags.in_case_statement))) { 1163 print_newline(); 1164 if (flags.case_body || opt.jslint_happy) { 1165 // switch cases following one another 1166 deindent(); 1167 flags.case_body = false; 1168 } 1169 print_token(); 1170 flags.in_case = true; 1171 flags.in_case_statement = true; 1172 return; 1173 } 1174 1175 if (last_type === 'TK_COMMA' || last_type === 'TK_START_EXPR' || last_type === 'TK_EQUALS' || last_type === 'TK_OPERATOR') { 1176 if (!start_of_object_property()) { 1177 allow_wrap_or_preserved_newline(); 1178 } 1179 } 1180 1181 if (current_token.type === 'TK_RESERVED' && current_token.text === 'function') { 1182 if (in_array(flags.last_text, ['}', ';']) || 1183 (output.just_added_newline() && !(in_array(flags.last_text, ['(', '[', '{', ':', '=', ',']) || last_type === 'TK_OPERATOR'))) { 1184 // make sure there is a nice clean space of at least one blank line 1185 // before a new function definition 1186 if (!output.just_added_blankline() && !current_token.comments_before.length) { 1187 print_newline(); 1188 print_newline(true); 1189 } 1190 } 1191 if (last_type === 'TK_RESERVED' || last_type === 'TK_WORD') { 1192 if (last_type === 'TK_RESERVED' && ( 1193 in_array(flags.last_text, ['get', 'set', 'new', 'export', 'async']) || 1194 in_array(flags.last_text, newline_restricted_tokens))) { 1195 output.space_before_token = true; 1196 } else if (last_type === 'TK_RESERVED' && flags.last_text === 'default' && last_last_text === 'export') { 1197 output.space_before_token = true; 1198 } else { 1199 print_newline(); 1200 } 1201 } else if (last_type === 'TK_OPERATOR' || flags.last_text === '=') { 1202 // foo = function 1203 output.space_before_token = true; 1204 } else if (!flags.multiline_frame && (is_expression(flags.mode) || is_array(flags.mode))) { 1205 // (function 1206 } else { 1207 print_newline(); 1208 } 1209 1210 print_token(); 1211 flags.last_word = current_token.text; 1212 return; 1213 } 1214 1215 prefix = 'NONE'; 1216 1217 if (last_type === 'TK_END_BLOCK') { 1218 1219 if (previous_flags.inline_frame) { 1220 prefix = 'SPACE'; 1221 } else if (!(current_token.type === 'TK_RESERVED' && in_array(current_token.text, ['else', 'catch', 'finally', 'from']))) { 1222 prefix = 'NEWLINE'; 1223 } else { 1224 if (opt.brace_style === "expand" || 1225 opt.brace_style === "end-expand" || 1226 (opt.brace_style === "none" && current_token.wanted_newline)) { 1227 prefix = 'NEWLINE'; 1228 } else { 1229 prefix = 'SPACE'; 1230 output.space_before_token = true; 1231 } 1232 } 1233 } else if (last_type === 'TK_SEMICOLON' && flags.mode === MODE.BlockStatement) { 1234 // TODO: Should this be for STATEMENT as well? 1235 prefix = 'NEWLINE'; 1236 } else if (last_type === 'TK_SEMICOLON' && is_expression(flags.mode)) { 1237 prefix = 'SPACE'; 1238 } else if (last_type === 'TK_STRING') { 1239 prefix = 'NEWLINE'; 1240 } else if (last_type === 'TK_RESERVED' || last_type === 'TK_WORD' || 1241 (flags.last_text === '*' && 1242 (in_array(last_last_text, ['function', 'yield']) || 1243 (flags.mode === MODE.ObjectLiteral && in_array(last_last_text, ['{', ',']))))) { 1244 prefix = 'SPACE'; 1245 } else if (last_type === 'TK_START_BLOCK') { 1246 if (flags.inline_frame) { 1247 prefix = 'SPACE'; 1248 } else { 1249 prefix = 'NEWLINE'; 1250 } 1251 } else if (last_type === 'TK_END_EXPR') { 1252 output.space_before_token = true; 1253 prefix = 'NEWLINE'; 1254 } 1255 1256 if (current_token.type === 'TK_RESERVED' && in_array(current_token.text, tokenizer.line_starters) && flags.last_text !== ')') { 1257 if (flags.inline_frame || flags.last_text === 'else' || flags.last_text === 'export') { 1258 prefix = 'SPACE'; 1259 } else { 1260 prefix = 'NEWLINE'; 1261 } 1262 1263 } 1264 1265 if (current_token.type === 'TK_RESERVED' && in_array(current_token.text, ['else', 'catch', 'finally'])) { 1266 if ((!(last_type === 'TK_END_BLOCK' && previous_flags.mode === MODE.BlockStatement) || 1267 opt.brace_style === "expand" || 1268 opt.brace_style === "end-expand" || 1269 (opt.brace_style === "none" && current_token.wanted_newline)) && 1270 !flags.inline_frame) { 1271 print_newline(); 1272 } else { 1273 output.trim(true); 1274 var line = output.current_line; 1275 // If we trimmed and there's something other than a close block before us 1276 // put a newline back in. Handles '} // comment' scenario. 1277 if (line.last() !== '}') { 1278 print_newline(); 1279 } 1280 output.space_before_token = true; 1281 } 1282 } else if (prefix === 'NEWLINE') { 1283 if (last_type === 'TK_RESERVED' && is_special_word(flags.last_text)) { 1284 // no newline between 'return nnn' 1285 output.space_before_token = true; 1286 } else if (last_type !== 'TK_END_EXPR') { 1287 if ((last_type !== 'TK_START_EXPR' || !(current_token.type === 'TK_RESERVED' && in_array(current_token.text, ['var', 'let', 'const']))) && flags.last_text !== ':') { 1288 // no need to force newline on 'var': for (var x = 0...) 1289 if (current_token.type === 'TK_RESERVED' && current_token.text === 'if' && flags.last_text === 'else') { 1290 // no newline for } else if { 1291 output.space_before_token = true; 1292 } else { 1293 print_newline(); 1294 } 1295 } 1296 } else if (current_token.type === 'TK_RESERVED' && in_array(current_token.text, tokenizer.line_starters) && flags.last_text !== ')') { 1297 print_newline(); 1298 } 1299 } else if (flags.multiline_frame && is_array(flags.mode) && flags.last_text === ',' && last_last_text === '}') { 1300 print_newline(); // }, in lists get a newline treatment 1301 } else if (prefix === 'SPACE') { 1302 output.space_before_token = true; 1303 } 1304 print_token(); 1305 flags.last_word = current_token.text; 1306 1307 if (current_token.type === 'TK_RESERVED') { 1308 if (current_token.text === 'do') { 1309 flags.do_block = true; 1310 } else if (current_token.text === 'if') { 1311 flags.if_block = true; 1312 } else if (current_token.text === 'import') { 1313 flags.import_block = true; 1314 } else if (flags.import_block && current_token.type === 'TK_RESERVED' && current_token.text === 'from') { 1315 flags.import_block = false; 1316 } 1317 } 1318 } 1319 1320 function handle_semicolon() { 1321 if (start_of_statement()) { 1322 // The conditional starts the statement if appropriate. 1323 // Semicolon can be the start (and end) of a statement 1324 output.space_before_token = false; 1325 } else { 1326 handle_whitespace_and_comments(current_token); 1327 } 1328 1329 var next_token = get_token(1); 1330 while (flags.mode === MODE.Statement && 1331 !(flags.if_block && next_token && next_token.type === 'TK_RESERVED' && next_token.text === 'else') && 1332 !flags.do_block) { 1333 restore_mode(); 1334 } 1335 1336 // hacky but effective for the moment 1337 if (flags.import_block) { 1338 flags.import_block = false; 1339 } 1340 print_token(); 1341 } 1342 1343 function handle_string() { 1344 if (start_of_statement()) { 1345 // The conditional starts the statement if appropriate. 1346 // One difference - strings want at least a space before 1347 output.space_before_token = true; 1348 } else { 1349 handle_whitespace_and_comments(current_token); 1350 if (last_type === 'TK_RESERVED' || last_type === 'TK_WORD' || flags.inline_frame) { 1351 output.space_before_token = true; 1352 } else if (last_type === 'TK_COMMA' || last_type === 'TK_START_EXPR' || last_type === 'TK_EQUALS' || last_type === 'TK_OPERATOR') { 1353 if (!start_of_object_property()) { 1354 allow_wrap_or_preserved_newline(); 1355 } 1356 } else { 1357 print_newline(); 1358 } 1359 } 1360 print_token(); 1361 } 1362 1363 function handle_equals() { 1364 if (start_of_statement()) { 1365 // The conditional starts the statement if appropriate. 1366 } else { 1367 handle_whitespace_and_comments(current_token); 1368 } 1369 1370 if (flags.declaration_statement) { 1371 // just got an '=' in a var-line, different formatting/line-breaking, etc will now be done 1372 flags.declaration_assignment = true; 1373 } 1374 output.space_before_token = true; 1375 print_token(); 1376 output.space_before_token = true; 1377 } 1378 1379 function handle_comma() { 1380 handle_whitespace_and_comments(current_token, true); 1381 1382 print_token(); 1383 output.space_before_token = true; 1384 if (flags.declaration_statement) { 1385 if (is_expression(flags.parent.mode)) { 1386 // do not break on comma, for(var a = 1, b = 2) 1387 flags.declaration_assignment = false; 1388 } 1389 1390 if (flags.declaration_assignment) { 1391 flags.declaration_assignment = false; 1392 print_newline(false, true); 1393 } else if (opt.comma_first) { 1394 // for comma-first, we want to allow a newline before the comma 1395 // to turn into a newline after the comma, which we will fixup later 1396 allow_wrap_or_preserved_newline(); 1397 } 1398 } else if (flags.mode === MODE.ObjectLiteral || 1399 (flags.mode === MODE.Statement && flags.parent.mode === MODE.ObjectLiteral)) { 1400 if (flags.mode === MODE.Statement) { 1401 restore_mode(); 1402 } 1403 1404 if (!flags.inline_frame) { 1405 print_newline(); 1406 } 1407 } else if (opt.comma_first) { 1408 // EXPR or DO_BLOCK 1409 // for comma-first, we want to allow a newline before the comma 1410 // to turn into a newline after the comma, which we will fixup later 1411 allow_wrap_or_preserved_newline(); 1412 } 1413 } 1414 1415 function handle_operator() { 1416 var isGeneratorAsterisk = current_token.text === '*' && 1417 ((last_type === 'TK_RESERVED' && in_array(flags.last_text, ['function', 'yield'])) || 1418 (in_array(last_type, ['TK_START_BLOCK', 'TK_COMMA', 'TK_END_BLOCK', 'TK_SEMICOLON'])) 1419 ); 1420 var isUnary = in_array(current_token.text, ['-', '+']) && ( 1421 in_array(last_type, ['TK_START_BLOCK', 'TK_START_EXPR', 'TK_EQUALS', 'TK_OPERATOR']) || 1422 in_array(flags.last_text, tokenizer.line_starters) || 1423 flags.last_text === ',' 1424 ); 1425 1426 if (start_of_statement()) { 1427 // The conditional starts the statement if appropriate. 1428 } else { 1429 var preserve_statement_flags = !isGeneratorAsterisk; 1430 handle_whitespace_and_comments(current_token, preserve_statement_flags); 1431 } 1432 1433 if (last_type === 'TK_RESERVED' && is_special_word(flags.last_text)) { 1434 // "return" had a special handling in TK_WORD. Now we need to return the favor 1435 output.space_before_token = true; 1436 print_token(); 1437 return; 1438 } 1439 1440 // hack for actionscript's import .*; 1441 if (current_token.text === '*' && last_type === 'TK_DOT') { 1442 print_token(); 1443 return; 1444 } 1445 1446 if (current_token.text === '::') { 1447 // no spaces around exotic namespacing syntax operator 1448 print_token(); 1449 return; 1450 } 1451 1452 // Allow line wrapping between operators when operator_position is 1453 // set to before or preserve 1454 if (last_type === 'TK_OPERATOR' && in_array(opt.operator_position, OPERATOR_POSITION_BEFORE_OR_PRESERVE)) { 1455 allow_wrap_or_preserved_newline(); 1456 } 1457 1458 if (current_token.text === ':' && flags.in_case) { 1459 flags.case_body = true; 1460 indent(); 1461 print_token(); 1462 print_newline(); 1463 flags.in_case = false; 1464 return; 1465 } 1466 1467 var space_before = true; 1468 var space_after = true; 1469 var in_ternary = false; 1470 if (current_token.text === ':') { 1471 if (flags.ternary_depth === 0) { 1472 // Colon is invalid javascript outside of ternary and object, but do our best to guess what was meant. 1473 space_before = false; 1474 } else { 1475 flags.ternary_depth -= 1; 1476 in_ternary = true; 1477 } 1478 } else if (current_token.text === '?') { 1479 flags.ternary_depth += 1; 1480 } 1481 1482 // let's handle the operator_position option prior to any conflicting logic 1483 if (!isUnary && !isGeneratorAsterisk && opt.preserve_newlines && in_array(current_token.text, tokenizer.positionable_operators)) { 1484 var isColon = current_token.text === ':'; 1485 var isTernaryColon = (isColon && in_ternary); 1486 var isOtherColon = (isColon && !in_ternary); 1487 1488 switch (opt.operator_position) { 1489 case OPERATOR_POSITION.before_newline: 1490 // if the current token is : and it's not a ternary statement then we set space_before to false 1491 output.space_before_token = !isOtherColon; 1492 1493 print_token(); 1494 1495 if (!isColon || isTernaryColon) { 1496 allow_wrap_or_preserved_newline(); 1497 } 1498 1499 output.space_before_token = true; 1500 return; 1501 1502 case OPERATOR_POSITION.after_newline: 1503 // if the current token is anything but colon, or (via deduction) it's a colon and in a ternary statement, 1504 // then print a newline. 1505 1506 output.space_before_token = true; 1507 1508 if (!isColon || isTernaryColon) { 1509 if (get_token(1).wanted_newline) { 1510 print_newline(false, true); 1511 } else { 1512 allow_wrap_or_preserved_newline(); 1513 } 1514 } else { 1515 output.space_before_token = false; 1516 } 1517 1518 print_token(); 1519 1520 output.space_before_token = true; 1521 return; 1522 1523 case OPERATOR_POSITION.preserve_newline: 1524 if (!isOtherColon) { 1525 allow_wrap_or_preserved_newline(); 1526 } 1527 1528 // if we just added a newline, or the current token is : and it's not a ternary statement, 1529 // then we set space_before to false 1530 space_before = !(output.just_added_newline() || isOtherColon); 1531 1532 output.space_before_token = space_before; 1533 print_token(); 1534 output.space_before_token = true; 1535 return; 1536 } 1537 } 1538 1539 if (isGeneratorAsterisk) { 1540 allow_wrap_or_preserved_newline(); 1541 space_before = false; 1542 var next_token = get_token(1); 1543 space_after = next_token && in_array(next_token.type, ['TK_WORD', 'TK_RESERVED']); 1544 } else if (current_token.text === '...') { 1545 allow_wrap_or_preserved_newline(); 1546 space_before = last_type === 'TK_START_BLOCK'; 1547 space_after = false; 1548 } else if (in_array(current_token.text, ['--', '++', '!', '~']) || isUnary) { 1549 // unary operators (and binary +/- pretending to be unary) special cases 1550 1551 space_before = false; 1552 space_after = false; 1553 1554 // http://www.ecma-international.org/ecma-262/5.1/#sec-7.9.1 1555 // if there is a newline between -- or ++ and anything else we should preserve it. 1556 if (current_token.wanted_newline && (current_token.text === '--' || current_token.text === '++')) { 1557 print_newline(false, true); 1558 } 1559 1560 if (flags.last_text === ';' && is_expression(flags.mode)) { 1561 // for (;; ++i) 1562 // ^^^ 1563 space_before = true; 1564 } 1565 1566 if (last_type === 'TK_RESERVED') { 1567 space_before = true; 1568 } else if (last_type === 'TK_END_EXPR') { 1569 space_before = !(flags.last_text === ']' && (current_token.text === '--' || current_token.text === '++')); 1570 } else if (last_type === 'TK_OPERATOR') { 1571 // a++ + ++b; 1572 // a - -b 1573 space_before = in_array(current_token.text, ['--', '-', '++', '+']) && in_array(flags.last_text, ['--', '-', '++', '+']); 1574 // + and - are not unary when preceeded by -- or ++ operator 1575 // a-- + b 1576 // a * +b 1577 // a - -b 1578 if (in_array(current_token.text, ['+', '-']) && in_array(flags.last_text, ['--', '++'])) { 1579 space_after = true; 1580 } 1581 } 1582 1583 1584 if (((flags.mode === MODE.BlockStatement && !flags.inline_frame) || flags.mode === MODE.Statement) && 1585 (flags.last_text === '{' || flags.last_text === ';')) { 1586 // { foo; --i } 1587 // foo(); --bar; 1588 print_newline(); 1589 } 1590 } 1591 1592 output.space_before_token = output.space_before_token || space_before; 1593 print_token(); 1594 output.space_before_token = space_after; 1595 } 1596 1597 function handle_block_comment(preserve_statement_flags) { 1598 if (output.raw) { 1599 output.add_raw_token(current_token); 1600 if (current_token.directives && current_token.directives.preserve === 'end') { 1601 // If we're testing the raw output behavior, do not allow a directive to turn it off. 1602 output.raw = opt.test_output_raw; 1603 } 1604 return; 1605 } 1606 1607 if (current_token.directives) { 1608 print_newline(false, preserve_statement_flags); 1609 print_token(); 1610 if (current_token.directives.preserve === 'start') { 1611 output.raw = true; 1612 } 1613 print_newline(false, true); 1614 return; 1615 } 1616 1617 // inline block 1618 if (!acorn.newline.test(current_token.text) && !current_token.wanted_newline) { 1619 output.space_before_token = true; 1620 print_token(); 1621 output.space_before_token = true; 1622 return; 1623 } 1624 1625 var lines = split_linebreaks(current_token.text); 1626 var j; // iterator for this case 1627 var javadoc = false; 1628 var starless = false; 1629 var lastIndent = current_token.whitespace_before; 1630 var lastIndentLength = lastIndent.length; 1631 1632 // block comment starts with a new line 1633 print_newline(false, preserve_statement_flags); 1634 if (lines.length > 1) { 1635 javadoc = all_lines_start_with(lines.slice(1), '*'); 1636 starless = each_line_matches_indent(lines.slice(1), lastIndent); 1637 } 1638 1639 // first line always indented 1640 print_token(lines[0]); 1641 for (j = 1; j < lines.length; j++) { 1642 print_newline(false, true); 1643 if (javadoc) { 1644 // javadoc: reformat and re-indent 1645 print_token(' ' + ltrim(lines[j])); 1646 } else if (starless && lines[j].length > lastIndentLength) { 1647 // starless: re-indent non-empty content, avoiding trim 1648 print_token(lines[j].substring(lastIndentLength)); 1649 } else { 1650 // normal comments output raw 1651 output.add_token(lines[j]); 1652 } 1653 } 1654 1655 // for comments of more than one line, make sure there's a new line after 1656 print_newline(false, preserve_statement_flags); 1657 } 1658 1659 function handle_comment(preserve_statement_flags) { 1660 if (current_token.wanted_newline) { 1661 print_newline(false, preserve_statement_flags); 1662 } else { 1663 output.trim(true); 1664 } 1665 1666 output.space_before_token = true; 1667 print_token(); 1668 print_newline(false, preserve_statement_flags); 1669 } 1670 1671 function handle_dot() { 1672 if (start_of_statement()) { 1673 // The conditional starts the statement if appropriate. 1674 } else { 1675 handle_whitespace_and_comments(current_token, true); 1676 } 1677 1678 if (last_type === 'TK_RESERVED' && is_special_word(flags.last_text)) { 1679 output.space_before_token = true; 1680 } else { 1681 // allow preserved newlines before dots in general 1682 // force newlines on dots after close paren when break_chained - for bar().baz() 1683 allow_wrap_or_preserved_newline(flags.last_text === ')' && opt.break_chained_methods); 1684 } 1685 1686 print_token(); 1687 } 1688 1689 function handle_unknown(preserve_statement_flags) { 1690 print_token(); 1691 1692 if (current_token.text[current_token.text.length - 1] === '\n') { 1693 print_newline(false, preserve_statement_flags); 1694 } 1695 } 1696 1697 function handle_eof() { 1698 // Unwind any open statements 1699 while (flags.mode === MODE.Statement) { 1700 restore_mode(); 1701 } 1702 handle_whitespace_and_comments(current_token); 1703 } 1704 } 1705 1706 module.exports.Beautifier = Beautifier; 1707 1708 /***/ }), 1709 /* 2 */ 1710 /***/ (function(module, exports) { 1711 1712 /*jshint curly:true, eqeqeq:true, laxbreak:true, noempty:false */ 1713 /* 1714 1715 The MIT License (MIT) 1716 1717 Copyright (c) 2007-2017 Einar Lielmanis, Liam Newman, and contributors. 1718 1719 Permission is hereby granted, free of charge, to any person 1720 obtaining a copy of this software and associated documentation files 1721 (the "Software"), to deal in the Software without restriction, 1722 including without limitation the rights to use, copy, modify, merge, 1723 publish, distribute, sublicense, and/or sell copies of the Software, 1724 and to permit persons to whom the Software is furnished to do so, 1725 subject to the following conditions: 1726 1727 The above copyright notice and this permission notice shall be 1728 included in all copies or substantial portions of the Software. 1729 1730 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 1731 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 1732 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 1733 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 1734 BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 1735 ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 1736 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 1737 SOFTWARE. 1738 */ 1739 1740 function InputScanner(input) { 1741 var _input = input; 1742 var _input_length = _input.length; 1743 var _position = 0; 1744 1745 this.back = function() { 1746 _position -= 1; 1747 }; 1748 1749 this.hasNext = function() { 1750 return _position < _input_length; 1751 }; 1752 1753 this.next = function() { 1754 var val = null; 1755 if (this.hasNext()) { 1756 val = _input.charAt(_position); 1757 _position += 1; 1758 } 1759 return val; 1760 }; 1761 1762 this.peek = function(index) { 1763 var val = null; 1764 index = index || 0; 1765 index += _position; 1766 if (index >= 0 && index < _input_length) { 1767 val = _input.charAt(index); 1768 } 1769 return val; 1770 }; 1771 1772 this.peekCharCode = function(index) { 1773 var val = 0; 1774 index = index || 0; 1775 index += _position; 1776 if (index >= 0 && index < _input_length) { 1777 val = _input.charCodeAt(index); 1778 } 1779 return val; 1780 }; 1781 1782 this.test = function(pattern, index) { 1783 index = index || 0; 1784 pattern.lastIndex = _position + index; 1785 return pattern.test(_input); 1786 }; 1787 1788 this.testChar = function(pattern, index) { 1789 var val = this.peek(index); 1790 return val !== null && pattern.test(val); 1791 }; 1792 1793 this.match = function(pattern) { 1794 pattern.lastIndex = _position; 1795 var pattern_match = pattern.exec(_input); 1796 if (pattern_match && pattern_match.index === _position) { 1797 _position += pattern_match[0].length; 1798 } else { 1799 pattern_match = null; 1800 } 1801 return pattern_match; 1802 }; 1803 } 1804 1805 1806 module.exports.InputScanner = InputScanner; 1807 1808 1809 /***/ }), 1810 /* 3 */ 1811 /***/ (function(module, exports) { 1812 1813 /*jshint curly:true, eqeqeq:true, laxbreak:true, noempty:false */ 1814 /* 1815 1816 The MIT License (MIT) 1817 1818 Copyright (c) 2007-2017 Einar Lielmanis, Liam Newman, and contributors. 1819 1820 Permission is hereby granted, free of charge, to any person 1821 obtaining a copy of this software and associated documentation files 1822 (the "Software"), to deal in the Software without restriction, 1823 including without limitation the rights to use, copy, modify, merge, 1824 publish, distribute, sublicense, and/or sell copies of the Software, 1825 and to permit persons to whom the Software is furnished to do so, 1826 subject to the following conditions: 1827 1828 The above copyright notice and this permission notice shall be 1829 included in all copies or substantial portions of the Software. 1830 1831 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 1832 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 1833 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 1834 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 1835 BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 1836 ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 1837 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 1838 SOFTWARE. 1839 */ 1840 1841 function mergeOpts(allOptions, targetType) { 1842 var finalOpts = {}; 1843 var name; 1844 1845 for (name in allOptions) { 1846 if (name !== targetType) { 1847 finalOpts[name] = allOptions[name]; 1848 } 1849 } 1850 1851 //merge in the per type settings for the targetType 1852 if (targetType in allOptions) { 1853 for (name in allOptions[targetType]) { 1854 finalOpts[name] = allOptions[targetType][name]; 1855 } 1856 } 1857 return finalOpts; 1858 } 1859 1860 module.exports.mergeOpts = mergeOpts; 1861 1862 1863 /***/ }), 1864 /* 4 */ 1865 /***/ (function(module, exports) { 1866 1867 /*jshint curly:true, eqeqeq:true, laxbreak:true, noempty:false */ 1868 /* 1869 1870 The MIT License (MIT) 1871 1872 Copyright (c) 2007-2017 Einar Lielmanis, Liam Newman, and contributors. 1873 1874 Permission is hereby granted, free of charge, to any person 1875 obtaining a copy of this software and associated documentation files 1876 (the "Software"), to deal in the Software without restriction, 1877 including without limitation the rights to use, copy, modify, merge, 1878 publish, distribute, sublicense, and/or sell copies of the Software, 1879 and to permit persons to whom the Software is furnished to do so, 1880 subject to the following conditions: 1881 1882 The above copyright notice and this permission notice shall be 1883 included in all copies or substantial portions of the Software. 1884 1885 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 1886 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 1887 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 1888 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 1889 BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 1890 ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 1891 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 1892 SOFTWARE. 1893 */ 1894 1895 function OutputLine(parent) { 1896 var _character_count = 0; 1897 // use indent_count as a marker for lines that have preserved indentation 1898 var _indent_count = -1; 1899 1900 var _items = []; 1901 var _empty = true; 1902 1903 this.set_indent = function(level) { 1904 _character_count = parent.baseIndentLength + level * parent.indent_length; 1905 _indent_count = level; 1906 }; 1907 1908 this.get_character_count = function() { 1909 return _character_count; 1910 }; 1911 1912 this.is_empty = function() { 1913 return _empty; 1914 }; 1915 1916 this.last = function() { 1917 if (!this._empty) { 1918 return _items[_items.length - 1]; 1919 } else { 1920 return null; 1921 } 1922 }; 1923 1924 this.push = function(input) { 1925 _items.push(input); 1926 _character_count += input.length; 1927 _empty = false; 1928 }; 1929 1930 this.pop = function() { 1931 var item = null; 1932 if (!_empty) { 1933 item = _items.pop(); 1934 _character_count -= item.length; 1935 _empty = _items.length === 0; 1936 } 1937 return item; 1938 }; 1939 1940 this.remove_indent = function() { 1941 if (_indent_count > 0) { 1942 _indent_count -= 1; 1943 _character_count -= parent.indent_length; 1944 } 1945 }; 1946 1947 this.trim = function() { 1948 while (this.last() === ' ') { 1949 _items.pop(); 1950 _character_count -= 1; 1951 } 1952 _empty = _items.length === 0; 1953 }; 1954 1955 this.toString = function() { 1956 var result = ''; 1957 if (!this._empty) { 1958 if (_indent_count >= 0) { 1959 result = parent.indent_cache[_indent_count]; 1960 } 1961 result += _items.join(''); 1962 } 1963 return result; 1964 }; 1965 } 1966 1967 function Output(indent_string, baseIndentString) { 1968 baseIndentString = baseIndentString || ''; 1969 this.indent_cache = [baseIndentString]; 1970 this.baseIndentLength = baseIndentString.length; 1971 this.indent_length = indent_string.length; 1972 this.raw = false; 1973 1974 var lines = []; 1975 this.baseIndentString = baseIndentString; 1976 this.indent_string = indent_string; 1977 this.previous_line = null; 1978 this.current_line = null; 1979 this.space_before_token = false; 1980 1981 this.add_outputline = function() { 1982 this.previous_line = this.current_line; 1983 this.current_line = new OutputLine(this); 1984 lines.push(this.current_line); 1985 }; 1986 1987 // initialize 1988 this.add_outputline(); 1989 1990 1991 this.get_line_number = function() { 1992 return lines.length; 1993 }; 1994 1995 // Using object instead of string to allow for later expansion of info about each line 1996 this.add_new_line = function(force_newline) { 1997 if (this.get_line_number() === 1 && this.just_added_newline()) { 1998 return false; // no newline on start of file 1999 } 2000 2001 if (force_newline || !this.just_added_newline()) { 2002 if (!this.raw) { 2003 this.add_outputline(); 2004 } 2005 return true; 2006 } 2007 2008 return false; 2009 }; 2010 2011 this.get_code = function(end_with_newline, eol) { 2012 var sweet_code = lines.join('\n').replace(/[\r\n\t ]+$/, ''); 2013 2014 if (end_with_newline) { 2015 sweet_code += '\n'; 2016 } 2017 2018 if (eol !== '\n') { 2019 sweet_code = sweet_code.replace(/[\n]/g, eol); 2020 } 2021 2022 return sweet_code; 2023 }; 2024 2025 this.set_indent = function(level) { 2026 // Never indent your first output indent at the start of the file 2027 if (lines.length > 1) { 2028 while (level >= this.indent_cache.length) { 2029 this.indent_cache.push(this.indent_cache[this.indent_cache.length - 1] + this.indent_string); 2030 } 2031 2032 this.current_line.set_indent(level); 2033 return true; 2034 } 2035 this.current_line.set_indent(0); 2036 return false; 2037 }; 2038 2039 this.add_raw_token = function(token) { 2040 for (var x = 0; x < token.newlines; x++) { 2041 this.add_outputline(); 2042 } 2043 this.current_line.push(token.whitespace_before); 2044 this.current_line.push(token.text); 2045 this.space_before_token = false; 2046 }; 2047 2048 this.add_token = function(printable_token) { 2049 this.add_space_before_token(); 2050 this.current_line.push(printable_token); 2051 }; 2052 2053 this.add_space_before_token = function() { 2054 if (this.space_before_token && !this.just_added_newline()) { 2055 this.current_line.push(' '); 2056 } 2057 this.space_before_token = false; 2058 }; 2059 2060 this.remove_indent = function(index) { 2061 var output_length = lines.length; 2062 while (index < output_length) { 2063 lines[index].remove_indent(); 2064 index++; 2065 } 2066 }; 2067 2068 this.trim = function(eat_newlines) { 2069 eat_newlines = (eat_newlines === undefined) ? false : eat_newlines; 2070 2071 this.current_line.trim(indent_string, baseIndentString); 2072 2073 while (eat_newlines && lines.length > 1 && 2074 this.current_line.is_empty()) { 2075 lines.pop(); 2076 this.current_line = lines[lines.length - 1]; 2077 this.current_line.trim(); 2078 } 2079 2080 this.previous_line = lines.length > 1 ? lines[lines.length - 2] : null; 2081 }; 2082 2083 this.just_added_newline = function() { 2084 return this.current_line.is_empty(); 2085 }; 2086 2087 this.just_added_blankline = function() { 2088 if (this.just_added_newline()) { 2089 if (lines.length === 1) { 2090 return true; // start of the file and newline = blank 2091 } 2092 2093 var line = lines[lines.length - 2]; 2094 return line.is_empty(); 2095 } 2096 return false; 2097 }; 2098 } 2099 2100 module.exports.Output = Output; 2101 2102 2103 /***/ }), 2104 /* 5 */ 2105 /***/ (function(module, exports) { 2106 2107 /*jshint curly:true, eqeqeq:true, laxbreak:true, noempty:false */ 2108 /* 2109 2110 The MIT License (MIT) 2111 2112 Copyright (c) 2007-2017 Einar Lielmanis, Liam Newman, and contributors. 2113 2114 Permission is hereby granted, free of charge, to any person 2115 obtaining a copy of this software and associated documentation files 2116 (the "Software"), to deal in the Software without restriction, 2117 including without limitation the rights to use, copy, modify, merge, 2118 publish, distribute, sublicense, and/or sell copies of the Software, 2119 and to permit persons to whom the Software is furnished to do so, 2120 subject to the following conditions: 2121 2122 The above copyright notice and this permission notice shall be 2123 included in all copies or substantial portions of the Software. 2124 2125 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 2126 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 2127 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 2128 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 2129 BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 2130 ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 2131 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 2132 SOFTWARE. 2133 */ 2134 2135 function Token(type, text, newlines, whitespace_before, parent) { 2136 this.type = type; 2137 this.text = text; 2138 2139 // comments_before are 2140 // comments that have a new line before them 2141 // and may or may not have a newline after 2142 // this is a set of comments before 2143 this.comments_before = /* inline comment*/ []; 2144 2145 2146 this.comments_after = []; // no new line before and newline after 2147 this.newlines = newlines || 0; 2148 this.wanted_newline = newlines > 0; 2149 this.whitespace_before = whitespace_before || ''; 2150 this.parent = parent || null; 2151 this.opened = null; 2152 this.directives = null; 2153 } 2154 2155 module.exports.Token = Token; 2156 2157 2158 /***/ }), 2159 /* 6 */ 2160 /***/ (function(module, exports, __webpack_require__) { 2161 2162 /*jshint curly:true, eqeqeq:true, laxbreak:true, noempty:false */ 2163 /* 2164 2165 The MIT License (MIT) 2166 2167 Copyright (c) 2007-2017 Einar Lielmanis, Liam Newman, and contributors. 2168 2169 Permission is hereby granted, free of charge, to any person 2170 obtaining a copy of this software and associated documentation files 2171 (the "Software"), to deal in the Software without restriction, 2172 including without limitation the rights to use, copy, modify, merge, 2173 publish, distribute, sublicense, and/or sell copies of the Software, 2174 and to permit persons to whom the Software is furnished to do so, 2175 subject to the following conditions: 2176 2177 The above copyright notice and this permission notice shall be 2178 included in all copies or substantial portions of the Software. 2179 2180 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 2181 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 2182 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 2183 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 2184 BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 2185 ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 2186 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 2187 SOFTWARE. 2188 */ 2189 2190 var Beautifier = __webpack_require__(1).Beautifier; 2191 2192 function js_beautify(js_source_text, options) { 2193 var beautifier = new Beautifier(js_source_text, options); 2194 return beautifier.beautify(); 2195 } 2196 2197 module.exports = js_beautify; 2198 2199 /***/ }), 2200 /* 7 */ 2201 /***/ (function(module, exports, __webpack_require__) { 2202 2203 /*jshint curly:true, eqeqeq:true, laxbreak:true, noempty:false */ 2204 /* 2205 2206 The MIT License (MIT) 2207 2208 Copyright (c) 2007-2017 Einar Lielmanis, Liam Newman, and contributors. 2209 2210 Permission is hereby granted, free of charge, to any person 2211 obtaining a copy of this software and associated documentation files 2212 (the "Software"), to deal in the Software without restriction, 2213 including without limitation the rights to use, copy, modify, merge, 2214 publish, distribute, sublicense, and/or sell copies of the Software, 2215 and to permit persons to whom the Software is furnished to do so, 2216 subject to the following conditions: 2217 2218 The above copyright notice and this permission notice shall be 2219 included in all copies or substantial portions of the Software. 2220 2221 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 2222 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 2223 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 2224 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 2225 BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 2226 ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 2227 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 2228 SOFTWARE. 2229 */ 2230 2231 var InputScanner = __webpack_require__(2).InputScanner; 2232 var Token = __webpack_require__(5).Token; 2233 var acorn = __webpack_require__(0); 2234 2235 function trim(s) { 2236 return s.replace(/^\s+|\s+$/g, ''); 2237 } 2238 2239 function in_array(what, arr) { 2240 for (var i = 0; i < arr.length; i += 1) { 2241 if (arr[i] === what) { 2242 return true; 2243 } 2244 } 2245 return false; 2246 } 2247 2248 function Tokenizer(input_string, opts) { 2249 2250 var whitespace = "\n\r\t ".split(''); 2251 var digit = /[0-9]/; 2252 var digit_bin = /[01]/; 2253 var digit_oct = /[01234567]/; 2254 var digit_hex = /[0123456789abcdefABCDEF]/; 2255 2256 this.positionable_operators = '!= !== % & && * ** + - / : < << <= == === > >= >> >>> ? ^ | ||'.split(' '); 2257 var punct = this.positionable_operators.concat( 2258 // non-positionable operators - these do not follow operator position settings 2259 '! %= &= *= **= ++ += , -- -= /= :: <<= = => >>= >>>= ^= |= ~ ...'.split(' ')); 2260 2261 // words which should always start on new line. 2262 this.line_starters = 'continue,try,throw,return,var,let,const,if,switch,case,default,for,while,break,function,import,export'.split(','); 2263 var reserved_words = this.line_starters.concat(['do', 'in', 'of', 'else', 'get', 'set', 'new', 'catch', 'finally', 'typeof', 'yield', 'async', 'await', 'from', 'as']); 2264 2265 // /* ... */ comment ends with nearest */ or end of file 2266 var block_comment_pattern = /([\s\S]*?)((?:\*\/)|$)/g; 2267 2268 // comment ends just before nearest linefeed or end of file 2269 var comment_pattern = /([^\n\r\u2028\u2029]*)/g; 2270 2271 var directives_block_pattern = /\/\* beautify( \w+[:]\w+)+ \*\//g; 2272 var directive_pattern = / (\w+)[:](\w+)/g; 2273 var directives_end_ignore_pattern = /([\s\S]*?)((?:\/\*\sbeautify\signore:end\s\*\/)|$)/g; 2274 2275 var template_pattern = /((<\?php|<\?=)[\s\S]*?\?>)|(<%[\s\S]*?%>)/g; 2276 2277 var n_newlines, whitespace_before_token, in_html_comment, tokens; 2278 var input; 2279 2280 this.tokenize = function() { 2281 input = new InputScanner(input_string); 2282 in_html_comment = false; 2283 tokens = []; 2284 2285 var next, last; 2286 var token_values; 2287 var open = null; 2288 var open_stack = []; 2289 var comments = []; 2290 2291 while (!(last && last.type === 'TK_EOF')) { 2292 token_values = tokenize_next(); 2293 next = new Token(token_values[1], token_values[0], n_newlines, whitespace_before_token); 2294 while (next.type === 'TK_COMMENT' || next.type === 'TK_BLOCK_COMMENT' || next.type === 'TK_UNKNOWN') { 2295 if (next.type === 'TK_BLOCK_COMMENT') { 2296 next.directives = token_values[2]; 2297 } 2298 comments.push(next); 2299 token_values = tokenize_next(); 2300 next = new Token(token_values[1], token_values[0], n_newlines, whitespace_before_token); 2301 } 2302 2303 if (comments.length) { 2304 next.comments_before = comments; 2305 comments = []; 2306 } 2307 2308 if (next.type === 'TK_START_BLOCK' || next.type === 'TK_START_EXPR') { 2309 next.parent = last; 2310 open_stack.push(open); 2311 open = next; 2312 } else if ((next.type === 'TK_END_BLOCK' || next.type === 'TK_END_EXPR') && 2313 (open && ( 2314 (next.text === ']' && open.text === '[') || 2315 (next.text === ')' && open.text === '(') || 2316 (next.text === '}' && open.text === '{')))) { 2317 next.parent = open.parent; 2318 next.opened = open; 2319 2320 open = open_stack.pop(); 2321 } 2322 2323 tokens.push(next); 2324 last = next; 2325 } 2326 2327 return tokens; 2328 }; 2329 2330 function get_directives(text) { 2331 if (!text.match(directives_block_pattern)) { 2332 return null; 2333 } 2334 2335 var directives = {}; 2336 directive_pattern.lastIndex = 0; 2337 var directive_match = directive_pattern.exec(text); 2338 2339 while (directive_match) { 2340 directives[directive_match[1]] = directive_match[2]; 2341 directive_match = directive_pattern.exec(text); 2342 } 2343 2344 return directives; 2345 } 2346 2347 function tokenize_next() { 2348 var resulting_string; 2349 var whitespace_on_this_line = []; 2350 2351 n_newlines = 0; 2352 whitespace_before_token = ''; 2353 2354 var c = input.next(); 2355 2356 if (c === null) { 2357 return ['', 'TK_EOF']; 2358 } 2359 2360 var last_token; 2361 if (tokens.length) { 2362 last_token = tokens[tokens.length - 1]; 2363 } else { 2364 // For the sake of tokenizing we can pretend that there was on open brace to start 2365 last_token = new Token('TK_START_BLOCK', '{'); 2366 } 2367 2368 while (in_array(c, whitespace)) { 2369 2370 if (acorn.newline.test(c)) { 2371 if (!(c === '\n' && input.peek(-2) === '\r')) { 2372 n_newlines += 1; 2373 whitespace_on_this_line = []; 2374 } 2375 } else { 2376 whitespace_on_this_line.push(c); 2377 } 2378 2379 c = input.next(); 2380 2381 if (c === null) { 2382 return ['', 'TK_EOF']; 2383 } 2384 } 2385 2386 if (whitespace_on_this_line.length) { 2387 whitespace_before_token = whitespace_on_this_line.join(''); 2388 } 2389 2390 if (digit.test(c) || (c === '.' && input.testChar(digit))) { 2391 var allow_decimal = true; 2392 var allow_e = true; 2393 var local_digit = digit; 2394 2395 if (c === '0' && input.testChar(/[XxOoBb]/)) { 2396 // switch to hex/oct/bin number, no decimal or e, just hex/oct/bin digits 2397 allow_decimal = false; 2398 allow_e = false; 2399 if (input.testChar(/[Bb]/)) { 2400 local_digit = digit_bin; 2401 } else if (input.testChar(/[Oo]/)) { 2402 local_digit = digit_oct; 2403 } else { 2404 local_digit = digit_hex; 2405 } 2406 c += input.next(); 2407 } else if (c === '.') { 2408 // Already have a decimal for this literal, don't allow another 2409 allow_decimal = false; 2410 } else { 2411 // we know this first loop will run. It keeps the logic simpler. 2412 c = ''; 2413 input.back(); 2414 } 2415 2416 // Add the digits 2417 while (input.testChar(local_digit)) { 2418 c += input.next(); 2419 2420 if (allow_decimal && input.peek() === '.') { 2421 c += input.next(); 2422 allow_decimal = false; 2423 } 2424 2425 // a = 1.e-7 is valid, so we test for . then e in one loop 2426 if (allow_e && input.testChar(/[Ee]/)) { 2427 c += input.next(); 2428 2429 if (input.testChar(/[+-]/)) { 2430 c += input.next(); 2431 } 2432 2433 allow_e = false; 2434 allow_decimal = false; 2435 } 2436 } 2437 2438 return [c, 'TK_WORD']; 2439 } 2440 2441 if (acorn.isIdentifierStart(input.peekCharCode(-1))) { 2442 if (input.hasNext()) { 2443 while (acorn.isIdentifierChar(input.peekCharCode())) { 2444 c += input.next(); 2445 if (!input.hasNext()) { 2446 break; 2447 } 2448 } 2449 } 2450 2451 if (!(last_token.type === 'TK_DOT' || 2452 (last_token.type === 'TK_RESERVED' && in_array(last_token.text, ['set', 'get']))) && 2453 in_array(c, reserved_words)) { 2454 if (c === 'in' || c === 'of') { // hack for 'in' and 'of' operators 2455 return [c, 'TK_OPERATOR']; 2456 } 2457 return [c, 'TK_RESERVED']; 2458 } 2459 2460 return [c, 'TK_WORD']; 2461 } 2462 2463 if (c === '(' || c === '[') { 2464 return [c, 'TK_START_EXPR']; 2465 } 2466 2467 if (c === ')' || c === ']') { 2468 return [c, 'TK_END_EXPR']; 2469 } 2470 2471 if (c === '{') { 2472 return [c, 'TK_START_BLOCK']; 2473 } 2474 2475 if (c === '}') { 2476 return [c, 'TK_END_BLOCK']; 2477 } 2478 2479 if (c === ';') { 2480 return [c, 'TK_SEMICOLON']; 2481 } 2482 2483 if (c === '/') { 2484 var comment = ''; 2485 var comment_match; 2486 // peek for comment /* ... */ 2487 if (input.peek() === '*') { 2488 input.next(); 2489 comment_match = input.match(block_comment_pattern); 2490 comment = '/*' + comment_match[0]; 2491 var directives = get_directives(comment); 2492 if (directives && directives.ignore === 'start') { 2493 comment_match = input.match(directives_end_ignore_pattern); 2494 comment += comment_match[0]; 2495 } 2496 comment = comment.replace(acorn.allLineBreaks, '\n'); 2497 return [comment, 'TK_BLOCK_COMMENT', directives]; 2498 } 2499 // peek for comment // ... 2500 if (input.peek() === '/') { 2501 input.next(); 2502 comment_match = input.match(comment_pattern); 2503 comment = '//' + comment_match[0]; 2504 return [comment, 'TK_COMMENT']; 2505 } 2506 2507 } 2508 2509 var startXmlRegExp = /<()([-a-zA-Z:0-9_.]+|{[\s\S]+?}|!\[CDATA\[[\s\S]*?\]\])(\s+{[\s\S]+?}|\s+[-a-zA-Z:0-9_.]+|\s+[-a-zA-Z:0-9_.]+\s*=\s*('[^']*'|"[^"]*"|{[\s\S]+?}))*\s*(\/?)\s*>/g; 2510 2511 if (c === '`' || c === "'" || c === '"' || // string 2512 ( 2513 (c === '/') || // regexp 2514 (opts.e4x && c === "<" && input.test(startXmlRegExp, -1)) // xml 2515 ) && ( // regex and xml can only appear in specific locations during parsing 2516 (last_token.type === 'TK_RESERVED' && in_array(last_token.text, ['return', 'case', 'throw', 'else', 'do', 'typeof', 'yield'])) || 2517 (last_token.type === 'TK_END_EXPR' && last_token.text === ')' && 2518 last_token.parent && last_token.parent.type === 'TK_RESERVED' && in_array(last_token.parent.text, ['if', 'while', 'for'])) || 2519 (in_array(last_token.type, ['TK_COMMENT', 'TK_START_EXPR', 'TK_START_BLOCK', 2520 'TK_END_BLOCK', 'TK_OPERATOR', 'TK_EQUALS', 'TK_EOF', 'TK_SEMICOLON', 'TK_COMMA' 2521 ])) 2522 )) { 2523 2524 var sep = c, 2525 esc = false, 2526 has_char_escapes = false; 2527 2528 resulting_string = c; 2529 2530 if (sep === '/') { 2531 // 2532 // handle regexp 2533 // 2534 var in_char_class = false; 2535 while (input.hasNext() && 2536 ((esc || in_char_class || input.peek() !== sep) && 2537 !input.testChar(acorn.newline))) { 2538 resulting_string += input.peek(); 2539 if (!esc) { 2540 esc = input.peek() === '\\'; 2541 if (input.peek() === '[') { 2542 in_char_class = true; 2543 } else if (input.peek() === ']') { 2544 in_char_class = false; 2545 } 2546 } else { 2547 esc = false; 2548 } 2549 input.next(); 2550 } 2551 } else if (opts.e4x && sep === '<') { 2552 // 2553 // handle e4x xml literals 2554 // 2555 2556 var xmlRegExp = /[\s\S]*?<(\/?)([-a-zA-Z:0-9_.]+|{[\s\S]+?}|!\[CDATA\[[\s\S]*?\]\])(\s+{[\s\S]+?}|\s+[-a-zA-Z:0-9_.]+|\s+[-a-zA-Z:0-9_.]+\s*=\s*('[^']*'|"[^"]*"|{[\s\S]+?}))*\s*(\/?)\s*>/g; 2557 input.back(); 2558 var xmlStr = ''; 2559 var match = input.match(startXmlRegExp); 2560 if (match) { 2561 // Trim root tag to attempt to 2562 var rootTag = match[2].replace(/^{\s+/, '{').replace(/\s+}$/, '}'); 2563 var isCurlyRoot = rootTag.indexOf('{') === 0; 2564 var depth = 0; 2565 while (match) { 2566 var isEndTag = !!match[1]; 2567 var tagName = match[2]; 2568 var isSingletonTag = (!!match[match.length - 1]) || (tagName.slice(0, 8) === "![CDATA["); 2569 if (!isSingletonTag && 2570 (tagName === rootTag || (isCurlyRoot && tagName.replace(/^{\s+/, '{').replace(/\s+}$/, '}')))) { 2571 if (isEndTag) { 2572 --depth; 2573 } else { 2574 ++depth; 2575 } 2576 } 2577 xmlStr += match[0]; 2578 if (depth <= 0) { 2579 break; 2580 } 2581 match = input.match(xmlRegExp); 2582 } 2583 // if we didn't close correctly, keep unformatted. 2584 if (!match) { 2585 xmlStr += input.match(/[\s\S]*/g)[0]; 2586 } 2587 xmlStr = xmlStr.replace(acorn.allLineBreaks, '\n'); 2588 return [xmlStr, "TK_STRING"]; 2589 } 2590 } else { 2591 // 2592 // handle string 2593 // 2594 var parse_string = function(delimiter, allow_unescaped_newlines, start_sub) { 2595 // Template strings can travers lines without escape characters. 2596 // Other strings cannot 2597 var current_char; 2598 while (input.hasNext()) { 2599 current_char = input.peek(); 2600 if (!(esc || (current_char !== delimiter && 2601 (allow_unescaped_newlines || !acorn.newline.test(current_char))))) { 2602 break; 2603 } 2604 2605 // Handle \r\n linebreaks after escapes or in template strings 2606 if ((esc || allow_unescaped_newlines) && acorn.newline.test(current_char)) { 2607 if (current_char === '\r' && input.peek(1) === '\n') { 2608 input.next(); 2609 current_char = input.peek(); 2610 } 2611 resulting_string += '\n'; 2612 } else { 2613 resulting_string += current_char; 2614 } 2615 2616 if (esc) { 2617 if (current_char === 'x' || current_char === 'u') { 2618 has_char_escapes = true; 2619 } 2620 esc = false; 2621 } else { 2622 esc = current_char === '\\'; 2623 } 2624 2625 input.next(); 2626 2627 if (start_sub && resulting_string.indexOf(start_sub, resulting_string.length - start_sub.length) !== -1) { 2628 if (delimiter === '`') { 2629 parse_string('}', allow_unescaped_newlines, '`'); 2630 } else { 2631 parse_string('`', allow_unescaped_newlines, '${'); 2632 } 2633 2634 if (input.hasNext()) { 2635 resulting_string += input.next(); 2636 } 2637 } 2638 } 2639 }; 2640 2641 if (sep === '`') { 2642 parse_string('`', true, '${'); 2643 } else { 2644 parse_string(sep); 2645 } 2646 } 2647 2648 if (has_char_escapes && opts.unescape_strings) { 2649 resulting_string = unescape_string(resulting_string); 2650 } 2651 2652 if (input.peek() === sep) { 2653 resulting_string += sep; 2654 input.next(); 2655 2656 if (sep === '/') { 2657 // regexps may have modifiers /regexp/MOD , so fetch those, too 2658 // Only [gim] are valid, but if the user puts in garbage, do what we can to take it. 2659 while (input.hasNext() && acorn.isIdentifierStart(input.peekCharCode())) { 2660 resulting_string += input.next(); 2661 } 2662 } 2663 } 2664 return [resulting_string, 'TK_STRING']; 2665 } 2666 2667 if (c === '#') { 2668 2669 if (tokens.length === 0 && input.peek() === '!') { 2670 // shebang 2671 resulting_string = c; 2672 while (input.hasNext() && c !== '\n') { 2673 c = input.next(); 2674 resulting_string += c; 2675 } 2676 return [trim(resulting_string) + '\n', 'TK_UNKNOWN']; 2677 } 2678 2679 2680 2681 // Spidermonkey-specific sharp variables for circular references 2682 // https://developer.mozilla.org/En/Sharp_variables_in_JavaScript 2683 // http://mxr.mozilla.org/mozilla-central/source/js/src/jsscan.cpp around line 1935 2684 var sharp = '#'; 2685 if (input.hasNext() && input.testChar(digit)) { 2686 do { 2687 c = input.next(); 2688 sharp += c; 2689 } while (input.hasNext() && c !== '#' && c !== '='); 2690 if (c === '#') { 2691 // 2692 } else if (input.peek() === '[' && input.peek(1) === ']') { 2693 sharp += '[]'; 2694 input.next(); 2695 input.next(); 2696 } else if (input.peek() === '{' && input.peek(1) === '}') { 2697 sharp += '{}'; 2698 input.next(); 2699 input.next(); 2700 } 2701 return [sharp, 'TK_WORD']; 2702 } 2703 } 2704 2705 if (c === '<' && (input.peek() === '?' || input.peek() === '%')) { 2706 input.back(); 2707 var template_match = input.match(template_pattern); 2708 if (template_match) { 2709 c = template_match[0]; 2710 c = c.replace(acorn.allLineBreaks, '\n'); 2711 return [c, 'TK_STRING']; 2712 } 2713 } 2714 2715 if (c === '<' && input.match(/\!--/g)) { 2716 c = '<!--'; 2717 while (input.hasNext() && !input.testChar(acorn.newline)) { 2718 c += input.next(); 2719 } 2720 in_html_comment = true; 2721 return [c, 'TK_COMMENT']; 2722 } 2723 2724 if (c === '-' && in_html_comment && input.match(/->/g)) { 2725 in_html_comment = false; 2726 return ['-->', 'TK_COMMENT']; 2727 } 2728 2729 if (c === '.') { 2730 if (input.peek() === '.' && input.peek(1) === '.') { 2731 c += input.next() + input.next(); 2732 return [c, 'TK_OPERATOR']; 2733 } 2734 return [c, 'TK_DOT']; 2735 } 2736 2737 if (in_array(c, punct)) { 2738 while (input.hasNext() && in_array(c + input.peek(), punct)) { 2739 c += input.next(); 2740 if (!input.hasNext()) { 2741 break; 2742 } 2743 } 2744 2745 if (c === ',') { 2746 return [c, 'TK_COMMA']; 2747 } else if (c === '=') { 2748 return [c, 'TK_EQUALS']; 2749 } else { 2750 return [c, 'TK_OPERATOR']; 2751 } 2752 } 2753 2754 return [c, 'TK_UNKNOWN']; 2755 } 2756 2757 2758 function unescape_string(s) { 2759 // You think that a regex would work for this 2760 // return s.replace(/\\x([0-9a-f]{2})/gi, function(match, val) { 2761 // return String.fromCharCode(parseInt(val, 16)); 2762 // }) 2763 // However, dealing with '\xff', '\\xff', '\\\xff' makes this more fun. 2764 var out = '', 2765 escaped = 0; 2766 2767 var input_scan = new InputScanner(s); 2768 var matched = null; 2769 2770 while (input_scan.hasNext()) { 2771 // Keep any whitespace, non-slash characters 2772 // also keep slash pairs. 2773 matched = input_scan.match(/([\s]|[^\\]|\\\\)+/g); 2774 2775 if (matched) { 2776 out += matched[0]; 2777 } 2778 2779 if (input_scan.peek() === '\\') { 2780 input_scan.next(); 2781 if (input_scan.peek() === 'x') { 2782 matched = input_scan.match(/x([0-9A-Fa-f]{2})/g); 2783 } else if (input_scan.peek() === 'u') { 2784 matched = input_scan.match(/u([0-9A-Fa-f]{4})/g); 2785 } else { 2786 out += '\\'; 2787 if (input_scan.hasNext()) { 2788 out += input_scan.next(); 2789 } 2790 continue; 2791 } 2792 2793 // If there's some error decoding, return the original string 2794 if (!matched) { 2795 return s; 2796 } 2797 2798 escaped = parseInt(matched[1], 16); 2799 2800 if (escaped > 0x7e && escaped <= 0xff && matched[0].indexOf('x') === 0) { 2801 // we bail out on \x7f..\xff, 2802 // leaving whole string escaped, 2803 // as it's probably completely binary 2804 return s; 2805 } else if (escaped >= 0x00 && escaped < 0x20) { 2806 // leave 0x00...0x1f escaped 2807 out += '\\' + matched[0]; 2808 continue; 2809 } else if (escaped === 0x22 || escaped === 0x27 || escaped === 0x5c) { 2810 // single-quote, apostrophe, backslash - escape these 2811 out += '\\' + String.fromCharCode(escaped); 2812 } else { 2813 out += String.fromCharCode(escaped); 2814 } 2815 } 2816 } 2817 2818 return out; 2819 } 2820 } 2821 2822 module.exports.Tokenizer = Tokenizer; 2823 2824 /***/ }) 2825 /******/ ]); 2826 var js_beautify = legacy_beautify_js; 2827 /* Footer */ 2828 if (typeof define === "function" && define.amd) { 2829 // Add support for AMD ( https://github.com/amdjs/amdjs-api/wiki/AMD#defineamd-property- ) 2830 define([], function() { 2831 return { js_beautify: js_beautify }; 2832 }); 2833 } else if (typeof exports !== "undefined") { 2834 // Add support for CommonJS. Just put this file somewhere on your require.paths 2835 // and you will be able to `var js_beautify = require("beautify").js_beautify`. 2836 exports.js_beautify = js_beautify; 2837 } else if (typeof window !== "undefined") { 2838 // If we're running a web page and don't have either of the above, add our one global 2839 window.js_beautify = js_beautify; 2840 } else if (typeof global !== "undefined") { 2841 // If we don't even have window, try global. 2842 global.js_beautify = js_beautify; 2843 } 2844 2845 }()); 2846 /*jshint curly:false, eqeqeq:true, laxbreak:true, noempty:false */ 2847 /* AUTO-GENERATED. DO NOT MODIFY. */ 2848 /* 2849 2850 The MIT License (MIT) 2851 2852 Copyright (c) 2007-2017 Einar Lielmanis, Liam Newman, and contributors. 2853 2854 Permission is hereby granted, free of charge, to any person 2855 obtaining a copy of this software and associated documentation files 2856 (the "Software"), to deal in the Software without restriction, 2857 including without limitation the rights to use, copy, modify, merge, 2858 publish, distribute, sublicense, and/or sell copies of the Software, 2859 and to permit persons to whom the Software is furnished to do so, 2860 subject to the following conditions: 2861 2862 The above copyright notice and this permission notice shall be 2863 included in all copies or substantial portions of the Software. 2864 2865 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 2866 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 2867 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 2868 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 2869 BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 2870 ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 2871 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 2872 SOFTWARE. 2873 2874 2875 CSS Beautifier 2876 --------------- 2877 2878 Written by Harutyun Amirjanyan, (amirjanyan@gmail.com) 2879 2880 Based on code initially developed by: Einar Lielmanis, <einar@jsbeautifier.org> 2881 http://jsbeautifier.org/ 2882 2883 Usage: 2884 css_beautify(source_text); 2885 css_beautify(source_text, options); 2886 2887 The options are (default in brackets): 2888 indent_size (4) — indentation size, 2889 indent_char (space) — character to indent with, 2890 selector_separator_newline (true) - separate selectors with newline or 2891 not (e.g. "a,\nbr" or "a, br") 2892 end_with_newline (false) - end with a newline 2893 newline_between_rules (true) - add a new line after every css rule 2894 space_around_selector_separator (false) - ensure space around selector separators: 2895 '>', '+', '~' (e.g. "a>b" -> "a > b") 2896 e.g 2897 2898 css_beautify(css_source_text, { 2899 'indent_size': 1, 2900 'indent_char': '\t', 2901 'selector_separator': ' ', 2902 'end_with_newline': false, 2903 'newline_between_rules': true, 2904 'space_around_selector_separator': true 2905 }); 2906 */ 2907 2908 // http://www.w3.org/TR/CSS21/syndata.html#tokenization 2909 // http://www.w3.org/TR/css3-syntax/ 2910 2911 (function() { 2912 var legacy_beautify_css = 2913 /******/ (function(modules) { // webpackBootstrap 2914 /******/ // The module cache 2915 /******/ var installedModules = {}; 2916 /******/ 2917 /******/ // The require function 2918 /******/ function __webpack_require__(moduleId) { 2919 /******/ 2920 /******/ // Check if module is in cache 2921 /******/ if(installedModules[moduleId]) { 2922 /******/ return installedModules[moduleId].exports; 2923 /******/ } 2924 /******/ // Create a new module (and put it into the cache) 2925 /******/ var module = installedModules[moduleId] = { 2926 /******/ i: moduleId, 2927 /******/ l: false, 2928 /******/ exports: {} 2929 /******/ }; 2930 /******/ 2931 /******/ // Execute the module function 2932 /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); 2933 /******/ 2934 /******/ // Flag the module as loaded 2935 /******/ module.l = true; 2936 /******/ 2937 /******/ // Return the exports of the module 2938 /******/ return module.exports; 2939 /******/ } 2940 /******/ 2941 /******/ 2942 /******/ // expose the modules object (__webpack_modules__) 2943 /******/ __webpack_require__.m = modules; 2944 /******/ 2945 /******/ // expose the module cache 2946 /******/ __webpack_require__.c = installedModules; 2947 /******/ 2948 /******/ // identity function for calling harmony imports with the correct context 2949 /******/ __webpack_require__.i = function(value) { return value; }; 2950 /******/ 2951 /******/ // define getter function for harmony exports 2952 /******/ __webpack_require__.d = function(exports, name, getter) { 2953 /******/ if(!__webpack_require__.o(exports, name)) { 2954 /******/ Object.defineProperty(exports, name, { 2955 /******/ configurable: false, 2956 /******/ enumerable: true, 2957 /******/ get: getter 2958 /******/ }); 2959 /******/ } 2960 /******/ }; 2961 /******/ 2962 /******/ // getDefaultExport function for compatibility with non-harmony modules 2963 /******/ __webpack_require__.n = function(module) { 2964 /******/ var getter = module && module.__esModule ? 2965 /******/ function getDefault() { return module['default']; } : 2966 /******/ function getModuleExports() { return module; }; 2967 /******/ __webpack_require__.d(getter, 'a', getter); 2968 /******/ return getter; 2969 /******/ }; 2970 /******/ 2971 /******/ // Object.prototype.hasOwnProperty.call 2972 /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; 2973 /******/ 2974 /******/ // __webpack_public_path__ 2975 /******/ __webpack_require__.p = ""; 2976 /******/ 2977 /******/ // Load entry module and return exports 2978 /******/ return __webpack_require__(__webpack_require__.s = 4); 2979 /******/ }) 2980 /************************************************************************/ 2981 /******/ ([ 2982 /* 0 */ 2983 /***/ (function(module, exports, __webpack_require__) { 2984 2985 /*jshint curly:true, eqeqeq:true, laxbreak:true, noempty:false */ 2986 /* 2987 2988 The MIT License (MIT) 2989 2990 Copyright (c) 2007-2017 Einar Lielmanis, Liam Newman, and contributors. 2991 2992 Permission is hereby granted, free of charge, to any person 2993 obtaining a copy of this software and associated documentation files 2994 (the "Software"), to deal in the Software without restriction, 2995 including without limitation the rights to use, copy, modify, merge, 2996 publish, distribute, sublicense, and/or sell copies of the Software, 2997 and to permit persons to whom the Software is furnished to do so, 2998 subject to the following conditions: 2999 3000 The above copyright notice and this permission notice shall be 3001 included in all copies or substantial portions of the Software. 3002 3003 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 3004 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 3005 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 3006 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 3007 BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 3008 ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 3009 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 3010 SOFTWARE. 3011 */ 3012 3013 var mergeOpts = __webpack_require__(2).mergeOpts; 3014 var acorn = __webpack_require__(1); 3015 var Output = __webpack_require__(3).Output; 3016 3017 3018 var lineBreak = acorn.lineBreak; 3019 var allLineBreaks = acorn.allLineBreaks; 3020 3021 function Beautifier(source_text, options) { 3022 options = options || {}; 3023 3024 // Allow the setting of language/file-type specific options 3025 // with inheritance of overall settings 3026 options = mergeOpts(options, 'css'); 3027 3028 source_text = source_text || ''; 3029 3030 var newlinesFromLastWSEat = 0; 3031 var indentSize = options.indent_size ? parseInt(options.indent_size, 10) : 4; 3032 var indentCharacter = options.indent_char || ' '; 3033 var preserve_newlines = (options.preserve_newlines === undefined) ? false : options.preserve_newlines; 3034 var selectorSeparatorNewline = (options.selector_separator_newline === undefined) ? true : options.selector_separator_newline; 3035 var end_with_newline = (options.end_with_newline === undefined) ? false : options.end_with_newline; 3036 var newline_between_rules = (options.newline_between_rules === undefined) ? true : options.newline_between_rules; 3037 var space_around_combinator = (options.space_around_combinator === undefined) ? false : options.space_around_combinator; 3038 space_around_combinator = space_around_combinator || ((options.space_around_selector_separator === undefined) ? false : options.space_around_selector_separator); 3039 var eol = options.eol ? options.eol : 'auto'; 3040 3041 if (options.indent_with_tabs) { 3042 indentCharacter = '\t'; 3043 indentSize = 1; 3044 } 3045 3046 if (eol === 'auto') { 3047 eol = '\n'; 3048 if (source_text && lineBreak.test(source_text || '')) { 3049 eol = source_text.match(lineBreak)[0]; 3050 } 3051 } 3052 3053 eol = eol.replace(/\\r/, '\r').replace(/\\n/, '\n'); 3054 3055 // HACK: newline parsing inconsistent. This brute force normalizes the input. 3056 source_text = source_text.replace(allLineBreaks, '\n'); 3057 3058 // tokenizer 3059 var whiteRe = /^\s+$/; 3060 3061 var pos = -1, 3062 ch; 3063 var parenLevel = 0; 3064 3065 function next() { 3066 ch = source_text.charAt(++pos); 3067 return ch || ''; 3068 } 3069 3070 function peek(skipWhitespace) { 3071 var result = ''; 3072 var prev_pos = pos; 3073 if (skipWhitespace) { 3074 eatWhitespace(); 3075 } 3076 result = source_text.charAt(pos + 1) || ''; 3077 pos = prev_pos - 1; 3078 next(); 3079 return result; 3080 } 3081 3082 function eatString(endChars) { 3083 var start = pos; 3084 while (next()) { 3085 if (ch === "\\") { 3086 next(); 3087 } else if (endChars.indexOf(ch) !== -1) { 3088 break; 3089 } else if (ch === "\n") { 3090 break; 3091 } 3092 } 3093 return source_text.substring(start, pos + 1); 3094 } 3095 3096 function peekString(endChar) { 3097 var prev_pos = pos; 3098 var str = eatString(endChar); 3099 pos = prev_pos - 1; 3100 next(); 3101 return str; 3102 } 3103 3104 function eatWhitespace(preserve_newlines_local) { 3105 var result = 0; 3106 while (whiteRe.test(peek())) { 3107 next(); 3108 if (ch === '\n' && preserve_newlines_local && preserve_newlines) { 3109 output.add_new_line(true); 3110 result++; 3111 } 3112 } 3113 newlinesFromLastWSEat = result; 3114 return result; 3115 } 3116 3117 function skipWhitespace() { 3118 var result = ''; 3119 if (ch && whiteRe.test(ch)) { 3120 result = ch; 3121 } 3122 while (whiteRe.test(next())) { 3123 result += ch; 3124 } 3125 return result; 3126 } 3127 3128 function eatComment() { 3129 var start = pos; 3130 var singleLine = peek() === "/"; 3131 next(); 3132 while (next()) { 3133 if (!singleLine && ch === "*" && peek() === "/") { 3134 next(); 3135 break; 3136 } else if (singleLine && ch === "\n") { 3137 return source_text.substring(start, pos); 3138 } 3139 } 3140 3141 return source_text.substring(start, pos) + ch; 3142 } 3143 3144 3145 function lookBack(str) { 3146 return source_text.substring(pos - str.length, pos).toLowerCase() === 3147 str; 3148 } 3149 3150 // Nested pseudo-class if we are insideRule 3151 // and the next special character found opens 3152 // a new block 3153 function foundNestedPseudoClass() { 3154 var openParen = 0; 3155 for (var i = pos + 1; i < source_text.length; i++) { 3156 var ch = source_text.charAt(i); 3157 if (ch === "{") { 3158 return true; 3159 } else if (ch === '(') { 3160 // pseudoclasses can contain () 3161 openParen += 1; 3162 } else if (ch === ')') { 3163 if (openParen === 0) { 3164 return false; 3165 } 3166 openParen -= 1; 3167 } else if (ch === ";" || ch === "}") { 3168 return false; 3169 } 3170 } 3171 return false; 3172 } 3173 3174 // printer 3175 var baseIndentString = ''; 3176 var preindent_index = 0; 3177 if (source_text && source_text.length) { 3178 while ((source_text.charAt(preindent_index) === ' ' || 3179 source_text.charAt(preindent_index) === '\t')) { 3180 preindent_index += 1; 3181 } 3182 baseIndentString = source_text.substring(0, preindent_index); 3183 source_text = source_text.substring(preindent_index); 3184 } 3185 3186 3187 var singleIndent = new Array(indentSize + 1).join(indentCharacter); 3188 var indentLevel; 3189 var nestedLevel; 3190 var output; 3191 3192 function print_string(output_string) { 3193 if (output.just_added_newline()) { 3194 output.set_indent(indentLevel); 3195 } 3196 output.add_token(output_string); 3197 } 3198 3199 function preserveSingleSpace(isAfterSpace) { 3200 if (isAfterSpace) { 3201 output.space_before_token = true; 3202 } 3203 } 3204 3205 function indent() { 3206 indentLevel++; 3207 } 3208 3209 function outdent() { 3210 if (indentLevel > 0) { 3211 indentLevel--; 3212 } 3213 } 3214 3215 /*_____________________--------------------_____________________*/ 3216 3217 this.beautify = function() { 3218 // reset 3219 output = new Output(singleIndent, baseIndentString); 3220 indentLevel = 0; 3221 nestedLevel = 0; 3222 3223 pos = -1; 3224 ch = null; 3225 parenLevel = 0; 3226 3227 var insideRule = false; 3228 var insidePropertyValue = false; 3229 var enteringConditionalGroup = false; 3230 var top_ch = ''; 3231 var last_top_ch = ''; 3232 3233 while (true) { 3234 var whitespace = skipWhitespace(); 3235 var isAfterSpace = whitespace !== ''; 3236 var isAfterNewline = whitespace.indexOf('\n') !== -1; 3237 last_top_ch = top_ch; 3238 top_ch = ch; 3239 3240 if (!ch) { 3241 break; 3242 } else if (ch === '/' && peek() === '*') { /* css comment */ 3243 var header = indentLevel === 0; 3244 3245 if (isAfterNewline || header) { 3246 output.add_new_line(); 3247 } 3248 3249 print_string(eatComment()); 3250 output.add_new_line(); 3251 if (header) { 3252 output.add_new_line(true); 3253 } 3254 } else if (ch === '/' && peek() === '/') { // single line comment 3255 if (!isAfterNewline && last_top_ch !== '{') { 3256 output.trim(true); 3257 } 3258 output.space_before_token = true; 3259 print_string(eatComment()); 3260 output.add_new_line(); 3261 } else if (ch === '@') { 3262 preserveSingleSpace(isAfterSpace); 3263 3264 // deal with less propery mixins @{...} 3265 if (peek() === '{') { 3266 print_string(eatString('}')); 3267 } else { 3268 print_string(ch); 3269 3270 // strip trailing space, if present, for hash property checks 3271 var variableOrRule = peekString(": ,;{}()[]/='\""); 3272 3273 if (variableOrRule.match(/[ :]$/)) { 3274 // we have a variable or pseudo-class, add it and insert one space before continuing 3275 next(); 3276 variableOrRule = eatString(": ").replace(/\s$/, ''); 3277 print_string(variableOrRule); 3278 output.space_before_token = true; 3279 } 3280 3281 variableOrRule = variableOrRule.replace(/\s$/, ''); 3282 3283 // might be a nesting at-rule 3284 if (variableOrRule in this.NESTED_AT_RULE) { 3285 nestedLevel += 1; 3286 if (variableOrRule in this.CONDITIONAL_GROUP_RULE) { 3287 enteringConditionalGroup = true; 3288 } 3289 } 3290 } 3291 } else if (ch === '#' && peek() === '{') { 3292 preserveSingleSpace(isAfterSpace); 3293 print_string(eatString('}')); 3294 } else if (ch === '{') { 3295 if (peek(true) === '}') { 3296 eatWhitespace(); 3297 next(); 3298 output.space_before_token = true; 3299 print_string("{}"); 3300 if (!eatWhitespace(true)) { 3301 output.add_new_line(); 3302 } 3303 3304 if (newlinesFromLastWSEat < 2 && newline_between_rules && indentLevel === 0) { 3305 output.add_new_line(true); 3306 } 3307 } else { 3308 indent(); 3309 output.space_before_token = true; 3310 print_string(ch); 3311 if (!eatWhitespace(true)) { 3312 output.add_new_line(); 3313 } 3314 3315 // when entering conditional groups, only rulesets are allowed 3316 if (enteringConditionalGroup) { 3317 enteringConditionalGroup = false; 3318 insideRule = (indentLevel > nestedLevel); 3319 } else { 3320 // otherwise, declarations are also allowed 3321 insideRule = (indentLevel >= nestedLevel); 3322 } 3323 } 3324 } else if (ch === '}') { 3325 outdent(); 3326 output.add_new_line(); 3327 print_string(ch); 3328 insideRule = false; 3329 insidePropertyValue = false; 3330 if (nestedLevel) { 3331 nestedLevel--; 3332 } 3333 3334 if (!eatWhitespace(true)) { 3335 output.add_new_line(); 3336 } 3337 3338 if (newlinesFromLastWSEat < 2 && newline_between_rules && indentLevel === 0) { 3339 output.add_new_line(true); 3340 } 3341 } else if (ch === ":") { 3342 eatWhitespace(); 3343 if ((insideRule || enteringConditionalGroup) && 3344 !(lookBack("&") || foundNestedPseudoClass()) && 3345 !lookBack("(")) { 3346 // 'property: value' delimiter 3347 // which could be in a conditional group query 3348 print_string(':'); 3349 if (!insidePropertyValue) { 3350 insidePropertyValue = true; 3351 output.space_before_token = true; 3352 } 3353 } else { 3354 // sass/less parent reference don't use a space 3355 // sass nested pseudo-class don't use a space 3356 3357 // preserve space before pseudoclasses/pseudoelements, as it means "in any child" 3358 if (lookBack(" ")) { 3359 output.space_before_token = true; 3360 } 3361 if (peek() === ":") { 3362 // pseudo-element 3363 next(); 3364 print_string("::"); 3365 } else { 3366 // pseudo-class 3367 print_string(':'); 3368 } 3369 } 3370 } else if (ch === '"' || ch === '\'') { 3371 preserveSingleSpace(isAfterSpace); 3372 print_string(eatString(ch)); 3373 } else if (ch === ';') { 3374 insidePropertyValue = false; 3375 print_string(ch); 3376 if (!eatWhitespace(true)) { 3377 output.add_new_line(); 3378 } 3379 } else if (ch === '(') { // may be a url 3380 if (lookBack("url")) { 3381 print_string(ch); 3382 eatWhitespace(); 3383 if (next()) { 3384 if (ch !== ')' && ch !== '"' && ch !== '\'') { 3385 print_string(eatString(')')); 3386 } else { 3387 pos--; 3388 } 3389 } 3390 } else { 3391 parenLevel++; 3392 preserveSingleSpace(isAfterSpace); 3393 print_string(ch); 3394 eatWhitespace(); 3395 } 3396 } else if (ch === ')') { 3397 print_string(ch); 3398 parenLevel--; 3399 } else if (ch === ',') { 3400 print_string(ch); 3401 if (!eatWhitespace(true) && selectorSeparatorNewline && !insidePropertyValue && parenLevel < 1) { 3402 output.add_new_line(); 3403 } else { 3404 output.space_before_token = true; 3405 } 3406 } else if ((ch === '>' || ch === '+' || ch === '~') && 3407 !insidePropertyValue && parenLevel < 1) { 3408 //handle combinator spacing 3409 if (space_around_combinator) { 3410 output.space_before_token = true; 3411 print_string(ch); 3412 output.space_before_token = true; 3413 } else { 3414 print_string(ch); 3415 eatWhitespace(); 3416 // squash extra whitespace 3417 if (ch && whiteRe.test(ch)) { 3418 ch = ''; 3419 } 3420 } 3421 } else if (ch === ']') { 3422 print_string(ch); 3423 } else if (ch === '[') { 3424 preserveSingleSpace(isAfterSpace); 3425 print_string(ch); 3426 } else if (ch === '=') { // no whitespace before or after 3427 eatWhitespace(); 3428 print_string('='); 3429 if (whiteRe.test(ch)) { 3430 ch = ''; 3431 } 3432 } else if (ch === '!') { // !important 3433 print_string(' '); 3434 print_string(ch); 3435 } else { 3436 preserveSingleSpace(isAfterSpace); 3437 print_string(ch); 3438 } 3439 } 3440 3441 var sweetCode = output.get_code(end_with_newline, eol); 3442 3443 return sweetCode; 3444 }; 3445 3446 // https://developer.mozilla.org/en-US/docs/Web/CSS/At-rule 3447 this.NESTED_AT_RULE = { 3448 "@page": true, 3449 "@font-face": true, 3450 "@keyframes": true, 3451 // also in CONDITIONAL_GROUP_RULE below 3452 "@media": true, 3453 "@supports": true, 3454 "@document": true 3455 }; 3456 this.CONDITIONAL_GROUP_RULE = { 3457 "@media": true, 3458 "@supports": true, 3459 "@document": true 3460 }; 3461 } 3462 3463 module.exports.Beautifier = Beautifier; 3464 3465 3466 /***/ }), 3467 /* 1 */ 3468 /***/ (function(module, exports) { 3469 3470 /* jshint curly: false */ 3471 // This section of code is taken from acorn. 3472 // 3473 // Acorn was written by Marijn Haverbeke and released under an MIT 3474 // license. The Unicode regexps (for identifiers and whitespace) were 3475 // taken from [Esprima](http://esprima.org) by Ariya Hidayat. 3476 // 3477 // Git repositories for Acorn are available at 3478 // 3479 // http://marijnhaverbeke.nl/git/acorn 3480 // https://github.com/marijnh/acorn.git 3481 3482 // ## Character categories 3483 3484 // Big ugly regular expressions that match characters in the 3485 // whitespace, identifier, and identifier-start categories. These 3486 // are only applied when a character is found to actually have a 3487 // code point above 128. 3488 3489 var nonASCIIwhitespace = /[\u1680\u180e\u2000-\u200a\u202f\u205f\u3000\ufeff]/; // jshint ignore:line 3490 var nonASCIIidentifierStartChars = "\xaa\xb5\xba\xc0-\xd6\xd8-\xf6\xf8-\u02c1\u02c6-\u02d1\u02e0-\u02e4\u02ec\u02ee\u0370-\u0374\u0376\u0377\u037a-\u037d\u0386\u0388-\u038a\u038c\u038e-\u03a1\u03a3-\u03f5\u03f7-\u0481\u048a-\u0527\u0531-\u0556\u0559\u0561-\u0587\u05d0-\u05ea\u05f0-\u05f2\u0620-\u064a\u066e\u066f\u0671-\u06d3\u06d5\u06e5\u06e6\u06ee\u06ef\u06fa-\u06fc\u06ff\u0710\u0712-\u072f\u074d-\u07a5\u07b1\u07ca-\u07ea\u07f4\u07f5\u07fa\u0800-\u0815\u081a\u0824\u0828\u0840-\u0858\u08a0\u08a2-\u08ac\u0904-\u0939\u093d\u0950\u0958-\u0961\u0971-\u0977\u0979-\u097f\u0985-\u098c\u098f\u0990\u0993-\u09a8\u09aa-\u09b0\u09b2\u09b6-\u09b9\u09bd\u09ce\u09dc\u09dd\u09df-\u09e1\u09f0\u09f1\u0a05-\u0a0a\u0a0f\u0a10\u0a13-\u0a28\u0a2a-\u0a30\u0a32\u0a33\u0a35\u0a36\u0a38\u0a39\u0a59-\u0a5c\u0a5e\u0a72-\u0a74\u0a85-\u0a8d\u0a8f-\u0a91\u0a93-\u0aa8\u0aaa-\u0ab0\u0ab2\u0ab3\u0ab5-\u0ab9\u0abd\u0ad0\u0ae0\u0ae1\u0b05-\u0b0c\u0b0f\u0b10\u0b13-\u0b28\u0b2a-\u0b30\u0b32\u0b33\u0b35-\u0b39\u0b3d\u0b5c\u0b5d\u0b5f-\u0b61\u0b71\u0b83\u0b85-\u0b8a\u0b8e-\u0b90\u0b92-\u0b95\u0b99\u0b9a\u0b9c\u0b9e\u0b9f\u0ba3\u0ba4\u0ba8-\u0baa\u0bae-\u0bb9\u0bd0\u0c05-\u0c0c\u0c0e-\u0c10\u0c12-\u0c28\u0c2a-\u0c33\u0c35-\u0c39\u0c3d\u0c58\u0c59\u0c60\u0c61\u0c85-\u0c8c\u0c8e-\u0c90\u0c92-\u0ca8\u0caa-\u0cb3\u0cb5-\u0cb9\u0cbd\u0cde\u0ce0\u0ce1\u0cf1\u0cf2\u0d05-\u0d0c\u0d0e-\u0d10\u0d12-\u0d3a\u0d3d\u0d4e\u0d60\u0d61\u0d7a-\u0d7f\u0d85-\u0d96\u0d9a-\u0db1\u0db3-\u0dbb\u0dbd\u0dc0-\u0dc6\u0e01-\u0e30\u0e32\u0e33\u0e40-\u0e46\u0e81\u0e82\u0e84\u0e87\u0e88\u0e8a\u0e8d\u0e94-\u0e97\u0e99-\u0e9f\u0ea1-\u0ea3\u0ea5\u0ea7\u0eaa\u0eab\u0ead-\u0eb0\u0eb2\u0eb3\u0ebd\u0ec0-\u0ec4\u0ec6\u0edc-\u0edf\u0f00\u0f40-\u0f47\u0f49-\u0f6c\u0f88-\u0f8c\u1000-\u102a\u103f\u1050-\u1055\u105a-\u105d\u1061\u1065\u1066\u106e-\u1070\u1075-\u1081\u108e\u10a0-\u10c5\u10c7\u10cd\u10d0-\u10fa\u10fc-\u1248\u124a-\u124d\u1250-\u1256\u1258\u125a-\u125d\u1260-\u1288\u128a-\u128d\u1290-\u12b0\u12b2-\u12b5\u12b8-\u12be\u12c0\u12c2-\u12c5\u12c8-\u12d6\u12d8-\u1310\u1312-\u1315\u1318-\u135a\u1380-\u138f\u13a0-\u13f4\u1401-\u166c\u166f-\u167f\u1681-\u169a\u16a0-\u16ea\u16ee-\u16f0\u1700-\u170c\u170e-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176c\u176e-\u1770\u1780-\u17b3\u17d7\u17dc\u1820-\u1877\u1880-\u18a8\u18aa\u18b0-\u18f5\u1900-\u191c\u1950-\u196d\u1970-\u1974\u1980-\u19ab\u19c1-\u19c7\u1a00-\u1a16\u1a20-\u1a54\u1aa7\u1b05-\u1b33\u1b45-\u1b4b\u1b83-\u1ba0\u1bae\u1baf\u1bba-\u1be5\u1c00-\u1c23\u1c4d-\u1c4f\u1c5a-\u1c7d\u1ce9-\u1cec\u1cee-\u1cf1\u1cf5\u1cf6\u1d00-\u1dbf\u1e00-\u1f15\u1f18-\u1f1d\u1f20-\u1f45\u1f48-\u1f4d\u1f50-\u1f57\u1f59\u1f5b\u1f5d\u1f5f-\u1f7d\u1f80-\u1fb4\u1fb6-\u1fbc\u1fbe\u1fc2-\u1fc4\u1fc6-\u1fcc\u1fd0-\u1fd3\u1fd6-\u1fdb\u1fe0-\u1fec\u1ff2-\u1ff4\u1ff6-\u1ffc\u2071\u207f\u2090-\u209c\u2102\u2107\u210a-\u2113\u2115\u2119-\u211d\u2124\u2126\u2128\u212a-\u212d\u212f-\u2139\u213c-\u213f\u2145-\u2149\u214e\u2160-\u2188\u2c00-\u2c2e\u2c30-\u2c5e\u2c60-\u2ce4\u2ceb-\u2cee\u2cf2\u2cf3\u2d00-\u2d25\u2d27\u2d2d\u2d30-\u2d67\u2d6f\u2d80-\u2d96\u2da0-\u2da6\u2da8-\u2dae\u2db0-\u2db6\u2db8-\u2dbe\u2dc0-\u2dc6\u2dc8-\u2dce\u2dd0-\u2dd6\u2dd8-\u2dde\u2e2f\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303c\u3041-\u3096\u309d-\u309f\u30a1-\u30fa\u30fc-\u30ff\u3105-\u312d\u3131-\u318e\u31a0-\u31ba\u31f0-\u31ff\u3400-\u4db5\u4e00-\u9fcc\ua000-\ua48c\ua4d0-\ua4fd\ua500-\ua60c\ua610-\ua61f\ua62a\ua62b\ua640-\ua66e\ua67f-\ua697\ua6a0-\ua6ef\ua717-\ua71f\ua722-\ua788\ua78b-\ua78e\ua790-\ua793\ua7a0-\ua7aa\ua7f8-\ua801\ua803-\ua805\ua807-\ua80a\ua80c-\ua822\ua840-\ua873\ua882-\ua8b3\ua8f2-\ua8f7\ua8fb\ua90a-\ua925\ua930-\ua946\ua960-\ua97c\ua984-\ua9b2\ua9cf\uaa00-\uaa28\uaa40-\uaa42\uaa44-\uaa4b\uaa60-\uaa76\uaa7a\uaa80-\uaaaf\uaab1\uaab5\uaab6\uaab9-\uaabd\uaac0\uaac2\uaadb-\uaadd\uaae0-\uaaea\uaaf2-\uaaf4\uab01-\uab06\uab09-\uab0e\uab11-\uab16\uab20-\uab26\uab28-\uab2e\uabc0-\uabe2\uac00-\ud7a3\ud7b0-\ud7c6\ud7cb-\ud7fb\uf900-\ufa6d\ufa70-\ufad9\ufb00-\ufb06\ufb13-\ufb17\ufb1d\ufb1f-\ufb28\ufb2a-\ufb36\ufb38-\ufb3c\ufb3e\ufb40\ufb41\ufb43\ufb44\ufb46-\ufbb1\ufbd3-\ufd3d\ufd50-\ufd8f\ufd92-\ufdc7\ufdf0-\ufdfb\ufe70-\ufe74\ufe76-\ufefc\uff21-\uff3a\uff41-\uff5a\uff66-\uffbe\uffc2-\uffc7\uffca-\uffcf\uffd2-\uffd7\uffda-\uffdc"; 3491 var nonASCIIidentifierChars = "\u0300-\u036f\u0483-\u0487\u0591-\u05bd\u05bf\u05c1\u05c2\u05c4\u05c5\u05c7\u0610-\u061a\u0620-\u0649\u0672-\u06d3\u06e7-\u06e8\u06fb-\u06fc\u0730-\u074a\u0800-\u0814\u081b-\u0823\u0825-\u0827\u0829-\u082d\u0840-\u0857\u08e4-\u08fe\u0900-\u0903\u093a-\u093c\u093e-\u094f\u0951-\u0957\u0962-\u0963\u0966-\u096f\u0981-\u0983\u09bc\u09be-\u09c4\u09c7\u09c8\u09d7\u09df-\u09e0\u0a01-\u0a03\u0a3c\u0a3e-\u0a42\u0a47\u0a48\u0a4b-\u0a4d\u0a51\u0a66-\u0a71\u0a75\u0a81-\u0a83\u0abc\u0abe-\u0ac5\u0ac7-\u0ac9\u0acb-\u0acd\u0ae2-\u0ae3\u0ae6-\u0aef\u0b01-\u0b03\u0b3c\u0b3e-\u0b44\u0b47\u0b48\u0b4b-\u0b4d\u0b56\u0b57\u0b5f-\u0b60\u0b66-\u0b6f\u0b82\u0bbe-\u0bc2\u0bc6-\u0bc8\u0bca-\u0bcd\u0bd7\u0be6-\u0bef\u0c01-\u0c03\u0c46-\u0c48\u0c4a-\u0c4d\u0c55\u0c56\u0c62-\u0c63\u0c66-\u0c6f\u0c82\u0c83\u0cbc\u0cbe-\u0cc4\u0cc6-\u0cc8\u0cca-\u0ccd\u0cd5\u0cd6\u0ce2-\u0ce3\u0ce6-\u0cef\u0d02\u0d03\u0d46-\u0d48\u0d57\u0d62-\u0d63\u0d66-\u0d6f\u0d82\u0d83\u0dca\u0dcf-\u0dd4\u0dd6\u0dd8-\u0ddf\u0df2\u0df3\u0e34-\u0e3a\u0e40-\u0e45\u0e50-\u0e59\u0eb4-\u0eb9\u0ec8-\u0ecd\u0ed0-\u0ed9\u0f18\u0f19\u0f20-\u0f29\u0f35\u0f37\u0f39\u0f41-\u0f47\u0f71-\u0f84\u0f86-\u0f87\u0f8d-\u0f97\u0f99-\u0fbc\u0fc6\u1000-\u1029\u1040-\u1049\u1067-\u106d\u1071-\u1074\u1082-\u108d\u108f-\u109d\u135d-\u135f\u170e-\u1710\u1720-\u1730\u1740-\u1750\u1772\u1773\u1780-\u17b2\u17dd\u17e0-\u17e9\u180b-\u180d\u1810-\u1819\u1920-\u192b\u1930-\u193b\u1951-\u196d\u19b0-\u19c0\u19c8-\u19c9\u19d0-\u19d9\u1a00-\u1a15\u1a20-\u1a53\u1a60-\u1a7c\u1a7f-\u1a89\u1a90-\u1a99\u1b46-\u1b4b\u1b50-\u1b59\u1b6b-\u1b73\u1bb0-\u1bb9\u1be6-\u1bf3\u1c00-\u1c22\u1c40-\u1c49\u1c5b-\u1c7d\u1cd0-\u1cd2\u1d00-\u1dbe\u1e01-\u1f15\u200c\u200d\u203f\u2040\u2054\u20d0-\u20dc\u20e1\u20e5-\u20f0\u2d81-\u2d96\u2de0-\u2dff\u3021-\u3028\u3099\u309a\ua640-\ua66d\ua674-\ua67d\ua69f\ua6f0-\ua6f1\ua7f8-\ua800\ua806\ua80b\ua823-\ua827\ua880-\ua881\ua8b4-\ua8c4\ua8d0-\ua8d9\ua8f3-\ua8f7\ua900-\ua909\ua926-\ua92d\ua930-\ua945\ua980-\ua983\ua9b3-\ua9c0\uaa00-\uaa27\uaa40-\uaa41\uaa4c-\uaa4d\uaa50-\uaa59\uaa7b\uaae0-\uaae9\uaaf2-\uaaf3\uabc0-\uabe1\uabec\uabed\uabf0-\uabf9\ufb20-\ufb28\ufe00-\ufe0f\ufe20-\ufe26\ufe33\ufe34\ufe4d-\ufe4f\uff10-\uff19\uff3f"; 3492 var nonASCIIidentifierStart = new RegExp("[" + nonASCIIidentifierStartChars + "]"); 3493 var nonASCIIidentifier = new RegExp("[" + nonASCIIidentifierStartChars + nonASCIIidentifierChars + "]"); 3494 3495 // Whether a single character denotes a newline. 3496 3497 exports.newline = /[\n\r\u2028\u2029]/; 3498 3499 // Matches a whole line break (where CRLF is considered a single 3500 // line break). Used to count lines. 3501 3502 // in javascript, these two differ 3503 // in python they are the same, different methods are called on them 3504 exports.lineBreak = new RegExp('\r\n|' + exports.newline.source); 3505 exports.allLineBreaks = new RegExp(exports.lineBreak.source, 'g'); 3506 3507 3508 // Test whether a given character code starts an identifier. 3509 3510 exports.isIdentifierStart = function(code) { 3511 // permit $ (36) and @ (64). @ is used in ES7 decorators. 3512 if (code < 65) return code === 36 || code === 64; 3513 // 65 through 91 are uppercase letters. 3514 if (code < 91) return true; 3515 // permit _ (95). 3516 if (code < 97) return code === 95; 3517 // 97 through 123 are lowercase letters. 3518 if (code < 123) return true; 3519 return code >= 0xaa && nonASCIIidentifierStart.test(String.fromCharCode(code)); 3520 }; 3521 3522 // Test whether a given character is part of an identifier. 3523 3524 exports.isIdentifierChar = function(code) { 3525 if (code < 48) return code === 36; 3526 if (code < 58) return true; 3527 if (code < 65) return false; 3528 if (code < 91) return true; 3529 if (code < 97) return code === 95; 3530 if (code < 123) return true; 3531 return code >= 0xaa && nonASCIIidentifier.test(String.fromCharCode(code)); 3532 }; 3533 3534 3535 /***/ }), 3536 /* 2 */ 3537 /***/ (function(module, exports) { 3538 3539 /*jshint curly:true, eqeqeq:true, laxbreak:true, noempty:false */ 3540 /* 3541 3542 The MIT License (MIT) 3543 3544 Copyright (c) 2007-2017 Einar Lielmanis, Liam Newman, and contributors. 3545 3546 Permission is hereby granted, free of charge, to any person 3547 obtaining a copy of this software and associated documentation files 3548 (the "Software"), to deal in the Software without restriction, 3549 including without limitation the rights to use, copy, modify, merge, 3550 publish, distribute, sublicense, and/or sell copies of the Software, 3551 and to permit persons to whom the Software is furnished to do so, 3552 subject to the following conditions: 3553 3554 The above copyright notice and this permission notice shall be 3555 included in all copies or substantial portions of the Software. 3556 3557 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 3558 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 3559 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 3560 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 3561 BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 3562 ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 3563 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 3564 SOFTWARE. 3565 */ 3566 3567 function mergeOpts(allOptions, targetType) { 3568 var finalOpts = {}; 3569 var name; 3570 3571 for (name in allOptions) { 3572 if (name !== targetType) { 3573 finalOpts[name] = allOptions[name]; 3574 } 3575 } 3576 3577 //merge in the per type settings for the targetType 3578 if (targetType in allOptions) { 3579 for (name in allOptions[targetType]) { 3580 finalOpts[name] = allOptions[targetType][name]; 3581 } 3582 } 3583 return finalOpts; 3584 } 3585 3586 module.exports.mergeOpts = mergeOpts; 3587 3588 3589 /***/ }), 3590 /* 3 */ 3591 /***/ (function(module, exports) { 3592 3593 /*jshint curly:true, eqeqeq:true, laxbreak:true, noempty:false */ 3594 /* 3595 3596 The MIT License (MIT) 3597 3598 Copyright (c) 2007-2017 Einar Lielmanis, Liam Newman, and contributors. 3599 3600 Permission is hereby granted, free of charge, to any person 3601 obtaining a copy of this software and associated documentation files 3602 (the "Software"), to deal in the Software without restriction, 3603 including without limitation the rights to use, copy, modify, merge, 3604 publish, distribute, sublicense, and/or sell copies of the Software, 3605 and to permit persons to whom the Software is furnished to do so, 3606 subject to the following conditions: 3607 3608 The above copyright notice and this permission notice shall be 3609 included in all copies or substantial portions of the Software. 3610 3611 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 3612 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 3613 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 3614 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 3615 BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 3616 ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 3617 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 3618 SOFTWARE. 3619 */ 3620 3621 function OutputLine(parent) { 3622 var _character_count = 0; 3623 // use indent_count as a marker for lines that have preserved indentation 3624 var _indent_count = -1; 3625 3626 var _items = []; 3627 var _empty = true; 3628 3629 this.set_indent = function(level) { 3630 _character_count = parent.baseIndentLength + level * parent.indent_length; 3631 _indent_count = level; 3632 }; 3633 3634 this.get_character_count = function() { 3635 return _character_count; 3636 }; 3637 3638 this.is_empty = function() { 3639 return _empty; 3640 }; 3641 3642 this.last = function() { 3643 if (!this._empty) { 3644 return _items[_items.length - 1]; 3645 } else { 3646 return null; 3647 } 3648 }; 3649 3650 this.push = function(input) { 3651 _items.push(input); 3652 _character_count += input.length; 3653 _empty = false; 3654 }; 3655 3656 this.pop = function() { 3657 var item = null; 3658 if (!_empty) { 3659 item = _items.pop(); 3660 _character_count -= item.length; 3661 _empty = _items.length === 0; 3662 } 3663 return item; 3664 }; 3665 3666 this.remove_indent = function() { 3667 if (_indent_count > 0) { 3668 _indent_count -= 1; 3669 _character_count -= parent.indent_length; 3670 } 3671 }; 3672 3673 this.trim = function() { 3674 while (this.last() === ' ') { 3675 _items.pop(); 3676 _character_count -= 1; 3677 } 3678 _empty = _items.length === 0; 3679 }; 3680 3681 this.toString = function() { 3682 var result = ''; 3683 if (!this._empty) { 3684 if (_indent_count >= 0) { 3685 result = parent.indent_cache[_indent_count]; 3686 } 3687 result += _items.join(''); 3688 } 3689 return result; 3690 }; 3691 } 3692 3693 function Output(indent_string, baseIndentString) { 3694 baseIndentString = baseIndentString || ''; 3695 this.indent_cache = [baseIndentString]; 3696 this.baseIndentLength = baseIndentString.length; 3697 this.indent_length = indent_string.length; 3698 this.raw = false; 3699 3700 var lines = []; 3701 this.baseIndentString = baseIndentString; 3702 this.indent_string = indent_string; 3703 this.previous_line = null; 3704 this.current_line = null; 3705 this.space_before_token = false; 3706 3707 this.add_outputline = function() { 3708 this.previous_line = this.current_line; 3709 this.current_line = new OutputLine(this); 3710 lines.push(this.current_line); 3711 }; 3712 3713 // initialize 3714 this.add_outputline(); 3715 3716 3717 this.get_line_number = function() { 3718 return lines.length; 3719 }; 3720 3721 // Using object instead of string to allow for later expansion of info about each line 3722 this.add_new_line = function(force_newline) { 3723 if (this.get_line_number() === 1 && this.just_added_newline()) { 3724 return false; // no newline on start of file 3725 } 3726 3727 if (force_newline || !this.just_added_newline()) { 3728 if (!this.raw) { 3729 this.add_outputline(); 3730 } 3731 return true; 3732 } 3733 3734 return false; 3735 }; 3736 3737 this.get_code = function(end_with_newline, eol) { 3738 var sweet_code = lines.join('\n').replace(/[\r\n\t ]+$/, ''); 3739 3740 if (end_with_newline) { 3741 sweet_code += '\n'; 3742 } 3743 3744 if (eol !== '\n') { 3745 sweet_code = sweet_code.replace(/[\n]/g, eol); 3746 } 3747 3748 return sweet_code; 3749 }; 3750 3751 this.set_indent = function(level) { 3752 // Never indent your first output indent at the start of the file 3753 if (lines.length > 1) { 3754 while (level >= this.indent_cache.length) { 3755 this.indent_cache.push(this.indent_cache[this.indent_cache.length - 1] + this.indent_string); 3756 } 3757 3758 this.current_line.set_indent(level); 3759 return true; 3760 } 3761 this.current_line.set_indent(0); 3762 return false; 3763 }; 3764 3765 this.add_raw_token = function(token) { 3766 for (var x = 0; x < token.newlines; x++) { 3767 this.add_outputline(); 3768 } 3769 this.current_line.push(token.whitespace_before); 3770 this.current_line.push(token.text); 3771 this.space_before_token = false; 3772 }; 3773 3774 this.add_token = function(printable_token) { 3775 this.add_space_before_token(); 3776 this.current_line.push(printable_token); 3777 }; 3778 3779 this.add_space_before_token = function() { 3780 if (this.space_before_token && !this.just_added_newline()) { 3781 this.current_line.push(' '); 3782 } 3783 this.space_before_token = false; 3784 }; 3785 3786 this.remove_indent = function(index) { 3787 var output_length = lines.length; 3788 while (index < output_length) { 3789 lines[index].remove_indent(); 3790 index++; 3791 } 3792 }; 3793 3794 this.trim = function(eat_newlines) { 3795 eat_newlines = (eat_newlines === undefined) ? false : eat_newlines; 3796 3797 this.current_line.trim(indent_string, baseIndentString); 3798 3799 while (eat_newlines && lines.length > 1 && 3800 this.current_line.is_empty()) { 3801 lines.pop(); 3802 this.current_line = lines[lines.length - 1]; 3803 this.current_line.trim(); 3804 } 3805 3806 this.previous_line = lines.length > 1 ? lines[lines.length - 2] : null; 3807 }; 3808 3809 this.just_added_newline = function() { 3810 return this.current_line.is_empty(); 3811 }; 3812 3813 this.just_added_blankline = function() { 3814 if (this.just_added_newline()) { 3815 if (lines.length === 1) { 3816 return true; // start of the file and newline = blank 3817 } 3818 3819 var line = lines[lines.length - 2]; 3820 return line.is_empty(); 3821 } 3822 return false; 3823 }; 3824 } 3825 3826 module.exports.Output = Output; 3827 3828 3829 /***/ }), 3830 /* 4 */ 3831 /***/ (function(module, exports, __webpack_require__) { 3832 3833 /*jshint curly:true, eqeqeq:true, laxbreak:true, noempty:false */ 3834 /* 3835 3836 The MIT License (MIT) 3837 3838 Copyright (c) 2007-2017 Einar Lielmanis, Liam Newman, and contributors. 3839 3840 Permission is hereby granted, free of charge, to any person 3841 obtaining a copy of this software and associated documentation files 3842 (the "Software"), to deal in the Software without restriction, 3843 including without limitation the rights to use, copy, modify, merge, 3844 publish, distribute, sublicense, and/or sell copies of the Software, 3845 and to permit persons to whom the Software is furnished to do so, 3846 subject to the following conditions: 3847 3848 The above copyright notice and this permission notice shall be 3849 included in all copies or substantial portions of the Software. 3850 3851 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 3852 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 3853 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 3854 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 3855 BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 3856 ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 3857 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 3858 SOFTWARE. 3859 */ 3860 3861 var Beautifier = __webpack_require__(0).Beautifier; 3862 3863 function css_beautify(source_text, options) { 3864 var beautifier = new Beautifier(source_text, options); 3865 return beautifier.beautify(); 3866 } 3867 3868 module.exports = css_beautify; 3869 3870 /***/ }) 3871 /******/ ]); 3872 var css_beautify = legacy_beautify_css; 3873 /* Footer */ 3874 if (typeof define === "function" && define.amd) { 3875 // Add support for AMD ( https://github.com/amdjs/amdjs-api/wiki/AMD#defineamd-property- ) 3876 define([], function() { 3877 return { 3878 css_beautify: css_beautify 3879 }; 3880 }); 3881 } else if (typeof exports !== "undefined") { 3882 // Add support for CommonJS. Just put this file somewhere on your require.paths 3883 // and you will be able to `var html_beautify = require("beautify").html_beautify`. 3884 exports.css_beautify = css_beautify; 3885 } else if (typeof window !== "undefined") { 3886 // If we're running a web page and don't have either of the above, add our one global 3887 window.css_beautify = css_beautify; 3888 } else if (typeof global !== "undefined") { 3889 // If we don't even have window, try global. 3890 global.css_beautify = css_beautify; 3891 } 3892 3893 }()); 3894 /*jshint curly:false, eqeqeq:true, laxbreak:true, noempty:false */ 3895 /* AUTO-GENERATED. DO NOT MODIFY. */ 3896 /* 3897 3898 The MIT License (MIT) 3899 3900 Copyright (c) 2007-2017 Einar Lielmanis, Liam Newman, and contributors. 3901 3902 Permission is hereby granted, free of charge, to any person 3903 obtaining a copy of this software and associated documentation files 3904 (the "Software"), to deal in the Software without restriction, 3905 including without limitation the rights to use, copy, modify, merge, 3906 publish, distribute, sublicense, and/or sell copies of the Software, 3907 and to permit persons to whom the Software is furnished to do so, 3908 subject to the following conditions: 3909 3910 The above copyright notice and this permission notice shall be 3911 included in all copies or substantial portions of the Software. 3912 3913 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 3914 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 3915 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 3916 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 3917 BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 3918 ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 3919 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 3920 SOFTWARE. 3921 3922 3923 Style HTML 3924 --------------- 3925 3926 Written by Nochum Sossonko, (nsossonko@hotmail.com) 3927 3928 Based on code initially developed by: Einar Lielmanis, <einar@jsbeautifier.org> 3929 http://jsbeautifier.org/ 3930 3931 Usage: 3932 style_html(html_source); 3933 3934 style_html(html_source, options); 3935 3936 The options are: 3937 indent_inner_html (default false) — indent <head> and <body> sections, 3938 indent_size (default 4) — indentation size, 3939 indent_char (default space) — character to indent with, 3940 wrap_line_length (default 250) - maximum amount of characters per line (0 = disable) 3941 brace_style (default "collapse") - "collapse" | "expand" | "end-expand" | "none" 3942 put braces on the same line as control statements (default), or put braces on own line (Allman / ANSI style), or just put end braces on own line, or attempt to keep them where they are. 3943 unformatted (defaults to inline tags) - list of tags, that shouldn't be reformatted 3944 content_unformatted (defaults to pre tag) - list of tags, whose content shouldn't be reformatted 3945 indent_scripts (default normal) - "keep"|"separate"|"normal" 3946 preserve_newlines (default true) - whether existing line breaks before elements should be preserved 3947 Only works before elements, not inside tags or for text. 3948 max_preserve_newlines (default unlimited) - maximum number of line breaks to be preserved in one chunk 3949 indent_handlebars (default false) - format and indent {{#foo}} and {{/foo}} 3950 end_with_newline (false) - end with a newline 3951 extra_liners (default [head,body,/html]) -List of tags that should have an extra newline before them. 3952 3953 e.g. 3954 3955 style_html(html_source, { 3956 'indent_inner_html': false, 3957 'indent_size': 2, 3958 'indent_char': ' ', 3959 'wrap_line_length': 78, 3960 'brace_style': 'expand', 3961 'preserve_newlines': true, 3962 'max_preserve_newlines': 5, 3963 'indent_handlebars': false, 3964 'extra_liners': ['/html'] 3965 }); 3966 */ 3967 3968 (function() { 3969 var legacy_beautify_html = 3970 /******/ (function(modules) { // webpackBootstrap 3971 /******/ // The module cache 3972 /******/ var installedModules = {}; 3973 /******/ 3974 /******/ // The require function 3975 /******/ function __webpack_require__(moduleId) { 3976 /******/ 3977 /******/ // Check if module is in cache 3978 /******/ if(installedModules[moduleId]) { 3979 /******/ return installedModules[moduleId].exports; 3980 /******/ } 3981 /******/ // Create a new module (and put it into the cache) 3982 /******/ var module = installedModules[moduleId] = { 3983 /******/ i: moduleId, 3984 /******/ l: false, 3985 /******/ exports: {} 3986 /******/ }; 3987 /******/ 3988 /******/ // Execute the module function 3989 /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); 3990 /******/ 3991 /******/ // Flag the module as loaded 3992 /******/ module.l = true; 3993 /******/ 3994 /******/ // Return the exports of the module 3995 /******/ return module.exports; 3996 /******/ } 3997 /******/ 3998 /******/ 3999 /******/ // expose the modules object (__webpack_modules__) 4000 /******/ __webpack_require__.m = modules; 4001 /******/ 4002 /******/ // expose the module cache 4003 /******/ __webpack_require__.c = installedModules; 4004 /******/ 4005 /******/ // identity function for calling harmony imports with the correct context 4006 /******/ __webpack_require__.i = function(value) { return value; }; 4007 /******/ 4008 /******/ // define getter function for harmony exports 4009 /******/ __webpack_require__.d = function(exports, name, getter) { 4010 /******/ if(!__webpack_require__.o(exports, name)) { 4011 /******/ Object.defineProperty(exports, name, { 4012 /******/ configurable: false, 4013 /******/ enumerable: true, 4014 /******/ get: getter 4015 /******/ }); 4016 /******/ } 4017 /******/ }; 4018 /******/ 4019 /******/ // getDefaultExport function for compatibility with non-harmony modules 4020 /******/ __webpack_require__.n = function(module) { 4021 /******/ var getter = module && module.__esModule ? 4022 /******/ function getDefault() { return module['default']; } : 4023 /******/ function getModuleExports() { return module; }; 4024 /******/ __webpack_require__.d(getter, 'a', getter); 4025 /******/ return getter; 4026 /******/ }; 4027 /******/ 4028 /******/ // Object.prototype.hasOwnProperty.call 4029 /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; 4030 /******/ 4031 /******/ // __webpack_public_path__ 4032 /******/ __webpack_require__.p = ""; 4033 /******/ 4034 /******/ // Load entry module and return exports 4035 /******/ return __webpack_require__(__webpack_require__.s = 3); 4036 /******/ }) 4037 /************************************************************************/ 4038 /******/ ([ 4039 /* 0 */ 4040 /***/ (function(module, exports, __webpack_require__) { 4041 4042 /*jshint curly:true, eqeqeq:true, laxbreak:true, noempty:false */ 4043 /* 4044 4045 The MIT License (MIT) 4046 4047 Copyright (c) 2007-2017 Einar Lielmanis, Liam Newman, and contributors. 4048 4049 Permission is hereby granted, free of charge, to any person 4050 obtaining a copy of this software and associated documentation files 4051 (the "Software"), to deal in the Software without restriction, 4052 including without limitation the rights to use, copy, modify, merge, 4053 publish, distribute, sublicense, and/or sell copies of the Software, 4054 and to permit persons to whom the Software is furnished to do so, 4055 subject to the following conditions: 4056 4057 The above copyright notice and this permission notice shall be 4058 included in all copies or substantial portions of the Software. 4059 4060 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 4061 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 4062 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 4063 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 4064 BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 4065 ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 4066 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 4067 SOFTWARE. 4068 */ 4069 4070 var mergeOpts = __webpack_require__(2).mergeOpts; 4071 var acorn = __webpack_require__(1); 4072 4073 4074 var lineBreak = acorn.lineBreak; 4075 var allLineBreaks = acorn.allLineBreaks; 4076 4077 // function trim(s) { 4078 // return s.replace(/^\s+|\s+$/g, ''); 4079 // } 4080 4081 function ltrim(s) { 4082 return s.replace(/^\s+/g, ''); 4083 } 4084 4085 function rtrim(s) { 4086 return s.replace(/\s+$/g, ''); 4087 } 4088 4089 function Beautifier(html_source, options, js_beautify, css_beautify) { 4090 //Wrapper function to invoke all the necessary constructors and deal with the output. 4091 html_source = html_source || ''; 4092 4093 var multi_parser, 4094 indent_inner_html, 4095 indent_body_inner_html, 4096 indent_head_inner_html, 4097 indent_size, 4098 indent_character, 4099 wrap_line_length, 4100 brace_style, 4101 unformatted, 4102 content_unformatted, 4103 preserve_newlines, 4104 max_preserve_newlines, 4105 indent_handlebars, 4106 wrap_attributes, 4107 wrap_attributes_indent_size, 4108 is_wrap_attributes_force, 4109 is_wrap_attributes_force_expand_multiline, 4110 is_wrap_attributes_force_aligned, 4111 end_with_newline, 4112 extra_liners, 4113 eol; 4114 4115 options = options || {}; 4116 4117 // Allow the setting of language/file-type specific options 4118 // with inheritance of overall settings 4119 options = mergeOpts(options, 'html'); 4120 4121 // backwards compatibility to 1.3.4 4122 if ((options.wrap_line_length === undefined || parseInt(options.wrap_line_length, 10) === 0) && 4123 (options.max_char !== undefined && parseInt(options.max_char, 10) !== 0)) { 4124 options.wrap_line_length = options.max_char; 4125 } 4126 4127 indent_inner_html = (options.indent_inner_html === undefined) ? false : options.indent_inner_html; 4128 indent_body_inner_html = (options.indent_body_inner_html === undefined) ? true : options.indent_body_inner_html; 4129 indent_head_inner_html = (options.indent_head_inner_html === undefined) ? true : options.indent_head_inner_html; 4130 indent_size = (options.indent_size === undefined) ? 4 : parseInt(options.indent_size, 10); 4131 indent_character = (options.indent_char === undefined) ? ' ' : options.indent_char; 4132 brace_style = (options.brace_style === undefined) ? 'collapse' : options.brace_style; 4133 wrap_line_length = parseInt(options.wrap_line_length, 10) === 0 ? 32786 : parseInt(options.wrap_line_length || 250, 10); 4134 unformatted = options.unformatted || [ 4135 // https://www.w3.org/TR/html5/dom.html#phrasing-content 4136 'a', 'abbr', 'area', 'audio', 'b', 'bdi', 'bdo', 'br', 'button', 'canvas', 'cite', 4137 'code', 'data', 'datalist', 'del', 'dfn', 'em', 'embed', 'i', 'iframe', 'img', 4138 'input', 'ins', 'kbd', 'keygen', 'label', 'map', 'mark', 'math', 'meter', 'noscript', 4139 'object', 'output', 'progress', 'q', 'ruby', 's', 'samp', /* 'script', */ 'select', 'small', 4140 'span', 'strong', 'sub', 'sup', 'svg', 'template', 'textarea', 'time', 'u', 'var', 4141 'video', 'wbr', 'text', 4142 // prexisting - not sure of full effect of removing, leaving in 4143 'acronym', 'address', 'big', 'dt', 'ins', 'strike', 'tt', 4144 ]; 4145 content_unformatted = options.content_unformatted || [ 4146 'pre', 4147 ]; 4148 preserve_newlines = (options.preserve_newlines === undefined) ? true : options.preserve_newlines; 4149 max_preserve_newlines = preserve_newlines ? 4150 (isNaN(parseInt(options.max_preserve_newlines, 10)) ? 32786 : parseInt(options.max_preserve_newlines, 10)) : 4151 0; 4152 indent_handlebars = (options.indent_handlebars === undefined) ? false : options.indent_handlebars; 4153 wrap_attributes = (options.wrap_attributes === undefined) ? 'auto' : options.wrap_attributes; 4154 wrap_attributes_indent_size = (isNaN(parseInt(options.wrap_attributes_indent_size, 10))) ? indent_size : parseInt(options.wrap_attributes_indent_size, 10); 4155 is_wrap_attributes_force = wrap_attributes.substr(0, 'force'.length) === 'force'; 4156 is_wrap_attributes_force_expand_multiline = (wrap_attributes === 'force-expand-multiline'); 4157 is_wrap_attributes_force_aligned = (wrap_attributes === 'force-aligned'); 4158 end_with_newline = (options.end_with_newline === undefined) ? false : options.end_with_newline; 4159 extra_liners = (typeof options.extra_liners === 'object') && options.extra_liners ? 4160 options.extra_liners.concat() : (typeof options.extra_liners === 'string') ? 4161 options.extra_liners.split(',') : 'head,body,/html'.split(','); 4162 eol = options.eol ? options.eol : 'auto'; 4163 4164 if (options.indent_with_tabs) { 4165 indent_character = '\t'; 4166 indent_size = 1; 4167 } 4168 4169 if (eol === 'auto') { 4170 eol = '\n'; 4171 if (html_source && lineBreak.test(html_source || '')) { 4172 eol = html_source.match(lineBreak)[0]; 4173 } 4174 } 4175 4176 eol = eol.replace(/\\r/, '\r').replace(/\\n/, '\n'); 4177 4178 // HACK: newline parsing inconsistent. This brute force normalizes the input. 4179 html_source = html_source.replace(allLineBreaks, '\n'); 4180 4181 function Parser() { 4182 4183 this.pos = 0; //Parser position 4184 this.token = ''; 4185 this.current_mode = 'CONTENT'; //reflects the current Parser mode: TAG/CONTENT 4186 this.tags = { //An object to hold tags, their position, and their parent-tags, initiated with default values 4187 parent: 'parent1', 4188 parentcount: 1, 4189 parent1: '' 4190 }; 4191 this.tag_type = ''; 4192 this.token_text = this.last_token = this.last_text = this.token_type = ''; 4193 this.newlines = 0; 4194 this.indent_content = indent_inner_html; 4195 this.indent_body_inner_html = indent_body_inner_html; 4196 this.indent_head_inner_html = indent_head_inner_html; 4197 4198 this.Utils = { //Uilities made available to the various functions 4199 whitespace: "\n\r\t ".split(''), 4200 4201 single_token: options.void_elements || [ 4202 // HTLM void elements - aka self-closing tags - aka singletons 4203 // https://www.w3.org/html/wg/drafts/html/master/syntax.html#void-elements 4204 'area', 'base', 'br', 'col', 'embed', 'hr', 'img', 'input', 'keygen', 4205 'link', 'menuitem', 'meta', 'param', 'source', 'track', 'wbr', 4206 // NOTE: Optional tags - are not understood. 4207 // https://www.w3.org/TR/html5/syntax.html#optional-tags 4208 // The rules for optional tags are too complex for a simple list 4209 // Also, the content of these tags should still be indented in many cases. 4210 // 'li' is a good exmple. 4211 4212 // Doctype and xml elements 4213 '!doctype', '?xml', 4214 // ?php tag 4215 '?php', 4216 // other tags that were in this list, keeping just in case 4217 'basefont', 'isindex' 4218 ], 4219 extra_liners: extra_liners, //for tags that need a line of whitespace before them 4220 in_array: function(what, arr) { 4221 for (var i = 0; i < arr.length; i++) { 4222 if (what === arr[i]) { 4223 return true; 4224 } 4225 } 4226 return false; 4227 } 4228 }; 4229 4230 // Return true if the given text is composed entirely of whitespace. 4231 this.is_whitespace = function(text) { 4232 for (var n = 0; n < text.length; n++) { 4233 if (!this.Utils.in_array(text.charAt(n), this.Utils.whitespace)) { 4234 return false; 4235 } 4236 } 4237 return true; 4238 }; 4239 4240 this.traverse_whitespace = function() { 4241 var input_char = ''; 4242 4243 input_char = this.input.charAt(this.pos); 4244 if (this.Utils.in_array(input_char, this.Utils.whitespace)) { 4245 this.newlines = 0; 4246 while (this.Utils.in_array(input_char, this.Utils.whitespace)) { 4247 if (preserve_newlines && input_char === '\n' && this.newlines <= max_preserve_newlines) { 4248 this.newlines += 1; 4249 } 4250 4251 this.pos++; 4252 input_char = this.input.charAt(this.pos); 4253 } 4254 return true; 4255 } 4256 return false; 4257 }; 4258 4259 // Append a space to the given content (string array) or, if we are 4260 // at the wrap_line_length, append a newline/indentation. 4261 // return true if a newline was added, false if a space was added 4262 this.space_or_wrap = function(content) { 4263 if (this.line_char_count >= this.wrap_line_length) { //insert a line when the wrap_line_length is reached 4264 this.print_newline(false, content); 4265 this.print_indentation(content); 4266 return true; 4267 } else { 4268 this.line_char_count++; 4269 content.push(' '); 4270 return false; 4271 } 4272 }; 4273 4274 this.get_content = function() { //function to capture regular content between tags 4275 var input_char = '', 4276 content = [], 4277 handlebarsStarted = 0; 4278 4279 while (this.input.charAt(this.pos) !== '<' || handlebarsStarted === 2) { 4280 if (this.pos >= this.input.length) { 4281 return content.length ? content.join('') : ['', 'TK_EOF']; 4282 } 4283 4284 if (handlebarsStarted < 2 && this.traverse_whitespace()) { 4285 this.space_or_wrap(content); 4286 continue; 4287 } 4288 4289 input_char = this.input.charAt(this.pos); 4290 4291 if (indent_handlebars) { 4292 if (input_char === '{') { 4293 handlebarsStarted += 1; 4294 } else if (handlebarsStarted < 2) { 4295 handlebarsStarted = 0; 4296 } 4297 4298 if (input_char === '}' && handlebarsStarted > 0) { 4299 if (handlebarsStarted-- === 0) { 4300 break; 4301 } 4302 } 4303 // Handlebars parsing is complicated. 4304 // {{#foo}} and {{/foo}} are formatted tags. 4305 // {{something}} should get treated as content, except: 4306 // {{else}} specifically behaves like {{#if}} and {{/if}} 4307 var peek3 = this.input.substr(this.pos, 3); 4308 if (peek3 === '{{#' || peek3 === '{{/') { 4309 // These are tags and not content. 4310 break; 4311 } else if (peek3 === '{{!') { 4312 return [this.get_tag(), 'TK_TAG_HANDLEBARS_COMMENT']; 4313 } else if (this.input.substr(this.pos, 2) === '{{') { 4314 if (this.get_tag(true) === '{{else}}') { 4315 break; 4316 } 4317 } 4318 } 4319 4320 this.pos++; 4321 this.line_char_count++; 4322 content.push(input_char); //letter at-a-time (or string) inserted to an array 4323 } 4324 return content.length ? content.join('') : ''; 4325 }; 4326 4327 this.get_contents_to = function(name) { //get the full content of a script or style to pass to js_beautify 4328 if (this.pos === this.input.length) { 4329 return ['', 'TK_EOF']; 4330 } 4331 var content = ''; 4332 var reg_match = new RegExp('</' + name + '\\s*>', 'igm'); 4333 reg_match.lastIndex = this.pos; 4334 var reg_array = reg_match.exec(this.input); 4335 var end_script = reg_array ? reg_array.index : this.input.length; //absolute end of script 4336 if (this.pos < end_script) { //get everything in between the script tags 4337 content = this.input.substring(this.pos, end_script); 4338 this.pos = end_script; 4339 } 4340 return content; 4341 }; 4342 4343 this.record_tag = function(tag) { //function to record a tag and its parent in this.tags Object 4344 if (this.tags[tag + 'count']) { //check for the existence of this tag type 4345 this.tags[tag + 'count']++; 4346 this.tags[tag + this.tags[tag + 'count']] = this.indent_level; //and record the present indent level 4347 } else { //otherwise initialize this tag type 4348 this.tags[tag + 'count'] = 1; 4349 this.tags[tag + this.tags[tag + 'count']] = this.indent_level; //and record the present indent level 4350 } 4351 this.tags[tag + this.tags[tag + 'count'] + 'parent'] = this.tags.parent; //set the parent (i.e. in the case of a div this.tags.div1parent) 4352 this.tags.parent = tag + this.tags[tag + 'count']; //and make this the current parent (i.e. in the case of a div 'div1') 4353 }; 4354 4355 this.retrieve_tag = function(tag) { //function to retrieve the opening tag to the corresponding closer 4356 if (this.tags[tag + 'count']) { //if the openener is not in the Object we ignore it 4357 var temp_parent = this.tags.parent; //check to see if it's a closable tag. 4358 while (temp_parent) { //till we reach '' (the initial value); 4359 if (tag + this.tags[tag + 'count'] === temp_parent) { //if this is it use it 4360 break; 4361 } 4362 temp_parent = this.tags[temp_parent + 'parent']; //otherwise keep on climbing up the DOM Tree 4363 } 4364 if (temp_parent) { //if we caught something 4365 this.indent_level = this.tags[tag + this.tags[tag + 'count']]; //set the indent_level accordingly 4366 this.tags.parent = this.tags[temp_parent + 'parent']; //and set the current parent 4367 } 4368 delete this.tags[tag + this.tags[tag + 'count'] + 'parent']; //delete the closed tags parent reference... 4369 delete this.tags[tag + this.tags[tag + 'count']]; //...and the tag itself 4370 if (this.tags[tag + 'count'] === 1) { 4371 delete this.tags[tag + 'count']; 4372 } else { 4373 this.tags[tag + 'count']--; 4374 } 4375 } 4376 }; 4377 4378 this.indent_to_tag = function(tag) { 4379 // Match the indentation level to the last use of this tag, but don't remove it. 4380 if (!this.tags[tag + 'count']) { 4381 return; 4382 } 4383 var temp_parent = this.tags.parent; 4384 while (temp_parent) { 4385 if (tag + this.tags[tag + 'count'] === temp_parent) { 4386 break; 4387 } 4388 temp_parent = this.tags[temp_parent + 'parent']; 4389 } 4390 if (temp_parent) { 4391 this.indent_level = this.tags[tag + this.tags[tag + 'count']]; 4392 } 4393 }; 4394 4395 this.get_tag = function(peek) { //function to get a full tag and parse its type 4396 var input_char = '', 4397 content = [], 4398 comment = '', 4399 space = false, 4400 first_attr = true, 4401 has_wrapped_attrs = false, 4402 tag_start, tag_end, 4403 tag_start_char, 4404 orig_pos = this.pos, 4405 orig_line_char_count = this.line_char_count, 4406 is_tag_closed = false, 4407 tail; 4408 4409 peek = peek !== undefined ? peek : false; 4410 4411 do { 4412 if (this.pos >= this.input.length) { 4413 if (peek) { 4414 this.pos = orig_pos; 4415 this.line_char_count = orig_line_char_count; 4416 } 4417 return content.length ? content.join('') : ['', 'TK_EOF']; 4418 } 4419 4420 input_char = this.input.charAt(this.pos); 4421 this.pos++; 4422 4423 if (this.Utils.in_array(input_char, this.Utils.whitespace)) { //don't want to insert unnecessary space 4424 space = true; 4425 continue; 4426 } 4427 4428 if (input_char === "'" || input_char === '"') { 4429 input_char += this.get_unformatted(input_char); 4430 space = true; 4431 } 4432 4433 if (input_char === '=') { //no space before = 4434 space = false; 4435 } 4436 tail = this.input.substr(this.pos - 1); 4437 if (is_wrap_attributes_force_expand_multiline && has_wrapped_attrs && !is_tag_closed && (input_char === '>' || input_char === '/')) { 4438 if (tail.match(/^\/?\s*>/)) { 4439 space = false; 4440 is_tag_closed = true; 4441 this.print_newline(false, content); 4442 this.print_indentation(content); 4443 } 4444 } 4445 if (content.length && content[content.length - 1] !== '=' && input_char !== '>' && space) { 4446 //no space after = or before > 4447 var wrapped = this.space_or_wrap(content); 4448 var indentAttrs = wrapped && input_char !== '/' && !is_wrap_attributes_force; 4449 space = false; 4450 4451 if (is_wrap_attributes_force && input_char !== '/') { 4452 var force_first_attr_wrap = false; 4453 if (is_wrap_attributes_force_expand_multiline && first_attr) { 4454 var is_only_attribute = tail.match(/^\S*(="([^"]|\\")*")?\s*\/?\s*>/) !== null; 4455 force_first_attr_wrap = !is_only_attribute; 4456 } 4457 if (!first_attr || force_first_attr_wrap) { 4458 this.print_newline(false, content); 4459 this.print_indentation(content); 4460 indentAttrs = true; 4461 } 4462 } 4463 if (indentAttrs) { 4464 has_wrapped_attrs = true; 4465 4466 //indent attributes an auto, forced, or forced-align line-wrap 4467 var alignment_size = wrap_attributes_indent_size; 4468 if (is_wrap_attributes_force_aligned) { 4469 alignment_size = content.indexOf(' ') + 1; 4470 } 4471 4472 for (var count = 0; count < alignment_size; count++) { 4473 // only ever further indent with spaces since we're trying to align characters 4474 content.push(' '); 4475 } 4476 } 4477 if (first_attr) { 4478 for (var i = 0; i < content.length; i++) { 4479 if (content[i] === ' ') { 4480 first_attr = false; 4481 break; 4482 } 4483 } 4484 } 4485 } 4486 4487 if (indent_handlebars && tag_start_char === '<') { 4488 // When inside an angle-bracket tag, put spaces around 4489 // handlebars not inside of strings. 4490 if ((input_char + this.input.charAt(this.pos)) === '{{') { 4491 input_char += this.get_unformatted('}}'); 4492 if (content.length && content[content.length - 1] !== ' ' && content[content.length - 1] !== '<') { 4493 input_char = ' ' + input_char; 4494 } 4495 space = true; 4496 } 4497 } 4498 4499 if (input_char === '<' && !tag_start_char) { 4500 tag_start = this.pos - 1; 4501 tag_start_char = '<'; 4502 } 4503 4504 if (indent_handlebars && !tag_start_char) { 4505 if (content.length >= 2 && content[content.length - 1] === '{' && content[content.length - 2] === '{') { 4506 if (input_char === '#' || input_char === '/' || input_char === '!') { 4507 tag_start = this.pos - 3; 4508 } else { 4509 tag_start = this.pos - 2; 4510 } 4511 tag_start_char = '{'; 4512 } 4513 } 4514 4515 this.line_char_count++; 4516 content.push(input_char); //inserts character at-a-time (or string) 4517 4518 if (content[1] && (content[1] === '!' || content[1] === '?' || content[1] === '%')) { //if we're in a comment, do something special 4519 // We treat all comments as literals, even more than preformatted tags 4520 // we just look for the appropriate close tag 4521 content = [this.get_comment(tag_start)]; 4522 break; 4523 } 4524 4525 if (indent_handlebars && content[1] && content[1] === '{' && content[2] && content[2] === '!') { //if we're in a comment, do something special 4526 // We treat all comments as literals, even more than preformatted tags 4527 // we just look for the appropriate close tag 4528 content = [this.get_comment(tag_start)]; 4529 break; 4530 } 4531 4532 if (indent_handlebars && tag_start_char === '{' && content.length > 2 && content[content.length - 2] === '}' && content[content.length - 1] === '}') { 4533 break; 4534 } 4535 } while (input_char !== '>'); 4536 4537 var tag_complete = content.join(''); 4538 var tag_index; 4539 var tag_offset; 4540 4541 // must check for space first otherwise the tag could have the first attribute included, and 4542 // then not un-indent correctly 4543 if (tag_complete.indexOf(' ') !== -1) { //if there's whitespace, thats where the tag name ends 4544 tag_index = tag_complete.indexOf(' '); 4545 } else if (tag_complete.indexOf('\n') !== -1) { //if there's a line break, thats where the tag name ends 4546 tag_index = tag_complete.indexOf('\n'); 4547 } else if (tag_complete.charAt(0) === '{') { 4548 tag_index = tag_complete.indexOf('}'); 4549 } else { //otherwise go with the tag ending 4550 tag_index = tag_complete.indexOf('>'); 4551 } 4552 if (tag_complete.charAt(0) === '<' || !indent_handlebars) { 4553 tag_offset = 1; 4554 } else { 4555 tag_offset = tag_complete.charAt(2) === '#' ? 3 : 2; 4556 } 4557 var tag_check = tag_complete.substring(tag_offset, tag_index).toLowerCase(); 4558 if (tag_complete.charAt(tag_complete.length - 2) === '/' || 4559 this.Utils.in_array(tag_check, this.Utils.single_token)) { //if this tag name is a single tag type (either in the list or has a closing /) 4560 if (!peek) { 4561 this.tag_type = 'SINGLE'; 4562 } 4563 } else if (indent_handlebars && tag_complete.charAt(0) === '{' && tag_check === 'else') { 4564 if (!peek) { 4565 this.indent_to_tag('if'); 4566 this.tag_type = 'HANDLEBARS_ELSE'; 4567 this.indent_content = true; 4568 this.traverse_whitespace(); 4569 } 4570 } else if (this.is_unformatted(tag_check, unformatted) || 4571 this.is_unformatted(tag_check, content_unformatted)) { 4572 // do not reformat the "unformatted" or "content_unformatted" tags 4573 comment = this.get_unformatted('</' + tag_check + '>', tag_complete); //...delegate to get_unformatted function 4574 content.push(comment); 4575 tag_end = this.pos - 1; 4576 this.tag_type = 'SINGLE'; 4577 } else if (tag_check === 'script' && 4578 (tag_complete.search('type') === -1 || 4579 (tag_complete.search('type') > -1 && 4580 tag_complete.search(/\b(text|application|dojo)\/(x-)?(javascript|ecmascript|jscript|livescript|(ld\+)?json|method|aspect)/) > -1))) { 4581 if (!peek) { 4582 this.record_tag(tag_check); 4583 this.tag_type = 'SCRIPT'; 4584 } 4585 } else if (tag_check === 'style' && 4586 (tag_complete.search('type') === -1 || 4587 (tag_complete.search('type') > -1 && tag_complete.search('text/css') > -1))) { 4588 if (!peek) { 4589 this.record_tag(tag_check); 4590 this.tag_type = 'STYLE'; 4591 } 4592 } else if (tag_check.charAt(0) === '!') { //peek for <! comment 4593 // for comments content is already correct. 4594 if (!peek) { 4595 this.tag_type = 'SINGLE'; 4596 this.traverse_whitespace(); 4597 } 4598 } else if (!peek) { 4599 if (tag_check.charAt(0) === '/') { //this tag is a double tag so check for tag-ending 4600 this.retrieve_tag(tag_check.substring(1)); //remove it and all ancestors 4601 this.tag_type = 'END'; 4602 } else { //otherwise it's a start-tag 4603 this.record_tag(tag_check); //push it on the tag stack 4604 if (tag_check.toLowerCase() !== 'html') { 4605 this.indent_content = true; 4606 } 4607 this.tag_type = 'START'; 4608 } 4609 4610 // Allow preserving of newlines after a start or end tag 4611 if (this.traverse_whitespace()) { 4612 this.space_or_wrap(content); 4613 } 4614 4615 if (this.Utils.in_array(tag_check, this.Utils.extra_liners)) { //check if this double needs an extra line 4616 this.print_newline(false, this.output); 4617 if (this.output.length && this.output[this.output.length - 2] !== '\n') { 4618 this.print_newline(true, this.output); 4619 } 4620 } 4621 } 4622 4623 if (peek) { 4624 this.pos = orig_pos; 4625 this.line_char_count = orig_line_char_count; 4626 } 4627 4628 return content.join(''); //returns fully formatted tag 4629 }; 4630 4631 this.get_comment = function(start_pos) { //function to return comment content in its entirety 4632 // this is will have very poor perf, but will work for now. 4633 var comment = '', 4634 delimiter = '>', 4635 matched = false; 4636 4637 this.pos = start_pos; 4638 var input_char = this.input.charAt(this.pos); 4639 this.pos++; 4640 4641 while (this.pos <= this.input.length) { 4642 comment += input_char; 4643 4644 // only need to check for the delimiter if the last chars match 4645 if (comment.charAt(comment.length - 1) === delimiter.charAt(delimiter.length - 1) && 4646 comment.indexOf(delimiter) !== -1) { 4647 break; 4648 } 4649 4650 // only need to search for custom delimiter for the first few characters 4651 if (!matched && comment.length < 10) { 4652 if (comment.indexOf('<![if') === 0) { //peek for <![if conditional comment 4653 delimiter = '<![endif]>'; 4654 matched = true; 4655 } else if (comment.indexOf('<![cdata[') === 0) { //if it's a <[cdata[ comment... 4656 delimiter = ']]>'; 4657 matched = true; 4658 } else if (comment.indexOf('<![') === 0) { // some other ![ comment? ... 4659 delimiter = ']>'; 4660 matched = true; 4661 } else if (comment.indexOf('<!--') === 0) { // <!-- comment ... 4662 delimiter = '-->'; 4663 matched = true; 4664 } else if (comment.indexOf('{{!--') === 0) { // {{!-- handlebars comment 4665 delimiter = '--}}'; 4666 matched = true; 4667 } else if (comment.indexOf('{{!') === 0) { // {{! handlebars comment 4668 if (comment.length === 5 && comment.indexOf('{{!--') === -1) { 4669 delimiter = '}}'; 4670 matched = true; 4671 } 4672 } else if (comment.indexOf('<?') === 0) { // {{! handlebars comment 4673 delimiter = '?>'; 4674 matched = true; 4675 } else if (comment.indexOf('<%') === 0) { // {{! handlebars comment 4676 delimiter = '%>'; 4677 matched = true; 4678 } 4679 } 4680 4681 input_char = this.input.charAt(this.pos); 4682 this.pos++; 4683 } 4684 4685 return comment; 4686 }; 4687 4688 function tokenMatcher(delimiter) { 4689 var token = ''; 4690 4691 var add = function(str) { 4692 var newToken = token + str.toLowerCase(); 4693 token = newToken.length <= delimiter.length ? newToken : newToken.substr(newToken.length - delimiter.length, delimiter.length); 4694 }; 4695 4696 var doesNotMatch = function() { 4697 return token.indexOf(delimiter) === -1; 4698 }; 4699 4700 return { 4701 add: add, 4702 doesNotMatch: doesNotMatch 4703 }; 4704 } 4705 4706 this.get_unformatted = function(delimiter, orig_tag) { //function to return unformatted content in its entirety 4707 if (orig_tag && orig_tag.toLowerCase().indexOf(delimiter) !== -1) { 4708 return ''; 4709 } 4710 var input_char = ''; 4711 var content = ''; 4712 var space = true; 4713 4714 var delimiterMatcher = tokenMatcher(delimiter); 4715 4716 do { 4717 4718 if (this.pos >= this.input.length) { 4719 return content; 4720 } 4721 4722 input_char = this.input.charAt(this.pos); 4723 this.pos++; 4724 4725 if (this.Utils.in_array(input_char, this.Utils.whitespace)) { 4726 if (!space) { 4727 this.line_char_count--; 4728 continue; 4729 } 4730 if (input_char === '\n' || input_char === '\r') { 4731 content += '\n'; 4732 /* Don't change tab indention for unformatted blocks. If using code for html editing, this will greatly affect <pre> tags if they are specified in the 'unformatted array' 4733 for (var i=0; i<this.indent_level; i++) { 4734 content += this.indent_string; 4735 } 4736 space = false; //...and make sure other indentation is erased 4737 */ 4738 this.line_char_count = 0; 4739 continue; 4740 } 4741 } 4742 content += input_char; 4743 delimiterMatcher.add(input_char); 4744 this.line_char_count++; 4745 space = true; 4746 4747 if (indent_handlebars && input_char === '{' && content.length && content.charAt(content.length - 2) === '{') { 4748 // Handlebars expressions in strings should also be unformatted. 4749 content += this.get_unformatted('}}'); 4750 // Don't consider when stopping for delimiters. 4751 } 4752 } while (delimiterMatcher.doesNotMatch()); 4753 4754 return content; 4755 }; 4756 4757 this.get_token = function() { //initial handler for token-retrieval 4758 var token; 4759 4760 if (this.last_token === 'TK_TAG_SCRIPT' || this.last_token === 'TK_TAG_STYLE') { //check if we need to format javascript 4761 var type = this.last_token.substr(7); 4762 token = this.get_contents_to(type); 4763 if (typeof token !== 'string') { 4764 return token; 4765 } 4766 return [token, 'TK_' + type]; 4767 } 4768 if (this.current_mode === 'CONTENT') { 4769 token = this.get_content(); 4770 if (typeof token !== 'string') { 4771 return token; 4772 } else { 4773 return [token, 'TK_CONTENT']; 4774 } 4775 } 4776 4777 if (this.current_mode === 'TAG') { 4778 token = this.get_tag(); 4779 if (typeof token !== 'string') { 4780 return token; 4781 } else { 4782 var tag_name_type = 'TK_TAG_' + this.tag_type; 4783 return [token, tag_name_type]; 4784 } 4785 } 4786 }; 4787 4788 this.get_full_indent = function(level) { 4789 level = this.indent_level + level || 0; 4790 if (level < 1) { 4791 return ''; 4792 } 4793 4794 return Array(level + 1).join(this.indent_string); 4795 }; 4796 4797 this.is_unformatted = function(tag_check, unformatted) { 4798 //is this an HTML5 block-level link? 4799 if (!this.Utils.in_array(tag_check, unformatted)) { 4800 return false; 4801 } 4802 4803 if (tag_check.toLowerCase() !== 'a' || !this.Utils.in_array('a', unformatted)) { 4804 return true; 4805 } 4806 4807 //at this point we have an tag; is its first child something we want to remain 4808 //unformatted? 4809 var next_tag = this.get_tag(true /* peek. */ ); 4810 4811 // test next_tag to see if it is just html tag (no external content) 4812 var tag = (next_tag || "").match(/^\s*<\s*\/?([a-z]*)\s*[^>]*>\s*$/); 4813 4814 // if next_tag comes back but is not an isolated tag, then 4815 // let's treat the 'a' tag as having content 4816 // and respect the unformatted option 4817 if (!tag || this.Utils.in_array(tag[1], unformatted)) { 4818 return true; 4819 } else { 4820 return false; 4821 } 4822 }; 4823 4824 this.printer = function(js_source, indent_character, indent_size, wrap_line_length, brace_style) { //handles input/output and some other printing functions 4825 4826 this.input = js_source || ''; //gets the input for the Parser 4827 4828 // HACK: newline parsing inconsistent. This brute force normalizes the input. 4829 this.input = this.input.replace(/\r\n|[\r\u2028\u2029]/g, '\n'); 4830 4831 this.output = []; 4832 this.indent_character = indent_character; 4833 this.indent_string = ''; 4834 this.indent_size = indent_size; 4835 this.brace_style = brace_style; 4836 this.indent_level = 0; 4837 this.wrap_line_length = wrap_line_length; 4838 this.line_char_count = 0; //count to see if wrap_line_length was exceeded 4839 4840 for (var i = 0; i < this.indent_size; i++) { 4841 this.indent_string += this.indent_character; 4842 } 4843 4844 this.print_newline = function(force, arr) { 4845 this.line_char_count = 0; 4846 if (!arr || !arr.length) { 4847 return; 4848 } 4849 if (force || (arr[arr.length - 1] !== '\n')) { //we might want the extra line 4850 if ((arr[arr.length - 1] !== '\n')) { 4851 arr[arr.length - 1] = rtrim(arr[arr.length - 1]); 4852 } 4853 arr.push('\n'); 4854 } 4855 }; 4856 4857 this.print_indentation = function(arr) { 4858 for (var i = 0; i < this.indent_level; i++) { 4859 arr.push(this.indent_string); 4860 this.line_char_count += this.indent_string.length; 4861 } 4862 }; 4863 4864 this.print_token = function(text) { 4865 // Avoid printing initial whitespace. 4866 if (this.is_whitespace(text) && !this.output.length) { 4867 return; 4868 } 4869 if (text || text !== '') { 4870 if (this.output.length && this.output[this.output.length - 1] === '\n') { 4871 this.print_indentation(this.output); 4872 text = ltrim(text); 4873 } 4874 } 4875 this.print_token_raw(text); 4876 }; 4877 4878 this.print_token_raw = function(text) { 4879 // If we are going to print newlines, truncate trailing 4880 // whitespace, as the newlines will represent the space. 4881 if (this.newlines > 0) { 4882 text = rtrim(text); 4883 } 4884 4885 if (text && text !== '') { 4886 if (text.length > 1 && text.charAt(text.length - 1) === '\n') { 4887 // unformatted tags can grab newlines as their last character 4888 this.output.push(text.slice(0, -1)); 4889 this.print_newline(false, this.output); 4890 } else { 4891 this.output.push(text); 4892 } 4893 } 4894 4895 for (var n = 0; n < this.newlines; n++) { 4896 this.print_newline(n > 0, this.output); 4897 } 4898 this.newlines = 0; 4899 }; 4900 4901 this.indent = function() { 4902 this.indent_level++; 4903 }; 4904 4905 this.unindent = function() { 4906 if (this.indent_level > 0) { 4907 this.indent_level--; 4908 } 4909 }; 4910 }; 4911 return this; 4912 } 4913 4914 /*_____________________--------------------_____________________*/ 4915 4916 this.beautify = function() { 4917 multi_parser = new Parser(); //wrapping functions Parser 4918 multi_parser.printer(html_source, indent_character, indent_size, wrap_line_length, brace_style); //initialize starting values 4919 while (true) { 4920 var t = multi_parser.get_token(); 4921 multi_parser.token_text = t[0]; 4922 multi_parser.token_type = t[1]; 4923 4924 if (multi_parser.token_type === 'TK_EOF') { 4925 break; 4926 } 4927 4928 switch (multi_parser.token_type) { 4929 case 'TK_TAG_START': 4930 multi_parser.print_newline(false, multi_parser.output); 4931 multi_parser.print_token(multi_parser.token_text); 4932 if (multi_parser.indent_content) { 4933 if ((multi_parser.indent_body_inner_html || !multi_parser.token_text.match(/<body(?:.*)>/)) && 4934 (multi_parser.indent_head_inner_html || !multi_parser.token_text.match(/<head(?:.*)>/))) { 4935 4936 multi_parser.indent(); 4937 } 4938 4939 multi_parser.indent_content = false; 4940 } 4941 multi_parser.current_mode = 'CONTENT'; 4942 break; 4943 case 'TK_TAG_STYLE': 4944 case 'TK_TAG_SCRIPT': 4945 multi_parser.print_newline(false, multi_parser.output); 4946 multi_parser.print_token(multi_parser.token_text); 4947 multi_parser.current_mode = 'CONTENT'; 4948 break; 4949 case 'TK_TAG_END': 4950 //Print new line only if the tag has no content and has child 4951 if (multi_parser.last_token === 'TK_CONTENT' && multi_parser.last_text === '') { 4952 var tag_name = (multi_parser.token_text.match(/\w+/) || [])[0]; 4953 var tag_extracted_from_last_output = null; 4954 if (multi_parser.output.length) { 4955 tag_extracted_from_last_output = multi_parser.output[multi_parser.output.length - 1].match(/(?:<|{{#)\s*(\w+)/); 4956 } 4957 if (tag_extracted_from_last_output === null || 4958 (tag_extracted_from_last_output[1] !== tag_name && !multi_parser.Utils.in_array(tag_extracted_from_last_output[1], unformatted))) { 4959 multi_parser.print_newline(false, multi_parser.output); 4960 } 4961 } 4962 multi_parser.print_token(multi_parser.token_text); 4963 multi_parser.current_mode = 'CONTENT'; 4964 break; 4965 case 'TK_TAG_SINGLE': 4966 // Don't add a newline before elements that should remain unformatted. 4967 var tag_check = multi_parser.token_text.match(/^\s*<([a-z-]+)/i); 4968 if (!tag_check || !multi_parser.Utils.in_array(tag_check[1], unformatted)) { 4969 multi_parser.print_newline(false, multi_parser.output); 4970 } 4971 multi_parser.print_token(multi_parser.token_text); 4972 multi_parser.current_mode = 'CONTENT'; 4973 break; 4974 case 'TK_TAG_HANDLEBARS_ELSE': 4975 // Don't add a newline if opening {{#if}} tag is on the current line 4976 var foundIfOnCurrentLine = false; 4977 for (var lastCheckedOutput = multi_parser.output.length - 1; lastCheckedOutput >= 0; lastCheckedOutput--) { 4978 if (multi_parser.output[lastCheckedOutput] === '\n') { 4979 break; 4980 } else { 4981 if (multi_parser.output[lastCheckedOutput].match(/{{#if/)) { 4982 foundIfOnCurrentLine = true; 4983 break; 4984 } 4985 } 4986 } 4987 if (!foundIfOnCurrentLine) { 4988 multi_parser.print_newline(false, multi_parser.output); 4989 } 4990 multi_parser.print_token(multi_parser.token_text); 4991 if (multi_parser.indent_content) { 4992 multi_parser.indent(); 4993 multi_parser.indent_content = false; 4994 } 4995 multi_parser.current_mode = 'CONTENT'; 4996 break; 4997 case 'TK_TAG_HANDLEBARS_COMMENT': 4998 multi_parser.print_token(multi_parser.token_text); 4999 multi_parser.current_mode = 'TAG'; 5000 break; 5001 case 'TK_CONTENT': 5002 multi_parser.print_token(multi_parser.token_text); 5003 multi_parser.current_mode = 'TAG'; 5004 break; 5005 case 'TK_STYLE': 5006 case 'TK_SCRIPT': 5007 if (multi_parser.token_text !== '') { 5008 multi_parser.print_newline(false, multi_parser.output); 5009 var text = multi_parser.token_text, 5010 _beautifier, 5011 script_indent_level = 1; 5012 if (multi_parser.token_type === 'TK_SCRIPT') { 5013 _beautifier = typeof js_beautify === 'function' && js_beautify; 5014 } else if (multi_parser.token_type === 'TK_STYLE') { 5015 _beautifier = typeof css_beautify === 'function' && css_beautify; 5016 } 5017 5018 if (options.indent_scripts === "keep") { 5019 script_indent_level = 0; 5020 } else if (options.indent_scripts === "separate") { 5021 script_indent_level = -multi_parser.indent_level; 5022 } 5023 5024 var indentation = multi_parser.get_full_indent(script_indent_level); 5025 if (_beautifier) { 5026 5027 // call the Beautifier if avaliable 5028 var Child_options = function() { 5029 this.eol = '\n'; 5030 }; 5031 Child_options.prototype = options; 5032 var child_options = new Child_options(); 5033 text = _beautifier(text.replace(/^\s*/, indentation), child_options); 5034 } else { 5035 // simply indent the string otherwise 5036 var white = text.match(/^\s*/)[0]; 5037 var _level = white.match(/[^\n\r]*$/)[0].split(multi_parser.indent_string).length - 1; 5038 var reindent = multi_parser.get_full_indent(script_indent_level - _level); 5039 text = text.replace(/^\s*/, indentation) 5040 .replace(/\r\n|\r|\n/g, '\n' + reindent) 5041 .replace(/\s+$/, ''); 5042 } 5043 if (text) { 5044 multi_parser.print_token_raw(text); 5045 multi_parser.print_newline(true, multi_parser.output); 5046 } 5047 } 5048 multi_parser.current_mode = 'TAG'; 5049 break; 5050 default: 5051 // We should not be getting here but we don't want to drop input on the floor 5052 // Just output the text and move on 5053 if (multi_parser.token_text !== '') { 5054 multi_parser.print_token(multi_parser.token_text); 5055 } 5056 break; 5057 } 5058 multi_parser.last_token = multi_parser.token_type; 5059 multi_parser.last_text = multi_parser.token_text; 5060 } 5061 var sweet_code = multi_parser.output.join('').replace(/[\r\n\t ]+$/, ''); 5062 5063 // establish end_with_newline 5064 if (end_with_newline) { 5065 sweet_code += '\n'; 5066 } 5067 5068 if (eol !== '\n') { 5069 sweet_code = sweet_code.replace(/[\n]/g, eol); 5070 } 5071 5072 return sweet_code; 5073 }; 5074 } 5075 5076 module.exports.Beautifier = Beautifier; 5077 5078 5079 /***/ }), 5080 /* 1 */ 5081 /***/ (function(module, exports) { 5082 5083 /* jshint curly: false */ 5084 // This section of code is taken from acorn. 5085 // 5086 // Acorn was written by Marijn Haverbeke and released under an MIT 5087 // license. The Unicode regexps (for identifiers and whitespace) were 5088 // taken from [Esprima](http://esprima.org) by Ariya Hidayat. 5089 // 5090 // Git repositories for Acorn are available at 5091 // 5092 // http://marijnhaverbeke.nl/git/acorn 5093 // https://github.com/marijnh/acorn.git 5094 5095 // ## Character categories 5096 5097 // Big ugly regular expressions that match characters in the 5098 // whitespace, identifier, and identifier-start categories. These 5099 // are only applied when a character is found to actually have a 5100 // code point above 128. 5101 5102 var nonASCIIwhitespace = /[\u1680\u180e\u2000-\u200a\u202f\u205f\u3000\ufeff]/; // jshint ignore:line 5103 var nonASCIIidentifierStartChars = "\xaa\xb5\xba\xc0-\xd6\xd8-\xf6\xf8-\u02c1\u02c6-\u02d1\u02e0-\u02e4\u02ec\u02ee\u0370-\u0374\u0376\u0377\u037a-\u037d\u0386\u0388-\u038a\u038c\u038e-\u03a1\u03a3-\u03f5\u03f7-\u0481\u048a-\u0527\u0531-\u0556\u0559\u0561-\u0587\u05d0-\u05ea\u05f0-\u05f2\u0620-\u064a\u066e\u066f\u0671-\u06d3\u06d5\u06e5\u06e6\u06ee\u06ef\u06fa-\u06fc\u06ff\u0710\u0712-\u072f\u074d-\u07a5\u07b1\u07ca-\u07ea\u07f4\u07f5\u07fa\u0800-\u0815\u081a\u0824\u0828\u0840-\u0858\u08a0\u08a2-\u08ac\u0904-\u0939\u093d\u0950\u0958-\u0961\u0971-\u0977\u0979-\u097f\u0985-\u098c\u098f\u0990\u0993-\u09a8\u09aa-\u09b0\u09b2\u09b6-\u09b9\u09bd\u09ce\u09dc\u09dd\u09df-\u09e1\u09f0\u09f1\u0a05-\u0a0a\u0a0f\u0a10\u0a13-\u0a28\u0a2a-\u0a30\u0a32\u0a33\u0a35\u0a36\u0a38\u0a39\u0a59-\u0a5c\u0a5e\u0a72-\u0a74\u0a85-\u0a8d\u0a8f-\u0a91\u0a93-\u0aa8\u0aaa-\u0ab0\u0ab2\u0ab3\u0ab5-\u0ab9\u0abd\u0ad0\u0ae0\u0ae1\u0b05-\u0b0c\u0b0f\u0b10\u0b13-\u0b28\u0b2a-\u0b30\u0b32\u0b33\u0b35-\u0b39\u0b3d\u0b5c\u0b5d\u0b5f-\u0b61\u0b71\u0b83\u0b85-\u0b8a\u0b8e-\u0b90\u0b92-\u0b95\u0b99\u0b9a\u0b9c\u0b9e\u0b9f\u0ba3\u0ba4\u0ba8-\u0baa\u0bae-\u0bb9\u0bd0\u0c05-\u0c0c\u0c0e-\u0c10\u0c12-\u0c28\u0c2a-\u0c33\u0c35-\u0c39\u0c3d\u0c58\u0c59\u0c60\u0c61\u0c85-\u0c8c\u0c8e-\u0c90\u0c92-\u0ca8\u0caa-\u0cb3\u0cb5-\u0cb9\u0cbd\u0cde\u0ce0\u0ce1\u0cf1\u0cf2\u0d05-\u0d0c\u0d0e-\u0d10\u0d12-\u0d3a\u0d3d\u0d4e\u0d60\u0d61\u0d7a-\u0d7f\u0d85-\u0d96\u0d9a-\u0db1\u0db3-\u0dbb\u0dbd\u0dc0-\u0dc6\u0e01-\u0e30\u0e32\u0e33\u0e40-\u0e46\u0e81\u0e82\u0e84\u0e87\u0e88\u0e8a\u0e8d\u0e94-\u0e97\u0e99-\u0e9f\u0ea1-\u0ea3\u0ea5\u0ea7\u0eaa\u0eab\u0ead-\u0eb0\u0eb2\u0eb3\u0ebd\u0ec0-\u0ec4\u0ec6\u0edc-\u0edf\u0f00\u0f40-\u0f47\u0f49-\u0f6c\u0f88-\u0f8c\u1000-\u102a\u103f\u1050-\u1055\u105a-\u105d\u1061\u1065\u1066\u106e-\u1070\u1075-\u1081\u108e\u10a0-\u10c5\u10c7\u10cd\u10d0-\u10fa\u10fc-\u1248\u124a-\u124d\u1250-\u1256\u1258\u125a-\u125d\u1260-\u1288\u128a-\u128d\u1290-\u12b0\u12b2-\u12b5\u12b8-\u12be\u12c0\u12c2-\u12c5\u12c8-\u12d6\u12d8-\u1310\u1312-\u1315\u1318-\u135a\u1380-\u138f\u13a0-\u13f4\u1401-\u166c\u166f-\u167f\u1681-\u169a\u16a0-\u16ea\u16ee-\u16f0\u1700-\u170c\u170e-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176c\u176e-\u1770\u1780-\u17b3\u17d7\u17dc\u1820-\u1877\u1880-\u18a8\u18aa\u18b0-\u18f5\u1900-\u191c\u1950-\u196d\u1970-\u1974\u1980-\u19ab\u19c1-\u19c7\u1a00-\u1a16\u1a20-\u1a54\u1aa7\u1b05-\u1b33\u1b45-\u1b4b\u1b83-\u1ba0\u1bae\u1baf\u1bba-\u1be5\u1c00-\u1c23\u1c4d-\u1c4f\u1c5a-\u1c7d\u1ce9-\u1cec\u1cee-\u1cf1\u1cf5\u1cf6\u1d00-\u1dbf\u1e00-\u1f15\u1f18-\u1f1d\u1f20-\u1f45\u1f48-\u1f4d\u1f50-\u1f57\u1f59\u1f5b\u1f5d\u1f5f-\u1f7d\u1f80-\u1fb4\u1fb6-\u1fbc\u1fbe\u1fc2-\u1fc4\u1fc6-\u1fcc\u1fd0-\u1fd3\u1fd6-\u1fdb\u1fe0-\u1fec\u1ff2-\u1ff4\u1ff6-\u1ffc\u2071\u207f\u2090-\u209c\u2102\u2107\u210a-\u2113\u2115\u2119-\u211d\u2124\u2126\u2128\u212a-\u212d\u212f-\u2139\u213c-\u213f\u2145-\u2149\u214e\u2160-\u2188\u2c00-\u2c2e\u2c30-\u2c5e\u2c60-\u2ce4\u2ceb-\u2cee\u2cf2\u2cf3\u2d00-\u2d25\u2d27\u2d2d\u2d30-\u2d67\u2d6f\u2d80-\u2d96\u2da0-\u2da6\u2da8-\u2dae\u2db0-\u2db6\u2db8-\u2dbe\u2dc0-\u2dc6\u2dc8-\u2dce\u2dd0-\u2dd6\u2dd8-\u2dde\u2e2f\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303c\u3041-\u3096\u309d-\u309f\u30a1-\u30fa\u30fc-\u30ff\u3105-\u312d\u3131-\u318e\u31a0-\u31ba\u31f0-\u31ff\u3400-\u4db5\u4e00-\u9fcc\ua000-\ua48c\ua4d0-\ua4fd\ua500-\ua60c\ua610-\ua61f\ua62a\ua62b\ua640-\ua66e\ua67f-\ua697\ua6a0-\ua6ef\ua717-\ua71f\ua722-\ua788\ua78b-\ua78e\ua790-\ua793\ua7a0-\ua7aa\ua7f8-\ua801\ua803-\ua805\ua807-\ua80a\ua80c-\ua822\ua840-\ua873\ua882-\ua8b3\ua8f2-\ua8f7\ua8fb\ua90a-\ua925\ua930-\ua946\ua960-\ua97c\ua984-\ua9b2\ua9cf\uaa00-\uaa28\uaa40-\uaa42\uaa44-\uaa4b\uaa60-\uaa76\uaa7a\uaa80-\uaaaf\uaab1\uaab5\uaab6\uaab9-\uaabd\uaac0\uaac2\uaadb-\uaadd\uaae0-\uaaea\uaaf2-\uaaf4\uab01-\uab06\uab09-\uab0e\uab11-\uab16\uab20-\uab26\uab28-\uab2e\uabc0-\uabe2\uac00-\ud7a3\ud7b0-\ud7c6\ud7cb-\ud7fb\uf900-\ufa6d\ufa70-\ufad9\ufb00-\ufb06\ufb13-\ufb17\ufb1d\ufb1f-\ufb28\ufb2a-\ufb36\ufb38-\ufb3c\ufb3e\ufb40\ufb41\ufb43\ufb44\ufb46-\ufbb1\ufbd3-\ufd3d\ufd50-\ufd8f\ufd92-\ufdc7\ufdf0-\ufdfb\ufe70-\ufe74\ufe76-\ufefc\uff21-\uff3a\uff41-\uff5a\uff66-\uffbe\uffc2-\uffc7\uffca-\uffcf\uffd2-\uffd7\uffda-\uffdc"; 5104 var nonASCIIidentifierChars = "\u0300-\u036f\u0483-\u0487\u0591-\u05bd\u05bf\u05c1\u05c2\u05c4\u05c5\u05c7\u0610-\u061a\u0620-\u0649\u0672-\u06d3\u06e7-\u06e8\u06fb-\u06fc\u0730-\u074a\u0800-\u0814\u081b-\u0823\u0825-\u0827\u0829-\u082d\u0840-\u0857\u08e4-\u08fe\u0900-\u0903\u093a-\u093c\u093e-\u094f\u0951-\u0957\u0962-\u0963\u0966-\u096f\u0981-\u0983\u09bc\u09be-\u09c4\u09c7\u09c8\u09d7\u09df-\u09e0\u0a01-\u0a03\u0a3c\u0a3e-\u0a42\u0a47\u0a48\u0a4b-\u0a4d\u0a51\u0a66-\u0a71\u0a75\u0a81-\u0a83\u0abc\u0abe-\u0ac5\u0ac7-\u0ac9\u0acb-\u0acd\u0ae2-\u0ae3\u0ae6-\u0aef\u0b01-\u0b03\u0b3c\u0b3e-\u0b44\u0b47\u0b48\u0b4b-\u0b4d\u0b56\u0b57\u0b5f-\u0b60\u0b66-\u0b6f\u0b82\u0bbe-\u0bc2\u0bc6-\u0bc8\u0bca-\u0bcd\u0bd7\u0be6-\u0bef\u0c01-\u0c03\u0c46-\u0c48\u0c4a-\u0c4d\u0c55\u0c56\u0c62-\u0c63\u0c66-\u0c6f\u0c82\u0c83\u0cbc\u0cbe-\u0cc4\u0cc6-\u0cc8\u0cca-\u0ccd\u0cd5\u0cd6\u0ce2-\u0ce3\u0ce6-\u0cef\u0d02\u0d03\u0d46-\u0d48\u0d57\u0d62-\u0d63\u0d66-\u0d6f\u0d82\u0d83\u0dca\u0dcf-\u0dd4\u0dd6\u0dd8-\u0ddf\u0df2\u0df3\u0e34-\u0e3a\u0e40-\u0e45\u0e50-\u0e59\u0eb4-\u0eb9\u0ec8-\u0ecd\u0ed0-\u0ed9\u0f18\u0f19\u0f20-\u0f29\u0f35\u0f37\u0f39\u0f41-\u0f47\u0f71-\u0f84\u0f86-\u0f87\u0f8d-\u0f97\u0f99-\u0fbc\u0fc6\u1000-\u1029\u1040-\u1049\u1067-\u106d\u1071-\u1074\u1082-\u108d\u108f-\u109d\u135d-\u135f\u170e-\u1710\u1720-\u1730\u1740-\u1750\u1772\u1773\u1780-\u17b2\u17dd\u17e0-\u17e9\u180b-\u180d\u1810-\u1819\u1920-\u192b\u1930-\u193b\u1951-\u196d\u19b0-\u19c0\u19c8-\u19c9\u19d0-\u19d9\u1a00-\u1a15\u1a20-\u1a53\u1a60-\u1a7c\u1a7f-\u1a89\u1a90-\u1a99\u1b46-\u1b4b\u1b50-\u1b59\u1b6b-\u1b73\u1bb0-\u1bb9\u1be6-\u1bf3\u1c00-\u1c22\u1c40-\u1c49\u1c5b-\u1c7d\u1cd0-\u1cd2\u1d00-\u1dbe\u1e01-\u1f15\u200c\u200d\u203f\u2040\u2054\u20d0-\u20dc\u20e1\u20e5-\u20f0\u2d81-\u2d96\u2de0-\u2dff\u3021-\u3028\u3099\u309a\ua640-\ua66d\ua674-\ua67d\ua69f\ua6f0-\ua6f1\ua7f8-\ua800\ua806\ua80b\ua823-\ua827\ua880-\ua881\ua8b4-\ua8c4\ua8d0-\ua8d9\ua8f3-\ua8f7\ua900-\ua909\ua926-\ua92d\ua930-\ua945\ua980-\ua983\ua9b3-\ua9c0\uaa00-\uaa27\uaa40-\uaa41\uaa4c-\uaa4d\uaa50-\uaa59\uaa7b\uaae0-\uaae9\uaaf2-\uaaf3\uabc0-\uabe1\uabec\uabed\uabf0-\uabf9\ufb20-\ufb28\ufe00-\ufe0f\ufe20-\ufe26\ufe33\ufe34\ufe4d-\ufe4f\uff10-\uff19\uff3f"; 5105 var nonASCIIidentifierStart = new RegExp("[" + nonASCIIidentifierStartChars + "]"); 5106 var nonASCIIidentifier = new RegExp("[" + nonASCIIidentifierStartChars + nonASCIIidentifierChars + "]"); 5107 5108 // Whether a single character denotes a newline. 5109 5110 exports.newline = /[\n\r\u2028\u2029]/; 5111 5112 // Matches a whole line break (where CRLF is considered a single 5113 // line break). Used to count lines. 5114 5115 // in javascript, these two differ 5116 // in python they are the same, different methods are called on them 5117 exports.lineBreak = new RegExp('\r\n|' + exports.newline.source); 5118 exports.allLineBreaks = new RegExp(exports.lineBreak.source, 'g'); 5119 5120 5121 // Test whether a given character code starts an identifier. 5122 5123 exports.isIdentifierStart = function(code) { 5124 // permit $ (36) and @ (64). @ is used in ES7 decorators. 5125 if (code < 65) return code === 36 || code === 64; 5126 // 65 through 91 are uppercase letters. 5127 if (code < 91) return true; 5128 // permit _ (95). 5129 if (code < 97) return code === 95; 5130 // 97 through 123 are lowercase letters. 5131 if (code < 123) return true; 5132 return code >= 0xaa && nonASCIIidentifierStart.test(String.fromCharCode(code)); 5133 }; 5134 5135 // Test whether a given character is part of an identifier. 5136 5137 exports.isIdentifierChar = function(code) { 5138 if (code < 48) return code === 36; 5139 if (code < 58) return true; 5140 if (code < 65) return false; 5141 if (code < 91) return true; 5142 if (code < 97) return code === 95; 5143 if (code < 123) return true; 5144 return code >= 0xaa && nonASCIIidentifier.test(String.fromCharCode(code)); 5145 }; 5146 5147 5148 /***/ }), 5149 /* 2 */ 5150 /***/ (function(module, exports) { 5151 5152 /*jshint curly:true, eqeqeq:true, laxbreak:true, noempty:false */ 5153 /* 5154 5155 The MIT License (MIT) 5156 5157 Copyright (c) 2007-2017 Einar Lielmanis, Liam Newman, and contributors. 5158 5159 Permission is hereby granted, free of charge, to any person 5160 obtaining a copy of this software and associated documentation files 5161 (the "Software"), to deal in the Software without restriction, 5162 including without limitation the rights to use, copy, modify, merge, 5163 publish, distribute, sublicense, and/or sell copies of the Software, 5164 and to permit persons to whom the Software is furnished to do so, 5165 subject to the following conditions: 5166 5167 The above copyright notice and this permission notice shall be 5168 included in all copies or substantial portions of the Software. 5169 5170 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 5171 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 5172 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 5173 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 5174 BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 5175 ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 5176 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 5177 SOFTWARE. 5178 */ 5179 5180 function mergeOpts(allOptions, targetType) { 5181 var finalOpts = {}; 5182 var name; 5183 5184 for (name in allOptions) { 5185 if (name !== targetType) { 5186 finalOpts[name] = allOptions[name]; 5187 } 5188 } 5189 5190 //merge in the per type settings for the targetType 5191 if (targetType in allOptions) { 5192 for (name in allOptions[targetType]) { 5193 finalOpts[name] = allOptions[targetType][name]; 5194 } 5195 } 5196 return finalOpts; 5197 } 5198 5199 module.exports.mergeOpts = mergeOpts; 5200 5201 5202 /***/ }), 5203 /* 3 */ 5204 /***/ (function(module, exports, __webpack_require__) { 5205 5206 /*jshint curly:true, eqeqeq:true, laxbreak:true, noempty:false */ 5207 /* 5208 5209 The MIT License (MIT) 5210 5211 Copyright (c) 2007-2017 Einar Lielmanis, Liam Newman, and contributors. 5212 5213 Permission is hereby granted, free of charge, to any person 5214 obtaining a copy of this software and associated documentation files 5215 (the "Software"), to deal in the Software without restriction, 5216 including without limitation the rights to use, copy, modify, merge, 5217 publish, distribute, sublicense, and/or sell copies of the Software, 5218 and to permit persons to whom the Software is furnished to do so, 5219 subject to the following conditions: 5220 5221 The above copyright notice and this permission notice shall be 5222 included in all copies or substantial portions of the Software. 5223 5224 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 5225 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 5226 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 5227 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 5228 BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 5229 ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 5230 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 5231 SOFTWARE. 5232 */ 5233 5234 var Beautifier = __webpack_require__(0).Beautifier; 5235 5236 function style_html(html_source, options, js_beautify, css_beautify) { 5237 var beautifier = new Beautifier(html_source, options, js_beautify, css_beautify); 5238 return beautifier.beautify(); 5239 } 5240 5241 module.exports = style_html; 5242 5243 /***/ }) 5244 /******/ ]); 5245 var style_html = legacy_beautify_html; 5246 /* Footer */ 5247 if (typeof define === "function" && define.amd) { 5248 // Add support for AMD ( https://github.com/amdjs/amdjs-api/wiki/AMD#defineamd-property- ) 5249 define(["require", "./beautify", "./beautify-css"], function(requireamd) { 5250 var js_beautify = requireamd("./beautify"); 5251 var css_beautify = requireamd("./beautify-css"); 5252 5253 return { 5254 html_beautify: function(html_source, options) { 5255 return style_html(html_source, options, js_beautify.js_beautify, css_beautify.css_beautify); 5256 } 5257 }; 5258 }); 5259 } else if (typeof exports !== "undefined") { 5260 // Add support for CommonJS. Just put this file somewhere on your require.paths 5261 // and you will be able to `var html_beautify = require("beautify").html_beautify`. 5262 var js_beautify = require ('./beautify.js'); 5263 var css_beautify = require ('./beautify-css.js'); 5264 5265 exports.html_beautify = function(html_source, options) { 5266 return style_html(html_source, options, js_beautify.js_beautify, css_beautify.css_beautify); 5267 }; 5268 } else if (typeof window !== "undefined") { 5269 // If we're running a web page and don't have either of the above, add our one global 5270 window.html_beautify = function(html_source, options) { 5271 return style_html(html_source, options, window.js_beautify, window.css_beautify); 5272 }; 5273 } else if (typeof global !== "undefined") { 5274 // If we don't even have window, try global. 5275 global.html_beautify = function(html_source, options) { 5276 return style_html(html_source, options, global.js_beautify, global.css_beautify); 5277 }; 5278 } 5279 5280 }()); 5281 5282 5283 }, '@VERSION@');
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Wed Jan 22 11:59:49 2025 | Cross-referenced by PHPXref 0.7.1 |