beautify-css.js 44 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426
  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.get_indent_size(this.__indent_count, this.__alignment_count);
  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_size;
  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. result = this.__parent.get_indent_string(this.__indent_count, this.__alignment_count);
  244. result += this.__items.join('');
  245. }
  246. return result;
  247. };
  248. function IndentStringCache(options, baseIndentString) {
  249. this.__cache = [''];
  250. this.__indent_size = options.indent_size;
  251. this.__indent_string = options.indent_char;
  252. if (!options.indent_with_tabs) {
  253. this.__indent_string = new Array(options.indent_size + 1).join(options.indent_char);
  254. }
  255. // Set to null to continue support for auto detection of base indent
  256. baseIndentString = baseIndentString || '';
  257. if (options.indent_level > 0) {
  258. baseIndentString = new Array(options.indent_level + 1).join(this.__indent_string);
  259. }
  260. this.__base_string = baseIndentString;
  261. this.__base_string_length = baseIndentString.length;
  262. }
  263. IndentStringCache.prototype.get_indent_size = function(indent, column) {
  264. var result = this.__base_string_length;
  265. column = column || 0;
  266. if (indent < 0) {
  267. result = 0;
  268. }
  269. result += indent * this.__indent_size;
  270. result += column;
  271. return result;
  272. };
  273. IndentStringCache.prototype.get_indent_string = function(indent_level, column) {
  274. var result = this.__base_string;
  275. column = column || 0;
  276. if (indent_level < 0) {
  277. indent_level = 0;
  278. result = '';
  279. }
  280. column += indent_level * this.__indent_size;
  281. this.__ensure_cache(column);
  282. result += this.__cache[column];
  283. return result;
  284. };
  285. IndentStringCache.prototype.__ensure_cache = function(column) {
  286. while (column >= this.__cache.length) {
  287. this.__add_column();
  288. }
  289. };
  290. IndentStringCache.prototype.__add_column = function() {
  291. var column = this.__cache.length;
  292. var indent = 0;
  293. var result = '';
  294. if (this.__indent_size && column >= this.__indent_size) {
  295. indent = Math.floor(column / this.__indent_size);
  296. column -= indent * this.__indent_size;
  297. result = new Array(indent + 1).join(this.__indent_string);
  298. }
  299. if (column) {
  300. result += new Array(column + 1).join(' ');
  301. }
  302. this.__cache.push(result);
  303. };
  304. function Output(options, baseIndentString) {
  305. this.__indent_cache = new IndentStringCache(options, baseIndentString);
  306. this.raw = false;
  307. this._end_with_newline = options.end_with_newline;
  308. this.indent_size = options.indent_size;
  309. this.__lines = [];
  310. this.previous_line = null;
  311. this.current_line = null;
  312. this.space_before_token = false;
  313. // initialize
  314. this.__add_outputline();
  315. }
  316. Output.prototype.__add_outputline = function() {
  317. this.previous_line = this.current_line;
  318. this.current_line = new OutputLine(this);
  319. this.__lines.push(this.current_line);
  320. };
  321. Output.prototype.get_line_number = function() {
  322. return this.__lines.length;
  323. };
  324. Output.prototype.get_indent_string = function(indent, column) {
  325. return this.__indent_cache.get_indent_string(indent, column);
  326. };
  327. Output.prototype.get_indent_size = function(indent, column) {
  328. return this.__indent_cache.get_indent_size(indent, column);
  329. };
  330. Output.prototype.is_empty = function() {
  331. return !this.previous_line && this.current_line.is_empty();
  332. };
  333. Output.prototype.add_new_line = function(force_newline) {
  334. // never newline at the start of file
  335. // otherwise, newline only if we didn't just add one or we're forced
  336. if (this.is_empty() ||
  337. (!force_newline && this.just_added_newline())) {
  338. return false;
  339. }
  340. // if raw output is enabled, don't print additional newlines,
  341. // but still return True as though you had
  342. if (!this.raw) {
  343. this.__add_outputline();
  344. }
  345. return true;
  346. };
  347. Output.prototype.get_code = function(eol) {
  348. var sweet_code = this.__lines.join('\n').replace(/[\r\n\t ]+$/, '');
  349. if (this._end_with_newline) {
  350. sweet_code += '\n';
  351. }
  352. if (eol !== '\n') {
  353. sweet_code = sweet_code.replace(/[\n]/g, eol);
  354. }
  355. return sweet_code;
  356. };
  357. Output.prototype.set_indent = function(indent, alignment) {
  358. indent = indent || 0;
  359. alignment = alignment || 0;
  360. // Never indent your first output indent at the start of the file
  361. if (this.__lines.length > 1) {
  362. this.current_line.set_indent(indent, alignment);
  363. return true;
  364. }
  365. this.current_line.set_indent();
  366. return false;
  367. };
  368. Output.prototype.add_raw_token = function(token) {
  369. for (var x = 0; x < token.newlines; x++) {
  370. this.__add_outputline();
  371. }
  372. this.current_line.push(token.whitespace_before);
  373. this.current_line.push_raw(token.text);
  374. this.space_before_token = false;
  375. };
  376. Output.prototype.add_token = function(printable_token) {
  377. this.add_space_before_token();
  378. this.current_line.push(printable_token);
  379. };
  380. Output.prototype.add_space_before_token = function() {
  381. if (this.space_before_token && !this.just_added_newline()) {
  382. this.current_line.push(' ');
  383. }
  384. this.space_before_token = false;
  385. };
  386. Output.prototype.remove_indent = function(index) {
  387. var output_length = this.__lines.length;
  388. while (index < output_length) {
  389. this.__lines[index].remove_indent();
  390. index++;
  391. }
  392. };
  393. Output.prototype.trim = function(eat_newlines) {
  394. eat_newlines = (eat_newlines === undefined) ? false : eat_newlines;
  395. this.current_line.trim(this.indent_string, this.baseIndentString);
  396. while (eat_newlines && this.__lines.length > 1 &&
  397. this.current_line.is_empty()) {
  398. this.__lines.pop();
  399. this.current_line = this.__lines[this.__lines.length - 1];
  400. this.current_line.trim();
  401. }
  402. this.previous_line = this.__lines.length > 1 ?
  403. this.__lines[this.__lines.length - 2] : null;
  404. };
  405. Output.prototype.just_added_newline = function() {
  406. return this.current_line.is_empty();
  407. };
  408. Output.prototype.just_added_blankline = function() {
  409. return this.is_empty() ||
  410. (this.current_line.is_empty() && this.previous_line.is_empty());
  411. };
  412. Output.prototype.ensure_empty_line_above = function(starts_with, ends_with) {
  413. var index = this.__lines.length - 2;
  414. while (index >= 0) {
  415. var potentialEmptyLine = this.__lines[index];
  416. if (potentialEmptyLine.is_empty()) {
  417. break;
  418. } else if (potentialEmptyLine.item(0).indexOf(starts_with) !== 0 &&
  419. potentialEmptyLine.item(-1) !== ends_with) {
  420. this.__lines.splice(index + 1, 0, new OutputLine(this));
  421. this.previous_line = this.__lines[this.__lines.length - 2];
  422. break;
  423. }
  424. index--;
  425. }
  426. };
  427. module.exports.Output = Output;
  428. /***/ }),
  429. /* 3 */,
  430. /* 4 */,
  431. /* 5 */,
  432. /* 6 */
  433. /***/ (function(module, exports, __webpack_require__) {
  434. "use strict";
  435. /*jshint node:true */
  436. /*
  437. The MIT License (MIT)
  438. Copyright (c) 2007-2018 Einar Lielmanis, Liam Newman, and contributors.
  439. Permission is hereby granted, free of charge, to any person
  440. obtaining a copy of this software and associated documentation files
  441. (the "Software"), to deal in the Software without restriction,
  442. including without limitation the rights to use, copy, modify, merge,
  443. publish, distribute, sublicense, and/or sell copies of the Software,
  444. and to permit persons to whom the Software is furnished to do so,
  445. subject to the following conditions:
  446. The above copyright notice and this permission notice shall be
  447. included in all copies or substantial portions of the Software.
  448. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  449. EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  450. MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  451. NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
  452. BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
  453. ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  454. CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  455. SOFTWARE.
  456. */
  457. function Options(options, merge_child_field) {
  458. this.raw_options = _mergeOpts(options, merge_child_field);
  459. // Support passing the source text back with no change
  460. this.disabled = this._get_boolean('disabled');
  461. this.eol = this._get_characters('eol', 'auto');
  462. this.end_with_newline = this._get_boolean('end_with_newline');
  463. this.indent_size = this._get_number('indent_size', 4);
  464. this.indent_char = this._get_characters('indent_char', ' ');
  465. this.indent_level = this._get_number('indent_level');
  466. this.preserve_newlines = this._get_boolean('preserve_newlines', true);
  467. this.max_preserve_newlines = this._get_number('max_preserve_newlines', 32786);
  468. if (!this.preserve_newlines) {
  469. this.max_preserve_newlines = 0;
  470. }
  471. this.indent_with_tabs = this._get_boolean('indent_with_tabs', this.indent_char === '\t');
  472. if (this.indent_with_tabs) {
  473. this.indent_char = '\t';
  474. // indent_size behavior changed after 1.8.6
  475. // It used to be that indent_size would be
  476. // set to 1 for indent_with_tabs. That is no longer needed and
  477. // actually doesn't make sense - why not use spaces? Further,
  478. // that might produce unexpected behavior - tabs being used
  479. // for single-column alignment. So, when indent_with_tabs is true
  480. // and indent_size is 1, reset indent_size to 4.
  481. if (this.indent_size === 1) {
  482. this.indent_size = 4;
  483. }
  484. }
  485. // Backwards compat with 1.3.x
  486. this.wrap_line_length = this._get_number('wrap_line_length', this._get_number('max_char'));
  487. }
  488. Options.prototype._get_array = function(name, default_value) {
  489. var option_value = this.raw_options[name];
  490. var result = default_value || [];
  491. if (typeof option_value === 'object') {
  492. if (option_value !== null && typeof option_value.concat === 'function') {
  493. result = option_value.concat();
  494. }
  495. } else if (typeof option_value === 'string') {
  496. result = option_value.split(/[^a-zA-Z0-9_\/\-]+/);
  497. }
  498. return result;
  499. };
  500. Options.prototype._get_boolean = function(name, default_value) {
  501. var option_value = this.raw_options[name];
  502. var result = option_value === undefined ? !!default_value : !!option_value;
  503. return result;
  504. };
  505. Options.prototype._get_characters = function(name, default_value) {
  506. var option_value = this.raw_options[name];
  507. var result = default_value || '';
  508. if (typeof option_value === 'string') {
  509. result = option_value.replace(/\\r/, '\r').replace(/\\n/, '\n').replace(/\\t/, '\t');
  510. }
  511. return result;
  512. };
  513. Options.prototype._get_number = function(name, default_value) {
  514. var option_value = this.raw_options[name];
  515. default_value = parseInt(default_value, 10);
  516. if (isNaN(default_value)) {
  517. default_value = 0;
  518. }
  519. var result = parseInt(option_value, 10);
  520. if (isNaN(result)) {
  521. result = default_value;
  522. }
  523. return result;
  524. };
  525. Options.prototype._get_selection = function(name, selection_list, default_value) {
  526. var result = this._get_selection_list(name, selection_list, default_value);
  527. if (result.length !== 1) {
  528. throw new Error(
  529. "Invalid Option Value: The option '" + name + "' can only be one of the following values:\n" +
  530. selection_list + "\nYou passed in: '" + this.raw_options[name] + "'");
  531. }
  532. return result[0];
  533. };
  534. Options.prototype._get_selection_list = function(name, selection_list, default_value) {
  535. if (!selection_list || selection_list.length === 0) {
  536. throw new Error("Selection list cannot be empty.");
  537. }
  538. default_value = default_value || [selection_list[0]];
  539. if (!this._is_valid_selection(default_value, selection_list)) {
  540. throw new Error("Invalid Default Value!");
  541. }
  542. var result = this._get_array(name, default_value);
  543. if (!this._is_valid_selection(result, selection_list)) {
  544. throw new Error(
  545. "Invalid Option Value: The option '" + name + "' can contain only the following values:\n" +
  546. selection_list + "\nYou passed in: '" + this.raw_options[name] + "'");
  547. }
  548. return result;
  549. };
  550. Options.prototype._is_valid_selection = function(result, selection_list) {
  551. return result.length && selection_list.length &&
  552. !result.some(function(item) { return selection_list.indexOf(item) === -1; });
  553. };
  554. // merges child options up with the parent options object
  555. // Example: obj = {a: 1, b: {a: 2}}
  556. // mergeOpts(obj, 'b')
  557. //
  558. // Returns: {a: 2}
  559. function _mergeOpts(allOptions, childFieldName) {
  560. var finalOpts = {};
  561. allOptions = _normalizeOpts(allOptions);
  562. var name;
  563. for (name in allOptions) {
  564. if (name !== childFieldName) {
  565. finalOpts[name] = allOptions[name];
  566. }
  567. }
  568. //merge in the per type settings for the childFieldName
  569. if (childFieldName && allOptions[childFieldName]) {
  570. for (name in allOptions[childFieldName]) {
  571. finalOpts[name] = allOptions[childFieldName][name];
  572. }
  573. }
  574. return finalOpts;
  575. }
  576. function _normalizeOpts(options) {
  577. var convertedOpts = {};
  578. var key;
  579. for (key in options) {
  580. var newKey = key.replace(/-/g, "_");
  581. convertedOpts[newKey] = options[key];
  582. }
  583. return convertedOpts;
  584. }
  585. module.exports.Options = Options;
  586. module.exports.normalizeOpts = _normalizeOpts;
  587. module.exports.mergeOpts = _mergeOpts;
  588. /***/ }),
  589. /* 7 */,
  590. /* 8 */
  591. /***/ (function(module, exports, __webpack_require__) {
  592. "use strict";
  593. /*jshint node:true */
  594. /*
  595. The MIT License (MIT)
  596. Copyright (c) 2007-2018 Einar Lielmanis, Liam Newman, and contributors.
  597. Permission is hereby granted, free of charge, to any person
  598. obtaining a copy of this software and associated documentation files
  599. (the "Software"), to deal in the Software without restriction,
  600. including without limitation the rights to use, copy, modify, merge,
  601. publish, distribute, sublicense, and/or sell copies of the Software,
  602. and to permit persons to whom the Software is furnished to do so,
  603. subject to the following conditions:
  604. The above copyright notice and this permission notice shall be
  605. included in all copies or substantial portions of the Software.
  606. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  607. EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  608. MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  609. NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
  610. BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
  611. ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  612. CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  613. SOFTWARE.
  614. */
  615. function InputScanner(input_string) {
  616. this.__input = input_string || '';
  617. this.__input_length = this.__input.length;
  618. this.__position = 0;
  619. }
  620. InputScanner.prototype.restart = function() {
  621. this.__position = 0;
  622. };
  623. InputScanner.prototype.back = function() {
  624. if (this.__position > 0) {
  625. this.__position -= 1;
  626. }
  627. };
  628. InputScanner.prototype.hasNext = function() {
  629. return this.__position < this.__input_length;
  630. };
  631. InputScanner.prototype.next = function() {
  632. var val = null;
  633. if (this.hasNext()) {
  634. val = this.__input.charAt(this.__position);
  635. this.__position += 1;
  636. }
  637. return val;
  638. };
  639. InputScanner.prototype.peek = function(index) {
  640. var val = null;
  641. index = index || 0;
  642. index += this.__position;
  643. if (index >= 0 && index < this.__input_length) {
  644. val = this.__input.charAt(index);
  645. }
  646. return val;
  647. };
  648. InputScanner.prototype.test = function(pattern, index) {
  649. index = index || 0;
  650. index += this.__position;
  651. pattern.lastIndex = index;
  652. if (index >= 0 && index < this.__input_length) {
  653. var pattern_match = pattern.exec(this.__input);
  654. return pattern_match && pattern_match.index === index;
  655. } else {
  656. return false;
  657. }
  658. };
  659. InputScanner.prototype.testChar = function(pattern, index) {
  660. // test one character regex match
  661. var val = this.peek(index);
  662. return val !== null && pattern.test(val);
  663. };
  664. InputScanner.prototype.match = function(pattern) {
  665. pattern.lastIndex = this.__position;
  666. var pattern_match = pattern.exec(this.__input);
  667. if (pattern_match && pattern_match.index === this.__position) {
  668. this.__position += pattern_match[0].length;
  669. } else {
  670. pattern_match = null;
  671. }
  672. return pattern_match;
  673. };
  674. InputScanner.prototype.read = function(pattern) {
  675. var val = '';
  676. var match = this.match(pattern);
  677. if (match) {
  678. val = match[0];
  679. }
  680. return val;
  681. };
  682. InputScanner.prototype.readUntil = function(pattern, include_match) {
  683. var val = '';
  684. var match_index = this.__position;
  685. pattern.lastIndex = this.__position;
  686. var pattern_match = pattern.exec(this.__input);
  687. if (pattern_match) {
  688. if (include_match) {
  689. match_index = pattern_match.index + pattern_match[0].length;
  690. } else {
  691. match_index = pattern_match.index;
  692. }
  693. } else {
  694. match_index = this.__input_length;
  695. }
  696. val = this.__input.substring(this.__position, match_index);
  697. this.__position = match_index;
  698. return val;
  699. };
  700. InputScanner.prototype.readUntilAfter = function(pattern) {
  701. return this.readUntil(pattern, true);
  702. };
  703. /* css beautifier legacy helpers */
  704. InputScanner.prototype.peekUntilAfter = function(pattern) {
  705. var start = this.__position;
  706. var val = this.readUntilAfter(pattern);
  707. this.__position = start;
  708. return val;
  709. };
  710. InputScanner.prototype.lookBack = function(testVal) {
  711. var start = this.__position - 1;
  712. return start >= testVal.length && this.__input.substring(start - testVal.length, start)
  713. .toLowerCase() === testVal;
  714. };
  715. module.exports.InputScanner = InputScanner;
  716. /***/ }),
  717. /* 9 */,
  718. /* 10 */,
  719. /* 11 */,
  720. /* 12 */
  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 Beautifier = __webpack_require__(13).Beautifier,
  746. Options = __webpack_require__(14).Options;
  747. function css_beautify(source_text, options) {
  748. var beautifier = new Beautifier(source_text, options);
  749. return beautifier.beautify();
  750. }
  751. module.exports = css_beautify;
  752. module.exports.defaultOptions = function() {
  753. return new Options();
  754. };
  755. /***/ }),
  756. /* 13 */
  757. /***/ (function(module, exports, __webpack_require__) {
  758. "use strict";
  759. /*jshint node:true */
  760. /*
  761. The MIT License (MIT)
  762. Copyright (c) 2007-2018 Einar Lielmanis, Liam Newman, and contributors.
  763. Permission is hereby granted, free of charge, to any person
  764. obtaining a copy of this software and associated documentation files
  765. (the "Software"), to deal in the Software without restriction,
  766. including without limitation the rights to use, copy, modify, merge,
  767. publish, distribute, sublicense, and/or sell copies of the Software,
  768. and to permit persons to whom the Software is furnished to do so,
  769. subject to the following conditions:
  770. The above copyright notice and this permission notice shall be
  771. included in all copies or substantial portions of the Software.
  772. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  773. EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  774. MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  775. NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
  776. BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
  777. ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  778. CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  779. SOFTWARE.
  780. */
  781. var Options = __webpack_require__(14).Options;
  782. var Output = __webpack_require__(2).Output;
  783. var InputScanner = __webpack_require__(8).InputScanner;
  784. var lineBreak = /\r\n|[\r\n]/;
  785. var allLineBreaks = /\r\n|[\r\n]/g;
  786. // tokenizer
  787. var whitespaceChar = /\s/;
  788. var whitespacePattern = /(?:\s|\n)+/g;
  789. var block_comment_pattern = /\/\*(?:[\s\S]*?)((?:\*\/)|$)/g;
  790. var comment_pattern = /\/\/(?:[^\n\r\u2028\u2029]*)/g;
  791. function Beautifier(source_text, options) {
  792. this._source_text = source_text || '';
  793. // Allow the setting of language/file-type specific options
  794. // with inheritance of overall settings
  795. this._options = new Options(options);
  796. this._ch = null;
  797. this._input = null;
  798. // https://developer.mozilla.org/en-US/docs/Web/CSS/At-rule
  799. this.NESTED_AT_RULE = {
  800. "@page": true,
  801. "@font-face": true,
  802. "@keyframes": true,
  803. // also in CONDITIONAL_GROUP_RULE below
  804. "@media": true,
  805. "@supports": true,
  806. "@document": true
  807. };
  808. this.CONDITIONAL_GROUP_RULE = {
  809. "@media": true,
  810. "@supports": true,
  811. "@document": true
  812. };
  813. }
  814. Beautifier.prototype.eatString = function(endChars) {
  815. var result = '';
  816. this._ch = this._input.next();
  817. while (this._ch) {
  818. result += this._ch;
  819. if (this._ch === "\\") {
  820. result += this._input.next();
  821. } else if (endChars.indexOf(this._ch) !== -1 || this._ch === "\n") {
  822. break;
  823. }
  824. this._ch = this._input.next();
  825. }
  826. return result;
  827. };
  828. // Skips any white space in the source text from the current position.
  829. // When allowAtLeastOneNewLine is true, will output new lines for each
  830. // newline character found; if the user has preserve_newlines off, only
  831. // the first newline will be output
  832. Beautifier.prototype.eatWhitespace = function(allowAtLeastOneNewLine) {
  833. var result = whitespaceChar.test(this._input.peek());
  834. var isFirstNewLine = true;
  835. while (whitespaceChar.test(this._input.peek())) {
  836. this._ch = this._input.next();
  837. if (allowAtLeastOneNewLine && this._ch === '\n') {
  838. if (this._options.preserve_newlines || isFirstNewLine) {
  839. isFirstNewLine = false;
  840. this._output.add_new_line(true);
  841. }
  842. }
  843. }
  844. return result;
  845. };
  846. // Nested pseudo-class if we are insideRule
  847. // and the next special character found opens
  848. // a new block
  849. Beautifier.prototype.foundNestedPseudoClass = function() {
  850. var openParen = 0;
  851. var i = 1;
  852. var ch = this._input.peek(i);
  853. while (ch) {
  854. if (ch === "{") {
  855. return true;
  856. } else if (ch === '(') {
  857. // pseudoclasses can contain ()
  858. openParen += 1;
  859. } else if (ch === ')') {
  860. if (openParen === 0) {
  861. return false;
  862. }
  863. openParen -= 1;
  864. } else if (ch === ";" || ch === "}") {
  865. return false;
  866. }
  867. i++;
  868. ch = this._input.peek(i);
  869. }
  870. return false;
  871. };
  872. Beautifier.prototype.print_string = function(output_string) {
  873. if (this._output.just_added_newline()) {
  874. this._output.set_indent(this._indentLevel);
  875. }
  876. this._output.add_token(output_string);
  877. };
  878. Beautifier.prototype.preserveSingleSpace = function(isAfterSpace) {
  879. if (isAfterSpace) {
  880. this._output.space_before_token = true;
  881. }
  882. };
  883. Beautifier.prototype.indent = function() {
  884. this._indentLevel++;
  885. };
  886. Beautifier.prototype.outdent = function() {
  887. if (this._indentLevel > 0) {
  888. this._indentLevel--;
  889. }
  890. };
  891. /*_____________________--------------------_____________________*/
  892. Beautifier.prototype.beautify = function() {
  893. if (this._options.disabled) {
  894. return this._source_text;
  895. }
  896. var source_text = this._source_text;
  897. var eol = this._options.eol;
  898. if (eol === 'auto') {
  899. eol = '\n';
  900. if (source_text && lineBreak.test(source_text || '')) {
  901. eol = source_text.match(lineBreak)[0];
  902. }
  903. }
  904. // HACK: newline parsing inconsistent. This brute force normalizes the this._input.
  905. source_text = source_text.replace(allLineBreaks, '\n');
  906. // reset
  907. var baseIndentString = source_text.match(/^[\t ]*/)[0];
  908. this._output = new Output(this._options, baseIndentString);
  909. this._input = new InputScanner(source_text);
  910. this._indentLevel = 0;
  911. this._nestedLevel = 0;
  912. this._ch = null;
  913. var parenLevel = 0;
  914. var insideRule = false;
  915. // This is the value side of a property value pair (blue in the following ex)
  916. // label { content: blue }
  917. var insidePropertyValue = false;
  918. var enteringConditionalGroup = false;
  919. var insideAtExtend = false;
  920. var insideAtImport = false;
  921. var topCharacter = this._ch;
  922. while (true) {
  923. var whitespace = this._input.read(whitespacePattern);
  924. var isAfterSpace = whitespace !== '';
  925. var previous_ch = topCharacter;
  926. this._ch = this._input.next();
  927. topCharacter = this._ch;
  928. if (!this._ch) {
  929. break;
  930. } else if (this._ch === '/' && this._input.peek() === '*') {
  931. // /* css comment */
  932. // Always start block comments on a new line.
  933. // This handles scenarios where a block comment immediately
  934. // follows a property definition on the same line or where
  935. // minified code is being beautified.
  936. this._output.add_new_line();
  937. this._input.back();
  938. this.print_string(this._input.read(block_comment_pattern));
  939. // Ensures any new lines following the comment are preserved
  940. this.eatWhitespace(true);
  941. // Block comments are followed by a new line so they don't
  942. // share a line with other properties
  943. this._output.add_new_line();
  944. } else if (this._ch === '/' && this._input.peek() === '/') {
  945. // // single line comment
  946. // Preserves the space before a comment
  947. // on the same line as a rule
  948. this._output.space_before_token = true;
  949. this._input.back();
  950. this.print_string(this._input.read(comment_pattern));
  951. // Ensures any new lines following the comment are preserved
  952. this.eatWhitespace(true);
  953. } else if (this._ch === '@') {
  954. this.preserveSingleSpace(isAfterSpace);
  955. // deal with less propery mixins @{...}
  956. if (this._input.peek() === '{') {
  957. this.print_string(this._ch + this.eatString('}'));
  958. } else {
  959. this.print_string(this._ch);
  960. // strip trailing space, if present, for hash property checks
  961. var variableOrRule = this._input.peekUntilAfter(/[: ,;{}()[\]\/='"]/g);
  962. if (variableOrRule.match(/[ :]$/)) {
  963. // we have a variable or pseudo-class, add it and insert one space before continuing
  964. variableOrRule = this.eatString(": ").replace(/\s$/, '');
  965. this.print_string(variableOrRule);
  966. this._output.space_before_token = true;
  967. }
  968. variableOrRule = variableOrRule.replace(/\s$/, '');
  969. if (variableOrRule === 'extend') {
  970. insideAtExtend = true;
  971. } else if (variableOrRule === 'import') {
  972. insideAtImport = true;
  973. }
  974. // might be a nesting at-rule
  975. if (variableOrRule in this.NESTED_AT_RULE) {
  976. this._nestedLevel += 1;
  977. if (variableOrRule in this.CONDITIONAL_GROUP_RULE) {
  978. enteringConditionalGroup = true;
  979. }
  980. // might be less variable
  981. } else if (!insideRule && parenLevel === 0 && variableOrRule.indexOf(':') !== -1) {
  982. insidePropertyValue = true;
  983. this.indent();
  984. }
  985. }
  986. } else if (this._ch === '#' && this._input.peek() === '{') {
  987. this.preserveSingleSpace(isAfterSpace);
  988. this.print_string(this._ch + this.eatString('}'));
  989. } else if (this._ch === '{') {
  990. if (insidePropertyValue) {
  991. insidePropertyValue = false;
  992. this.outdent();
  993. }
  994. this.indent();
  995. this._output.space_before_token = true;
  996. this.print_string(this._ch);
  997. // when entering conditional groups, only rulesets are allowed
  998. if (enteringConditionalGroup) {
  999. enteringConditionalGroup = false;
  1000. insideRule = (this._indentLevel > this._nestedLevel);
  1001. } else {
  1002. // otherwise, declarations are also allowed
  1003. insideRule = (this._indentLevel >= this._nestedLevel);
  1004. }
  1005. if (this._options.newline_between_rules && insideRule) {
  1006. if (this._output.previous_line && this._output.previous_line.item(-1) !== '{') {
  1007. this._output.ensure_empty_line_above('/', ',');
  1008. }
  1009. }
  1010. this.eatWhitespace(true);
  1011. this._output.add_new_line();
  1012. } else if (this._ch === '}') {
  1013. this.outdent();
  1014. this._output.add_new_line();
  1015. if (previous_ch === '{') {
  1016. this._output.trim(true);
  1017. }
  1018. insideAtImport = false;
  1019. insideAtExtend = false;
  1020. if (insidePropertyValue) {
  1021. this.outdent();
  1022. insidePropertyValue = false;
  1023. }
  1024. this.print_string(this._ch);
  1025. insideRule = false;
  1026. if (this._nestedLevel) {
  1027. this._nestedLevel--;
  1028. }
  1029. this.eatWhitespace(true);
  1030. this._output.add_new_line();
  1031. if (this._options.newline_between_rules && !this._output.just_added_blankline()) {
  1032. if (this._input.peek() !== '}') {
  1033. this._output.add_new_line(true);
  1034. }
  1035. }
  1036. } else if (this._ch === ":") {
  1037. if ((insideRule || enteringConditionalGroup) && !(this._input.lookBack("&") || this.foundNestedPseudoClass()) && !this._input.lookBack("(") && !insideAtExtend) {
  1038. // 'property: value' delimiter
  1039. // which could be in a conditional group query
  1040. this.print_string(':');
  1041. if (!insidePropertyValue) {
  1042. insidePropertyValue = true;
  1043. this._output.space_before_token = true;
  1044. this.eatWhitespace(true);
  1045. this.indent();
  1046. }
  1047. } else {
  1048. // sass/less parent reference don't use a space
  1049. // sass nested pseudo-class don't use a space
  1050. // preserve space before pseudoclasses/pseudoelements, as it means "in any child"
  1051. if (this._input.lookBack(" ")) {
  1052. this._output.space_before_token = true;
  1053. }
  1054. if (this._input.peek() === ":") {
  1055. // pseudo-element
  1056. this._ch = this._input.next();
  1057. this.print_string("::");
  1058. } else {
  1059. // pseudo-class
  1060. this.print_string(':');
  1061. }
  1062. }
  1063. } else if (this._ch === '"' || this._ch === '\'') {
  1064. this.preserveSingleSpace(isAfterSpace);
  1065. this.print_string(this._ch + this.eatString(this._ch));
  1066. this.eatWhitespace(true);
  1067. } else if (this._ch === ';') {
  1068. if (insidePropertyValue) {
  1069. this.outdent();
  1070. insidePropertyValue = false;
  1071. }
  1072. insideAtExtend = false;
  1073. insideAtImport = false;
  1074. this.print_string(this._ch);
  1075. this.eatWhitespace(true);
  1076. // This maintains single line comments on the same
  1077. // line. Block comments are also affected, but
  1078. // a new line is always output before one inside
  1079. // that section
  1080. if (this._input.peek() !== '/') {
  1081. this._output.add_new_line();
  1082. }
  1083. } else if (this._ch === '(') { // may be a url
  1084. if (this._input.lookBack("url")) {
  1085. this.print_string(this._ch);
  1086. this.eatWhitespace();
  1087. this._ch = this._input.next();
  1088. if (this._ch === ')' || this._ch === '"' || this._ch === '\'') {
  1089. this._input.back();
  1090. parenLevel++;
  1091. } else if (this._ch) {
  1092. this.print_string(this._ch + this.eatString(')'));
  1093. }
  1094. } else {
  1095. parenLevel++;
  1096. this.preserveSingleSpace(isAfterSpace);
  1097. this.print_string(this._ch);
  1098. this.eatWhitespace();
  1099. }
  1100. } else if (this._ch === ')') {
  1101. this.print_string(this._ch);
  1102. parenLevel--;
  1103. } else if (this._ch === ',') {
  1104. this.print_string(this._ch);
  1105. this.eatWhitespace(true);
  1106. if (this._options.selector_separator_newline && !insidePropertyValue && parenLevel < 1 && !insideAtImport) {
  1107. this._output.add_new_line();
  1108. } else {
  1109. this._output.space_before_token = true;
  1110. }
  1111. } else if ((this._ch === '>' || this._ch === '+' || this._ch === '~') && !insidePropertyValue && parenLevel < 1) {
  1112. //handle combinator spacing
  1113. if (this._options.space_around_combinator) {
  1114. this._output.space_before_token = true;
  1115. this.print_string(this._ch);
  1116. this._output.space_before_token = true;
  1117. } else {
  1118. this.print_string(this._ch);
  1119. this.eatWhitespace();
  1120. // squash extra whitespace
  1121. if (this._ch && whitespaceChar.test(this._ch)) {
  1122. this._ch = '';
  1123. }
  1124. }
  1125. } else if (this._ch === ']') {
  1126. this.print_string(this._ch);
  1127. } else if (this._ch === '[') {
  1128. this.preserveSingleSpace(isAfterSpace);
  1129. this.print_string(this._ch);
  1130. } else if (this._ch === '=') { // no whitespace before or after
  1131. this.eatWhitespace();
  1132. this.print_string('=');
  1133. if (whitespaceChar.test(this._ch)) {
  1134. this._ch = '';
  1135. }
  1136. } else if (this._ch === '!') { // !important
  1137. this.print_string(' ');
  1138. this.print_string(this._ch);
  1139. } else {
  1140. this.preserveSingleSpace(isAfterSpace);
  1141. this.print_string(this._ch);
  1142. }
  1143. }
  1144. var sweetCode = this._output.get_code(eol);
  1145. return sweetCode;
  1146. };
  1147. module.exports.Beautifier = Beautifier;
  1148. /***/ }),
  1149. /* 14 */
  1150. /***/ (function(module, exports, __webpack_require__) {
  1151. "use strict";
  1152. /*jshint node:true */
  1153. /*
  1154. The MIT License (MIT)
  1155. Copyright (c) 2007-2018 Einar Lielmanis, Liam Newman, and contributors.
  1156. Permission is hereby granted, free of charge, to any person
  1157. obtaining a copy of this software and associated documentation files
  1158. (the "Software"), to deal in the Software without restriction,
  1159. including without limitation the rights to use, copy, modify, merge,
  1160. publish, distribute, sublicense, and/or sell copies of the Software,
  1161. and to permit persons to whom the Software is furnished to do so,
  1162. subject to the following conditions:
  1163. The above copyright notice and this permission notice shall be
  1164. included in all copies or substantial portions of the Software.
  1165. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  1166. EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  1167. MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  1168. NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
  1169. BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
  1170. ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  1171. CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  1172. SOFTWARE.
  1173. */
  1174. var BaseOptions = __webpack_require__(6).Options;
  1175. function Options(options) {
  1176. BaseOptions.call(this, options, 'css');
  1177. this.selector_separator_newline = this._get_boolean('selector_separator_newline', true);
  1178. this.newline_between_rules = this._get_boolean('newline_between_rules', true);
  1179. var space_around_selector_separator = this._get_boolean('space_around_selector_separator');
  1180. this.space_around_combinator = this._get_boolean('space_around_combinator') || space_around_selector_separator;
  1181. }
  1182. Options.prototype = new BaseOptions();
  1183. module.exports.Options = Options;
  1184. /***/ })
  1185. /******/ ]);
  1186. var css_beautify = legacy_beautify_css;
  1187. /* Footer */
  1188. if (typeof define === "function" && define.amd) {
  1189. // Add support for AMD ( https://github.com/amdjs/amdjs-api/wiki/AMD#defineamd-property- )
  1190. define([], function() {
  1191. return {
  1192. css_beautify: css_beautify
  1193. };
  1194. });
  1195. } else if (typeof exports !== "undefined") {
  1196. // Add support for CommonJS. Just put this file somewhere on your require.paths
  1197. // and you will be able to `var html_beautify = require("beautify").html_beautify`.
  1198. exports.css_beautify = css_beautify;
  1199. } else if (typeof window !== "undefined") {
  1200. // If we're running a web page and don't have either of the above, add our one global
  1201. window.css_beautify = css_beautify;
  1202. } else if (typeof global !== "undefined") {
  1203. // If we don't even have window, try global.
  1204. global.css_beautify = css_beautify;
  1205. }
  1206. }());