beautify-css.js 43 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389
  1. /* AUTO-GENERATED. DO NOT MODIFY. */
  2. /*
  3. The MIT License (MIT)
  4. Copyright (c) 2007-2018 Einar Lielmanis, Liam Newman, and contributors.
  5. Permission is hereby granted, free of charge, to any person
  6. obtaining a copy of this software and associated documentation files
  7. (the "Software"), to deal in the Software without restriction,
  8. including without limitation the rights to use, copy, modify, merge,
  9. publish, distribute, sublicense, and/or sell copies of the Software,
  10. and to permit persons to whom the Software is furnished to do so,
  11. subject to the following conditions:
  12. The above copyright notice and this permission notice shall be
  13. included in all copies or substantial portions of the Software.
  14. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  15. EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  16. MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  17. NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
  18. BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
  19. ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  20. CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  21. SOFTWARE.
  22. CSS Beautifier
  23. ---------------
  24. Written by Harutyun Amirjanyan, (amirjanyan@gmail.com)
  25. Based on code initially developed by: Einar Lielmanis, <einar@beautifier.io>
  26. https://beautifier.io/
  27. Usage:
  28. css_beautify(source_text);
  29. css_beautify(source_text, options);
  30. The options are (default in brackets):
  31. indent_size (4) — indentation size,
  32. indent_char (space) — character to indent with,
  33. selector_separator_newline (true) - separate selectors with newline or
  34. not (e.g. "a,\nbr" or "a, br")
  35. end_with_newline (false) - end with a newline
  36. newline_between_rules (true) - add a new line after every css rule
  37. space_around_selector_separator (false) - ensure space around selector separators:
  38. '>', '+', '~' (e.g. "a>b" -> "a > b")
  39. e.g
  40. css_beautify(css_source_text, {
  41. 'indent_size': 1,
  42. 'indent_char': '\t',
  43. 'selector_separator': ' ',
  44. 'end_with_newline': false,
  45. 'newline_between_rules': true,
  46. 'space_around_selector_separator': true
  47. });
  48. */
  49. // http://www.w3.org/TR/CSS21/syndata.html#tokenization
  50. // http://www.w3.org/TR/css3-syntax/
  51. (function() {
  52. /* GENERATED_BUILD_OUTPUT */
  53. var legacy_beautify_css =
  54. /******/ (function(modules) { // webpackBootstrap
  55. /******/ // The module cache
  56. /******/ var installedModules = {};
  57. /******/
  58. /******/ // The require function
  59. /******/ function __webpack_require__(moduleId) {
  60. /******/
  61. /******/ // Check if module is in cache
  62. /******/ if(installedModules[moduleId]) {
  63. /******/ return installedModules[moduleId].exports;
  64. /******/ }
  65. /******/ // Create a new module (and put it into the cache)
  66. /******/ var module = installedModules[moduleId] = {
  67. /******/ i: moduleId,
  68. /******/ l: false,
  69. /******/ exports: {}
  70. /******/ };
  71. /******/
  72. /******/ // Execute the module function
  73. /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  74. /******/
  75. /******/ // Flag the module as loaded
  76. /******/ module.l = true;
  77. /******/
  78. /******/ // Return the exports of the module
  79. /******/ return module.exports;
  80. /******/ }
  81. /******/
  82. /******/
  83. /******/ // expose the modules object (__webpack_modules__)
  84. /******/ __webpack_require__.m = modules;
  85. /******/
  86. /******/ // expose the module cache
  87. /******/ __webpack_require__.c = installedModules;
  88. /******/
  89. /******/ // define getter function for harmony exports
  90. /******/ __webpack_require__.d = function(exports, name, getter) {
  91. /******/ if(!__webpack_require__.o(exports, name)) {
  92. /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
  93. /******/ }
  94. /******/ };
  95. /******/
  96. /******/ // define __esModule on exports
  97. /******/ __webpack_require__.r = function(exports) {
  98. /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
  99. /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
  100. /******/ }
  101. /******/ Object.defineProperty(exports, '__esModule', { value: true });
  102. /******/ };
  103. /******/
  104. /******/ // create a fake namespace object
  105. /******/ // mode & 1: value is a module id, require it
  106. /******/ // mode & 2: merge all properties of value into the ns
  107. /******/ // mode & 4: return value when already ns object
  108. /******/ // mode & 8|1: behave like require
  109. /******/ __webpack_require__.t = function(value, mode) {
  110. /******/ if(mode & 1) value = __webpack_require__(value);
  111. /******/ if(mode & 8) return value;
  112. /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
  113. /******/ var ns = Object.create(null);
  114. /******/ __webpack_require__.r(ns);
  115. /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
  116. /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
  117. /******/ return ns;
  118. /******/ };
  119. /******/
  120. /******/ // getDefaultExport function for compatibility with non-harmony modules
  121. /******/ __webpack_require__.n = function(module) {
  122. /******/ var getter = module && module.__esModule ?
  123. /******/ function getDefault() { return module['default']; } :
  124. /******/ function getModuleExports() { return module; };
  125. /******/ __webpack_require__.d(getter, 'a', getter);
  126. /******/ return getter;
  127. /******/ };
  128. /******/
  129. /******/ // Object.prototype.hasOwnProperty.call
  130. /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
  131. /******/
  132. /******/ // __webpack_public_path__
  133. /******/ __webpack_require__.p = "";
  134. /******/
  135. /******/
  136. /******/ // Load entry module and return exports
  137. /******/ return __webpack_require__(__webpack_require__.s = 12);
  138. /******/ })
  139. /************************************************************************/
  140. /******/ ([
  141. /* 0 */,
  142. /* 1 */,
  143. /* 2 */
  144. /***/ (function(module, exports, __webpack_require__) {
  145. "use strict";
  146. /*jshint node:true */
  147. /*
  148. The MIT License (MIT)
  149. Copyright (c) 2007-2018 Einar Lielmanis, Liam Newman, and contributors.
  150. Permission is hereby granted, free of charge, to any person
  151. obtaining a copy of this software and associated documentation files
  152. (the "Software"), to deal in the Software without restriction,
  153. including without limitation the rights to use, copy, modify, merge,
  154. publish, distribute, sublicense, and/or sell copies of the Software,
  155. and to permit persons to whom the Software is furnished to do so,
  156. subject to the following conditions:
  157. The above copyright notice and this permission notice shall be
  158. included in all copies or substantial portions of the Software.
  159. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  160. EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  161. MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  162. NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
  163. BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
  164. ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  165. CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  166. SOFTWARE.
  167. */
  168. function OutputLine(parent) {
  169. this.__parent = parent;
  170. this.__character_count = 0;
  171. // use indent_count as a marker for this.__lines that have preserved indentation
  172. this.__indent_count = -1;
  173. this.__alignment_count = 0;
  174. this.__items = [];
  175. }
  176. OutputLine.prototype.item = function(index) {
  177. if (index < 0) {
  178. return this.__items[this.__items.length + index];
  179. } else {
  180. return this.__items[index];
  181. }
  182. };
  183. OutputLine.prototype.has_match = function(pattern) {
  184. for (var lastCheckedOutput = this.__items.length - 1; lastCheckedOutput >= 0; lastCheckedOutput--) {
  185. if (this.__items[lastCheckedOutput].match(pattern)) {
  186. return true;
  187. }
  188. }
  189. return false;
  190. };
  191. OutputLine.prototype.set_indent = function(indent, alignment) {
  192. this.__indent_count = indent || 0;
  193. this.__alignment_count = alignment || 0;
  194. this.__character_count = this.__parent.baseIndentLength + this.__alignment_count + this.__indent_count * this.__parent.indent_length;
  195. };
  196. OutputLine.prototype.get_character_count = function() {
  197. return this.__character_count;
  198. };
  199. OutputLine.prototype.is_empty = function() {
  200. return this.__items.length === 0;
  201. };
  202. OutputLine.prototype.last = function() {
  203. if (!this.is_empty()) {
  204. return this.__items[this.__items.length - 1];
  205. } else {
  206. return null;
  207. }
  208. };
  209. OutputLine.prototype.push = function(item) {
  210. this.__items.push(item);
  211. this.__character_count += item.length;
  212. };
  213. OutputLine.prototype.push_raw = function(item) {
  214. this.push(item);
  215. var last_newline_index = item.lastIndexOf('\n');
  216. if (last_newline_index !== -1) {
  217. this.__character_count = item.length - last_newline_index;
  218. }
  219. };
  220. OutputLine.prototype.pop = function() {
  221. var item = null;
  222. if (!this.is_empty()) {
  223. item = this.__items.pop();
  224. this.__character_count -= item.length;
  225. }
  226. return item;
  227. };
  228. OutputLine.prototype.remove_indent = function() {
  229. if (this.__indent_count > 0) {
  230. this.__indent_count -= 1;
  231. this.__character_count -= this.__parent.indent_length;
  232. }
  233. };
  234. OutputLine.prototype.trim = function() {
  235. while (this.last() === ' ') {
  236. this.__items.pop();
  237. this.__character_count -= 1;
  238. }
  239. };
  240. OutputLine.prototype.toString = function() {
  241. var result = '';
  242. if (!this.is_empty()) {
  243. if (this.__indent_count >= 0) {
  244. result = this.__parent.get_indent_string(this.__indent_count);
  245. }
  246. if (this.__alignment_count >= 0) {
  247. result += this.__parent.get_alignment_string(this.__alignment_count);
  248. }
  249. result += this.__items.join('');
  250. }
  251. return result;
  252. };
  253. function IndentCache(base_string, level_string) {
  254. this.__cache = [base_string];
  255. this.__level_string = level_string;
  256. }
  257. IndentCache.prototype.__ensure_cache = function(level) {
  258. while (level >= this.__cache.length) {
  259. this.__cache.push(this.__cache[this.__cache.length - 1] + this.__level_string);
  260. }
  261. };
  262. IndentCache.prototype.get_level_string = function(level) {
  263. this.__ensure_cache(level);
  264. return this.__cache[level];
  265. };
  266. function Output(options, baseIndentString) {
  267. var indent_string = options.indent_char;
  268. if (options.indent_size > 1) {
  269. indent_string = new Array(options.indent_size + 1).join(options.indent_char);
  270. }
  271. // Set to null to continue support for auto detection of base indent level.
  272. baseIndentString = baseIndentString || '';
  273. if (options.indent_level > 0) {
  274. baseIndentString = new Array(options.indent_level + 1).join(indent_string);
  275. }
  276. this.__indent_cache = new IndentCache(baseIndentString, indent_string);
  277. this.__alignment_cache = new IndentCache('', ' ');
  278. this.baseIndentLength = baseIndentString.length;
  279. this.indent_length = indent_string.length;
  280. this.raw = false;
  281. this._end_with_newline = options.end_with_newline;
  282. this.__lines = [];
  283. this.previous_line = null;
  284. this.current_line = null;
  285. this.space_before_token = false;
  286. // initialize
  287. this.__add_outputline();
  288. }
  289. Output.prototype.__add_outputline = function() {
  290. this.previous_line = this.current_line;
  291. this.current_line = new OutputLine(this);
  292. this.__lines.push(this.current_line);
  293. };
  294. Output.prototype.get_line_number = function() {
  295. return this.__lines.length;
  296. };
  297. Output.prototype.get_indent_string = function(level) {
  298. return this.__indent_cache.get_level_string(level);
  299. };
  300. Output.prototype.get_alignment_string = function(level) {
  301. return this.__alignment_cache.get_level_string(level);
  302. };
  303. Output.prototype.is_empty = function() {
  304. return !this.previous_line && this.current_line.is_empty();
  305. };
  306. Output.prototype.add_new_line = function(force_newline) {
  307. // never newline at the start of file
  308. // otherwise, newline only if we didn't just add one or we're forced
  309. if (this.is_empty() ||
  310. (!force_newline && this.just_added_newline())) {
  311. return false;
  312. }
  313. // if raw output is enabled, don't print additional newlines,
  314. // but still return True as though you had
  315. if (!this.raw) {
  316. this.__add_outputline();
  317. }
  318. return true;
  319. };
  320. Output.prototype.get_code = function(eol) {
  321. var sweet_code = this.__lines.join('\n').replace(/[\r\n\t ]+$/, '');
  322. if (this._end_with_newline) {
  323. sweet_code += '\n';
  324. }
  325. if (eol !== '\n') {
  326. sweet_code = sweet_code.replace(/[\n]/g, eol);
  327. }
  328. return sweet_code;
  329. };
  330. Output.prototype.set_indent = function(indent, alignment) {
  331. indent = indent || 0;
  332. alignment = alignment || 0;
  333. // Never indent your first output indent at the start of the file
  334. if (this.__lines.length > 1) {
  335. this.current_line.set_indent(indent, alignment);
  336. return true;
  337. }
  338. this.current_line.set_indent();
  339. return false;
  340. };
  341. Output.prototype.add_raw_token = function(token) {
  342. for (var x = 0; x < token.newlines; x++) {
  343. this.__add_outputline();
  344. }
  345. this.current_line.push(token.whitespace_before);
  346. this.current_line.push_raw(token.text);
  347. this.space_before_token = false;
  348. };
  349. Output.prototype.add_token = function(printable_token) {
  350. this.add_space_before_token();
  351. this.current_line.push(printable_token);
  352. };
  353. Output.prototype.add_space_before_token = function() {
  354. if (this.space_before_token && !this.just_added_newline()) {
  355. this.current_line.push(' ');
  356. }
  357. this.space_before_token = false;
  358. };
  359. Output.prototype.remove_indent = function(index) {
  360. var output_length = this.__lines.length;
  361. while (index < output_length) {
  362. this.__lines[index].remove_indent();
  363. index++;
  364. }
  365. };
  366. Output.prototype.trim = function(eat_newlines) {
  367. eat_newlines = (eat_newlines === undefined) ? false : eat_newlines;
  368. this.current_line.trim(this.indent_string, this.baseIndentString);
  369. while (eat_newlines && this.__lines.length > 1 &&
  370. this.current_line.is_empty()) {
  371. this.__lines.pop();
  372. this.current_line = this.__lines[this.__lines.length - 1];
  373. this.current_line.trim();
  374. }
  375. this.previous_line = this.__lines.length > 1 ?
  376. this.__lines[this.__lines.length - 2] : null;
  377. };
  378. Output.prototype.just_added_newline = function() {
  379. return this.current_line.is_empty();
  380. };
  381. Output.prototype.just_added_blankline = function() {
  382. return this.is_empty() ||
  383. (this.current_line.is_empty() && this.previous_line.is_empty());
  384. };
  385. Output.prototype.ensure_empty_line_above = function(starts_with, ends_with) {
  386. var index = this.__lines.length - 2;
  387. while (index >= 0) {
  388. var potentialEmptyLine = this.__lines[index];
  389. if (potentialEmptyLine.is_empty()) {
  390. break;
  391. } else if (potentialEmptyLine.item(0).indexOf(starts_with) !== 0 &&
  392. potentialEmptyLine.item(-1) !== ends_with) {
  393. this.__lines.splice(index + 1, 0, new OutputLine(this));
  394. this.previous_line = this.__lines[this.__lines.length - 2];
  395. break;
  396. }
  397. index--;
  398. }
  399. };
  400. module.exports.Output = Output;
  401. /***/ }),
  402. /* 3 */,
  403. /* 4 */,
  404. /* 5 */,
  405. /* 6 */
  406. /***/ (function(module, exports, __webpack_require__) {
  407. "use strict";
  408. /*jshint node:true */
  409. /*
  410. The MIT License (MIT)
  411. Copyright (c) 2007-2018 Einar Lielmanis, Liam Newman, and contributors.
  412. Permission is hereby granted, free of charge, to any person
  413. obtaining a copy of this software and associated documentation files
  414. (the "Software"), to deal in the Software without restriction,
  415. including without limitation the rights to use, copy, modify, merge,
  416. publish, distribute, sublicense, and/or sell copies of the Software,
  417. and to permit persons to whom the Software is furnished to do so,
  418. subject to the following conditions:
  419. The above copyright notice and this permission notice shall be
  420. included in all copies or substantial portions of the Software.
  421. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  422. EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  423. MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  424. NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
  425. BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
  426. ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  427. CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  428. SOFTWARE.
  429. */
  430. function Options(options, merge_child_field) {
  431. this.raw_options = _mergeOpts(options, merge_child_field);
  432. // Support passing the source text back with no change
  433. this.disabled = this._get_boolean('disabled');
  434. this.eol = this._get_characters('eol', 'auto');
  435. this.end_with_newline = this._get_boolean('end_with_newline');
  436. this.indent_size = this._get_number('indent_size', 4);
  437. this.indent_char = this._get_characters('indent_char', ' ');
  438. this.indent_level = this._get_number('indent_level');
  439. this.preserve_newlines = this._get_boolean('preserve_newlines', true);
  440. this.max_preserve_newlines = this._get_number('max_preserve_newlines', 32786);
  441. if (!this.preserve_newlines) {
  442. this.max_preserve_newlines = 0;
  443. }
  444. this.indent_with_tabs = this._get_boolean('indent_with_tabs');
  445. if (this.indent_with_tabs) {
  446. this.indent_char = '\t';
  447. this.indent_size = 1;
  448. }
  449. // Backwards compat with 1.3.x
  450. this.wrap_line_length = this._get_number('wrap_line_length', this._get_number('max_char'));
  451. }
  452. Options.prototype._get_array = function(name, default_value) {
  453. var option_value = this.raw_options[name];
  454. var result = default_value || [];
  455. if (typeof option_value === 'object') {
  456. if (option_value !== null && typeof option_value.concat === 'function') {
  457. result = option_value.concat();
  458. }
  459. } else if (typeof option_value === 'string') {
  460. result = option_value.split(/[^a-zA-Z0-9_\/\-]+/);
  461. }
  462. return result;
  463. };
  464. Options.prototype._get_boolean = function(name, default_value) {
  465. var option_value = this.raw_options[name];
  466. var result = option_value === undefined ? !!default_value : !!option_value;
  467. return result;
  468. };
  469. Options.prototype._get_characters = function(name, default_value) {
  470. var option_value = this.raw_options[name];
  471. var result = default_value || '';
  472. if (typeof option_value === 'string') {
  473. result = option_value.replace(/\\r/, '\r').replace(/\\n/, '\n').replace(/\\t/, '\t');
  474. }
  475. return result;
  476. };
  477. Options.prototype._get_number = function(name, default_value) {
  478. var option_value = this.raw_options[name];
  479. default_value = parseInt(default_value, 10);
  480. if (isNaN(default_value)) {
  481. default_value = 0;
  482. }
  483. var result = parseInt(option_value, 10);
  484. if (isNaN(result)) {
  485. result = default_value;
  486. }
  487. return result;
  488. };
  489. Options.prototype._get_selection = function(name, selection_list, default_value) {
  490. var result = this._get_selection_list(name, selection_list, default_value);
  491. if (result.length !== 1) {
  492. throw new Error(
  493. "Invalid Option Value: The option '" + name + "' can only be one of the following values:\n" +
  494. selection_list + "\nYou passed in: '" + this.raw_options[name] + "'");
  495. }
  496. return result[0];
  497. };
  498. Options.prototype._get_selection_list = function(name, selection_list, default_value) {
  499. if (!selection_list || selection_list.length === 0) {
  500. throw new Error("Selection list cannot be empty.");
  501. }
  502. default_value = default_value || [selection_list[0]];
  503. if (!this._is_valid_selection(default_value, selection_list)) {
  504. throw new Error("Invalid Default Value!");
  505. }
  506. var result = this._get_array(name, default_value);
  507. if (!this._is_valid_selection(result, selection_list)) {
  508. throw new Error(
  509. "Invalid Option Value: The option '" + name + "' can contain only the following values:\n" +
  510. selection_list + "\nYou passed in: '" + this.raw_options[name] + "'");
  511. }
  512. return result;
  513. };
  514. Options.prototype._is_valid_selection = function(result, selection_list) {
  515. return result.length && selection_list.length &&
  516. !result.some(function(item) { return selection_list.indexOf(item) === -1; });
  517. };
  518. // merges child options up with the parent options object
  519. // Example: obj = {a: 1, b: {a: 2}}
  520. // mergeOpts(obj, 'b')
  521. //
  522. // Returns: {a: 2}
  523. function _mergeOpts(allOptions, childFieldName) {
  524. var finalOpts = {};
  525. allOptions = _normalizeOpts(allOptions);
  526. var name;
  527. for (name in allOptions) {
  528. if (name !== childFieldName) {
  529. finalOpts[name] = allOptions[name];
  530. }
  531. }
  532. //merge in the per type settings for the childFieldName
  533. if (childFieldName && allOptions[childFieldName]) {
  534. for (name in allOptions[childFieldName]) {
  535. finalOpts[name] = allOptions[childFieldName][name];
  536. }
  537. }
  538. return finalOpts;
  539. }
  540. function _normalizeOpts(options) {
  541. var convertedOpts = {};
  542. var key;
  543. for (key in options) {
  544. var newKey = key.replace(/-/g, "_");
  545. convertedOpts[newKey] = options[key];
  546. }
  547. return convertedOpts;
  548. }
  549. module.exports.Options = Options;
  550. module.exports.normalizeOpts = _normalizeOpts;
  551. module.exports.mergeOpts = _mergeOpts;
  552. /***/ }),
  553. /* 7 */,
  554. /* 8 */
  555. /***/ (function(module, exports, __webpack_require__) {
  556. "use strict";
  557. /*jshint node:true */
  558. /*
  559. The MIT License (MIT)
  560. Copyright (c) 2007-2018 Einar Lielmanis, Liam Newman, and contributors.
  561. Permission is hereby granted, free of charge, to any person
  562. obtaining a copy of this software and associated documentation files
  563. (the "Software"), to deal in the Software without restriction,
  564. including without limitation the rights to use, copy, modify, merge,
  565. publish, distribute, sublicense, and/or sell copies of the Software,
  566. and to permit persons to whom the Software is furnished to do so,
  567. subject to the following conditions:
  568. The above copyright notice and this permission notice shall be
  569. included in all copies or substantial portions of the Software.
  570. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  571. EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  572. MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  573. NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
  574. BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
  575. ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  576. CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  577. SOFTWARE.
  578. */
  579. function InputScanner(input_string) {
  580. this.__input = input_string || '';
  581. this.__input_length = this.__input.length;
  582. this.__position = 0;
  583. }
  584. InputScanner.prototype.restart = function() {
  585. this.__position = 0;
  586. };
  587. InputScanner.prototype.back = function() {
  588. if (this.__position > 0) {
  589. this.__position -= 1;
  590. }
  591. };
  592. InputScanner.prototype.hasNext = function() {
  593. return this.__position < this.__input_length;
  594. };
  595. InputScanner.prototype.next = function() {
  596. var val = null;
  597. if (this.hasNext()) {
  598. val = this.__input.charAt(this.__position);
  599. this.__position += 1;
  600. }
  601. return val;
  602. };
  603. InputScanner.prototype.peek = function(index) {
  604. var val = null;
  605. index = index || 0;
  606. index += this.__position;
  607. if (index >= 0 && index < this.__input_length) {
  608. val = this.__input.charAt(index);
  609. }
  610. return val;
  611. };
  612. InputScanner.prototype.test = function(pattern, index) {
  613. index = index || 0;
  614. index += this.__position;
  615. pattern.lastIndex = index;
  616. if (index >= 0 && index < this.__input_length) {
  617. var pattern_match = pattern.exec(this.__input);
  618. return pattern_match && pattern_match.index === index;
  619. } else {
  620. return false;
  621. }
  622. };
  623. InputScanner.prototype.testChar = function(pattern, index) {
  624. // test one character regex match
  625. var val = this.peek(index);
  626. return val !== null && pattern.test(val);
  627. };
  628. InputScanner.prototype.match = function(pattern) {
  629. pattern.lastIndex = this.__position;
  630. var pattern_match = pattern.exec(this.__input);
  631. if (pattern_match && pattern_match.index === this.__position) {
  632. this.__position += pattern_match[0].length;
  633. } else {
  634. pattern_match = null;
  635. }
  636. return pattern_match;
  637. };
  638. InputScanner.prototype.read = function(pattern) {
  639. var val = '';
  640. var match = this.match(pattern);
  641. if (match) {
  642. val = match[0];
  643. }
  644. return val;
  645. };
  646. InputScanner.prototype.readUntil = function(pattern, include_match) {
  647. var val = '';
  648. var match_index = this.__position;
  649. pattern.lastIndex = this.__position;
  650. var pattern_match = pattern.exec(this.__input);
  651. if (pattern_match) {
  652. if (include_match) {
  653. match_index = pattern_match.index + pattern_match[0].length;
  654. } else {
  655. match_index = pattern_match.index;
  656. }
  657. } else {
  658. match_index = this.__input_length;
  659. }
  660. val = this.__input.substring(this.__position, match_index);
  661. this.__position = match_index;
  662. return val;
  663. };
  664. InputScanner.prototype.readUntilAfter = function(pattern) {
  665. return this.readUntil(pattern, true);
  666. };
  667. /* css beautifier legacy helpers */
  668. InputScanner.prototype.peekUntilAfter = function(pattern) {
  669. var start = this.__position;
  670. var val = this.readUntilAfter(pattern);
  671. this.__position = start;
  672. return val;
  673. };
  674. InputScanner.prototype.lookBack = function(testVal) {
  675. var start = this.__position - 1;
  676. return start >= testVal.length && this.__input.substring(start - testVal.length, start)
  677. .toLowerCase() === testVal;
  678. };
  679. module.exports.InputScanner = InputScanner;
  680. /***/ }),
  681. /* 9 */,
  682. /* 10 */,
  683. /* 11 */,
  684. /* 12 */
  685. /***/ (function(module, exports, __webpack_require__) {
  686. "use strict";
  687. /*jshint node:true */
  688. /*
  689. The MIT License (MIT)
  690. Copyright (c) 2007-2018 Einar Lielmanis, Liam Newman, and contributors.
  691. Permission is hereby granted, free of charge, to any person
  692. obtaining a copy of this software and associated documentation files
  693. (the "Software"), to deal in the Software without restriction,
  694. including without limitation the rights to use, copy, modify, merge,
  695. publish, distribute, sublicense, and/or sell copies of the Software,
  696. and to permit persons to whom the Software is furnished to do so,
  697. subject to the following conditions:
  698. The above copyright notice and this permission notice shall be
  699. included in all copies or substantial portions of the Software.
  700. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  701. EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  702. MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  703. NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
  704. BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
  705. ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  706. CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  707. SOFTWARE.
  708. */
  709. var Beautifier = __webpack_require__(13).Beautifier,
  710. Options = __webpack_require__(14).Options;
  711. function css_beautify(source_text, options) {
  712. var beautifier = new Beautifier(source_text, options);
  713. return beautifier.beautify();
  714. }
  715. module.exports = css_beautify;
  716. module.exports.defaultOptions = function() {
  717. return new Options();
  718. };
  719. /***/ }),
  720. /* 13 */
  721. /***/ (function(module, exports, __webpack_require__) {
  722. "use strict";
  723. /*jshint node:true */
  724. /*
  725. The MIT License (MIT)
  726. Copyright (c) 2007-2018 Einar Lielmanis, Liam Newman, and contributors.
  727. Permission is hereby granted, free of charge, to any person
  728. obtaining a copy of this software and associated documentation files
  729. (the "Software"), to deal in the Software without restriction,
  730. including without limitation the rights to use, copy, modify, merge,
  731. publish, distribute, sublicense, and/or sell copies of the Software,
  732. and to permit persons to whom the Software is furnished to do so,
  733. subject to the following conditions:
  734. The above copyright notice and this permission notice shall be
  735. included in all copies or substantial portions of the Software.
  736. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  737. EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  738. MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  739. NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
  740. BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
  741. ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  742. CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  743. SOFTWARE.
  744. */
  745. var Options = __webpack_require__(14).Options;
  746. var Output = __webpack_require__(2).Output;
  747. var InputScanner = __webpack_require__(8).InputScanner;
  748. var lineBreak = /\r\n|[\r\n]/;
  749. var allLineBreaks = /\r\n|[\r\n]/g;
  750. // tokenizer
  751. var whitespaceChar = /\s/;
  752. var whitespacePattern = /(?:\s|\n)+/g;
  753. var block_comment_pattern = /\/\*(?:[\s\S]*?)((?:\*\/)|$)/g;
  754. var comment_pattern = /\/\/(?:[^\n\r\u2028\u2029]*)/g;
  755. function Beautifier(source_text, options) {
  756. this._source_text = source_text || '';
  757. // Allow the setting of language/file-type specific options
  758. // with inheritance of overall settings
  759. this._options = new Options(options);
  760. this._ch = null;
  761. this._input = null;
  762. // https://developer.mozilla.org/en-US/docs/Web/CSS/At-rule
  763. this.NESTED_AT_RULE = {
  764. "@page": true,
  765. "@font-face": true,
  766. "@keyframes": true,
  767. // also in CONDITIONAL_GROUP_RULE below
  768. "@media": true,
  769. "@supports": true,
  770. "@document": true
  771. };
  772. this.CONDITIONAL_GROUP_RULE = {
  773. "@media": true,
  774. "@supports": true,
  775. "@document": true
  776. };
  777. }
  778. Beautifier.prototype.eatString = function(endChars) {
  779. var result = '';
  780. this._ch = this._input.next();
  781. while (this._ch) {
  782. result += this._ch;
  783. if (this._ch === "\\") {
  784. result += this._input.next();
  785. } else if (endChars.indexOf(this._ch) !== -1 || this._ch === "\n") {
  786. break;
  787. }
  788. this._ch = this._input.next();
  789. }
  790. return result;
  791. };
  792. // Skips any white space in the source text from the current position.
  793. // When allowAtLeastOneNewLine is true, will output new lines for each
  794. // newline character found; if the user has preserve_newlines off, only
  795. // the first newline will be output
  796. Beautifier.prototype.eatWhitespace = function(allowAtLeastOneNewLine) {
  797. var result = whitespaceChar.test(this._input.peek());
  798. var isFirstNewLine = true;
  799. while (whitespaceChar.test(this._input.peek())) {
  800. this._ch = this._input.next();
  801. if (allowAtLeastOneNewLine && this._ch === '\n') {
  802. if (this._options.preserve_newlines || isFirstNewLine) {
  803. isFirstNewLine = false;
  804. this._output.add_new_line(true);
  805. }
  806. }
  807. }
  808. return result;
  809. };
  810. // Nested pseudo-class if we are insideRule
  811. // and the next special character found opens
  812. // a new block
  813. Beautifier.prototype.foundNestedPseudoClass = function() {
  814. var openParen = 0;
  815. var i = 1;
  816. var ch = this._input.peek(i);
  817. while (ch) {
  818. if (ch === "{") {
  819. return true;
  820. } else if (ch === '(') {
  821. // pseudoclasses can contain ()
  822. openParen += 1;
  823. } else if (ch === ')') {
  824. if (openParen === 0) {
  825. return false;
  826. }
  827. openParen -= 1;
  828. } else if (ch === ";" || ch === "}") {
  829. return false;
  830. }
  831. i++;
  832. ch = this._input.peek(i);
  833. }
  834. return false;
  835. };
  836. Beautifier.prototype.print_string = function(output_string) {
  837. if (this._output.just_added_newline()) {
  838. this._output.set_indent(this._indentLevel);
  839. }
  840. this._output.add_token(output_string);
  841. };
  842. Beautifier.prototype.preserveSingleSpace = function(isAfterSpace) {
  843. if (isAfterSpace) {
  844. this._output.space_before_token = true;
  845. }
  846. };
  847. Beautifier.prototype.indent = function() {
  848. this._indentLevel++;
  849. };
  850. Beautifier.prototype.outdent = function() {
  851. if (this._indentLevel > 0) {
  852. this._indentLevel--;
  853. }
  854. };
  855. /*_____________________--------------------_____________________*/
  856. Beautifier.prototype.beautify = function() {
  857. if (this._options.disabled) {
  858. return this._source_text;
  859. }
  860. var source_text = this._source_text;
  861. var eol = this._options.eol;
  862. if (eol === 'auto') {
  863. eol = '\n';
  864. if (source_text && lineBreak.test(source_text || '')) {
  865. eol = source_text.match(lineBreak)[0];
  866. }
  867. }
  868. // HACK: newline parsing inconsistent. This brute force normalizes the this._input.
  869. source_text = source_text.replace(allLineBreaks, '\n');
  870. // reset
  871. var baseIndentString = source_text.match(/^[\t ]*/)[0];
  872. this._output = new Output(this._options, baseIndentString);
  873. this._input = new InputScanner(source_text);
  874. this._indentLevel = 0;
  875. this._nestedLevel = 0;
  876. this._ch = null;
  877. var parenLevel = 0;
  878. var insideRule = false;
  879. // This is the value side of a property value pair (blue in the following ex)
  880. // label { content: blue }
  881. var insidePropertyValue = false;
  882. var enteringConditionalGroup = false;
  883. var insideAtExtend = false;
  884. var insideAtImport = false;
  885. var topCharacter = this._ch;
  886. while (true) {
  887. var whitespace = this._input.read(whitespacePattern);
  888. var isAfterSpace = whitespace !== '';
  889. var previous_ch = topCharacter;
  890. this._ch = this._input.next();
  891. topCharacter = this._ch;
  892. if (!this._ch) {
  893. break;
  894. } else if (this._ch === '/' && this._input.peek() === '*') {
  895. // /* css comment */
  896. // Always start block comments on a new line.
  897. // This handles scenarios where a block comment immediately
  898. // follows a property definition on the same line or where
  899. // minified code is being beautified.
  900. this._output.add_new_line();
  901. this._input.back();
  902. this.print_string(this._input.read(block_comment_pattern));
  903. // Ensures any new lines following the comment are preserved
  904. this.eatWhitespace(true);
  905. // Block comments are followed by a new line so they don't
  906. // share a line with other properties
  907. this._output.add_new_line();
  908. } else if (this._ch === '/' && this._input.peek() === '/') {
  909. // // single line comment
  910. // Preserves the space before a comment
  911. // on the same line as a rule
  912. this._output.space_before_token = true;
  913. this._input.back();
  914. this.print_string(this._input.read(comment_pattern));
  915. // Ensures any new lines following the comment are preserved
  916. this.eatWhitespace(true);
  917. } else if (this._ch === '@') {
  918. this.preserveSingleSpace(isAfterSpace);
  919. // deal with less propery mixins @{...}
  920. if (this._input.peek() === '{') {
  921. this.print_string(this._ch + this.eatString('}'));
  922. } else {
  923. this.print_string(this._ch);
  924. // strip trailing space, if present, for hash property checks
  925. var variableOrRule = this._input.peekUntilAfter(/[: ,;{}()[\]\/='"]/g);
  926. if (variableOrRule.match(/[ :]$/)) {
  927. // we have a variable or pseudo-class, add it and insert one space before continuing
  928. variableOrRule = this.eatString(": ").replace(/\s$/, '');
  929. this.print_string(variableOrRule);
  930. this._output.space_before_token = true;
  931. }
  932. variableOrRule = variableOrRule.replace(/\s$/, '');
  933. if (variableOrRule === 'extend') {
  934. insideAtExtend = true;
  935. } else if (variableOrRule === 'import') {
  936. insideAtImport = true;
  937. }
  938. // might be a nesting at-rule
  939. if (variableOrRule in this.NESTED_AT_RULE) {
  940. this._nestedLevel += 1;
  941. if (variableOrRule in this.CONDITIONAL_GROUP_RULE) {
  942. enteringConditionalGroup = true;
  943. }
  944. // might be less variable
  945. } else if (!insideRule && parenLevel === 0 && variableOrRule.indexOf(':') !== -1) {
  946. insidePropertyValue = true;
  947. this.indent();
  948. }
  949. }
  950. } else if (this._ch === '#' && this._input.peek() === '{') {
  951. this.preserveSingleSpace(isAfterSpace);
  952. this.print_string(this._ch + this.eatString('}'));
  953. } else if (this._ch === '{') {
  954. if (insidePropertyValue) {
  955. insidePropertyValue = false;
  956. this.outdent();
  957. }
  958. this.indent();
  959. this._output.space_before_token = true;
  960. this.print_string(this._ch);
  961. // when entering conditional groups, only rulesets are allowed
  962. if (enteringConditionalGroup) {
  963. enteringConditionalGroup = false;
  964. insideRule = (this._indentLevel > this._nestedLevel);
  965. } else {
  966. // otherwise, declarations are also allowed
  967. insideRule = (this._indentLevel >= this._nestedLevel);
  968. }
  969. if (this._options.newline_between_rules && insideRule) {
  970. if (this._output.previous_line && this._output.previous_line.item(-1) !== '{') {
  971. this._output.ensure_empty_line_above('/', ',');
  972. }
  973. }
  974. this.eatWhitespace(true);
  975. this._output.add_new_line();
  976. } else if (this._ch === '}') {
  977. this.outdent();
  978. this._output.add_new_line();
  979. if (previous_ch === '{') {
  980. this._output.trim(true);
  981. }
  982. insideAtImport = false;
  983. insideAtExtend = false;
  984. if (insidePropertyValue) {
  985. this.outdent();
  986. insidePropertyValue = false;
  987. }
  988. this.print_string(this._ch);
  989. insideRule = false;
  990. if (this._nestedLevel) {
  991. this._nestedLevel--;
  992. }
  993. this.eatWhitespace(true);
  994. this._output.add_new_line();
  995. if (this._options.newline_between_rules && !this._output.just_added_blankline()) {
  996. if (this._input.peek() !== '}') {
  997. this._output.add_new_line(true);
  998. }
  999. }
  1000. } else if (this._ch === ":") {
  1001. if ((insideRule || enteringConditionalGroup) && !(this._input.lookBack("&") || this.foundNestedPseudoClass()) && !this._input.lookBack("(") && !insideAtExtend) {
  1002. // 'property: value' delimiter
  1003. // which could be in a conditional group query
  1004. this.print_string(':');
  1005. if (!insidePropertyValue) {
  1006. insidePropertyValue = true;
  1007. this._output.space_before_token = true;
  1008. this.eatWhitespace(true);
  1009. this.indent();
  1010. }
  1011. } else {
  1012. // sass/less parent reference don't use a space
  1013. // sass nested pseudo-class don't use a space
  1014. // preserve space before pseudoclasses/pseudoelements, as it means "in any child"
  1015. if (this._input.lookBack(" ")) {
  1016. this._output.space_before_token = true;
  1017. }
  1018. if (this._input.peek() === ":") {
  1019. // pseudo-element
  1020. this._ch = this._input.next();
  1021. this.print_string("::");
  1022. } else {
  1023. // pseudo-class
  1024. this.print_string(':');
  1025. }
  1026. }
  1027. } else if (this._ch === '"' || this._ch === '\'') {
  1028. this.preserveSingleSpace(isAfterSpace);
  1029. this.print_string(this._ch + this.eatString(this._ch));
  1030. this.eatWhitespace(true);
  1031. } else if (this._ch === ';') {
  1032. if (insidePropertyValue) {
  1033. this.outdent();
  1034. insidePropertyValue = false;
  1035. }
  1036. insideAtExtend = false;
  1037. insideAtImport = false;
  1038. this.print_string(this._ch);
  1039. this.eatWhitespace(true);
  1040. // This maintains single line comments on the same
  1041. // line. Block comments are also affected, but
  1042. // a new line is always output before one inside
  1043. // that section
  1044. if (this._input.peek() !== '/') {
  1045. this._output.add_new_line();
  1046. }
  1047. } else if (this._ch === '(') { // may be a url
  1048. if (this._input.lookBack("url")) {
  1049. this.print_string(this._ch);
  1050. this.eatWhitespace();
  1051. this._ch = this._input.next();
  1052. if (this._ch === ')' || this._ch === '"' || this._ch === '\'') {
  1053. this._input.back();
  1054. parenLevel++;
  1055. } else if (this._ch) {
  1056. this.print_string(this._ch + this.eatString(')'));
  1057. }
  1058. } else {
  1059. parenLevel++;
  1060. this.preserveSingleSpace(isAfterSpace);
  1061. this.print_string(this._ch);
  1062. this.eatWhitespace();
  1063. }
  1064. } else if (this._ch === ')') {
  1065. this.print_string(this._ch);
  1066. parenLevel--;
  1067. } else if (this._ch === ',') {
  1068. this.print_string(this._ch);
  1069. this.eatWhitespace(true);
  1070. if (this._options.selector_separator_newline && !insidePropertyValue && parenLevel < 1 && !insideAtImport) {
  1071. this._output.add_new_line();
  1072. } else {
  1073. this._output.space_before_token = true;
  1074. }
  1075. } else if ((this._ch === '>' || this._ch === '+' || this._ch === '~') && !insidePropertyValue && parenLevel < 1) {
  1076. //handle combinator spacing
  1077. if (this._options.space_around_combinator) {
  1078. this._output.space_before_token = true;
  1079. this.print_string(this._ch);
  1080. this._output.space_before_token = true;
  1081. } else {
  1082. this.print_string(this._ch);
  1083. this.eatWhitespace();
  1084. // squash extra whitespace
  1085. if (this._ch && whitespaceChar.test(this._ch)) {
  1086. this._ch = '';
  1087. }
  1088. }
  1089. } else if (this._ch === ']') {
  1090. this.print_string(this._ch);
  1091. } else if (this._ch === '[') {
  1092. this.preserveSingleSpace(isAfterSpace);
  1093. this.print_string(this._ch);
  1094. } else if (this._ch === '=') { // no whitespace before or after
  1095. this.eatWhitespace();
  1096. this.print_string('=');
  1097. if (whitespaceChar.test(this._ch)) {
  1098. this._ch = '';
  1099. }
  1100. } else if (this._ch === '!') { // !important
  1101. this.print_string(' ');
  1102. this.print_string(this._ch);
  1103. } else {
  1104. this.preserveSingleSpace(isAfterSpace);
  1105. this.print_string(this._ch);
  1106. }
  1107. }
  1108. var sweetCode = this._output.get_code(eol);
  1109. return sweetCode;
  1110. };
  1111. module.exports.Beautifier = Beautifier;
  1112. /***/ }),
  1113. /* 14 */
  1114. /***/ (function(module, exports, __webpack_require__) {
  1115. "use strict";
  1116. /*jshint node:true */
  1117. /*
  1118. The MIT License (MIT)
  1119. Copyright (c) 2007-2018 Einar Lielmanis, Liam Newman, and contributors.
  1120. Permission is hereby granted, free of charge, to any person
  1121. obtaining a copy of this software and associated documentation files
  1122. (the "Software"), to deal in the Software without restriction,
  1123. including without limitation the rights to use, copy, modify, merge,
  1124. publish, distribute, sublicense, and/or sell copies of the Software,
  1125. and to permit persons to whom the Software is furnished to do so,
  1126. subject to the following conditions:
  1127. The above copyright notice and this permission notice shall be
  1128. included in all copies or substantial portions of the Software.
  1129. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  1130. EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  1131. MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  1132. NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
  1133. BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
  1134. ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  1135. CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  1136. SOFTWARE.
  1137. */
  1138. var BaseOptions = __webpack_require__(6).Options;
  1139. function Options(options) {
  1140. BaseOptions.call(this, options, 'css');
  1141. this.selector_separator_newline = this._get_boolean('selector_separator_newline', true);
  1142. this.newline_between_rules = this._get_boolean('newline_between_rules', true);
  1143. var space_around_selector_separator = this._get_boolean('space_around_selector_separator');
  1144. this.space_around_combinator = this._get_boolean('space_around_combinator') || space_around_selector_separator;
  1145. }
  1146. Options.prototype = new BaseOptions();
  1147. module.exports.Options = Options;
  1148. /***/ })
  1149. /******/ ]);
  1150. var css_beautify = legacy_beautify_css;
  1151. /* Footer */
  1152. if (typeof define === "function" && define.amd) {
  1153. // Add support for AMD ( https://github.com/amdjs/amdjs-api/wiki/AMD#defineamd-property- )
  1154. define([], function() {
  1155. return {
  1156. css_beautify: css_beautify
  1157. };
  1158. });
  1159. } else if (typeof exports !== "undefined") {
  1160. // Add support for CommonJS. Just put this file somewhere on your require.paths
  1161. // and you will be able to `var html_beautify = require("beautify").html_beautify`.
  1162. exports.css_beautify = css_beautify;
  1163. } else if (typeof window !== "undefined") {
  1164. // If we're running a web page and don't have either of the above, add our one global
  1165. window.css_beautify = css_beautify;
  1166. } else if (typeof global !== "undefined") {
  1167. // If we don't even have window, try global.
  1168. global.css_beautify = css_beautify;
  1169. }
  1170. }());