beautify-css.js 44 KB

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