js-beautify 1.7.0 → 1.7.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. package/CHANGELOG.md +27 -0
  2. package/CONTRIBUTING.md +3 -3
  3. package/README.md +15 -12
  4. package/js/bin/css-beautify.js +4 -0
  5. package/js/bin/html-beautify.js +4 -0
  6. package/js/bin/js-beautify.js +4 -0
  7. package/js/config/defaults.json +18 -0
  8. package/js/lib/beautify-css.js +1046 -0
  9. package/js/lib/beautify-html.js +1387 -0
  10. package/js/lib/beautify.js +2820 -0
  11. package/js/lib/cli.js +623 -0
  12. package/js/lib/unpackers/javascriptobfuscator_unpacker.js +103 -0
  13. package/js/lib/unpackers/myobfuscate_unpacker.js +90 -0
  14. package/js/lib/unpackers/p_a_c_k_e_r_unpacker.js +83 -0
  15. package/js/lib/unpackers/urlencode_unpacker.js +73 -0
  16. package/js/src/core/acorn.js +63 -0
  17. package/js/src/core/inputscanner.js +95 -0
  18. package/js/src/core/options.js +48 -0
  19. package/js/src/core/output.js +234 -0
  20. package/js/src/core/token.js +49 -0
  21. package/js/src/css/beautifier.js +477 -0
  22. package/js/src/css/index.js +36 -0
  23. package/js/src/html/beautifier.js +1035 -0
  24. package/js/src/html/index.js +36 -0
  25. package/js/src/index.js +27 -0
  26. package/js/src/javascript/beautifier.js +1449 -0
  27. package/js/src/javascript/index.js +36 -0
  28. package/js/src/javascript/tokenizer.js +620 -0
  29. package/js/test/amd-beautify-tests.js +62 -0
  30. package/js/test/generated/beautify-css-tests.js +1393 -0
  31. package/js/test/generated/beautify-html-tests.js +3212 -0
  32. package/js/test/generated/beautify-javascript-tests.js +5896 -0
  33. package/js/test/node-beautify-html-perf-tests.js +51 -0
  34. package/js/test/node-beautify-perf-tests.js +50 -0
  35. package/js/test/node-beautify-tests.js +45 -0
  36. package/js/test/requirejs-html-beautify.html +58 -0
  37. package/js/test/resources/configerror/.jsbeautifyrc +6 -0
  38. package/js/test/resources/configerror/subDir1/subDir2/empty.txt +0 -0
  39. package/js/test/resources/editorconfig/.editorconfig +6 -0
  40. package/js/test/resources/editorconfig/cr/.editorconfig +3 -0
  41. package/js/test/resources/editorconfig/crlf/.editorconfig +3 -0
  42. package/js/test/resources/editorconfig/error/.editorconfig +1 -0
  43. package/js/test/resources/editorconfig/example-base.js +3 -0
  44. package/js/test/resources/example1.js +3 -0
  45. package/js/test/resources/indent11chars/.jsbeautifyrc +6 -0
  46. package/js/test/resources/indent11chars/subDir1/subDir2/empty.txt +0 -0
  47. package/js/test/run-tests +17 -0
  48. package/js/test/sanitytest.js +144 -0
  49. package/js/test/shell-smoke-test.sh +383 -0
  50. package/package.json +1 -1
@@ -0,0 +1,1046 @@
1
+ /*jshint curly:false, eqeqeq:true, laxbreak:true, noempty:false */
2
+ /* AUTO-GENERATED. DO NOT MODIFY. */
3
+ /*
4
+
5
+ The MIT License (MIT)
6
+
7
+ Copyright (c) 2007-2017 Einar Lielmanis, Liam Newman, and contributors.
8
+
9
+ Permission is hereby granted, free of charge, to any person
10
+ obtaining a copy of this software and associated documentation files
11
+ (the "Software"), to deal in the Software without restriction,
12
+ including without limitation the rights to use, copy, modify, merge,
13
+ publish, distribute, sublicense, and/or sell copies of the Software,
14
+ and to permit persons to whom the Software is furnished to do so,
15
+ subject to the following conditions:
16
+
17
+ The above copyright notice and this permission notice shall be
18
+ included in all copies or substantial portions of the Software.
19
+
20
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
23
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
24
+ BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
25
+ ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
26
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
27
+ SOFTWARE.
28
+
29
+
30
+ CSS Beautifier
31
+ ---------------
32
+
33
+ Written by Harutyun Amirjanyan, (amirjanyan@gmail.com)
34
+
35
+ Based on code initially developed by: Einar Lielmanis, <einar@jsbeautifier.org>
36
+ http://jsbeautifier.org/
37
+
38
+ Usage:
39
+ css_beautify(source_text);
40
+ css_beautify(source_text, options);
41
+
42
+ The options are (default in brackets):
43
+ indent_size (4) — indentation size,
44
+ indent_char (space) — character to indent with,
45
+ selector_separator_newline (true) - separate selectors with newline or
46
+ not (e.g. "a,\nbr" or "a, br")
47
+ end_with_newline (false) - end with a newline
48
+ newline_between_rules (true) - add a new line after every css rule
49
+ space_around_selector_separator (false) - ensure space around selector separators:
50
+ '>', '+', '~' (e.g. "a>b" -> "a > b")
51
+ e.g
52
+
53
+ css_beautify(css_source_text, {
54
+ 'indent_size': 1,
55
+ 'indent_char': '\t',
56
+ 'selector_separator': ' ',
57
+ 'end_with_newline': false,
58
+ 'newline_between_rules': true,
59
+ 'space_around_selector_separator': true
60
+ });
61
+ */
62
+
63
+ // http://www.w3.org/TR/CSS21/syndata.html#tokenization
64
+ // http://www.w3.org/TR/css3-syntax/
65
+
66
+ (function() {
67
+ var legacy_beautify_css =
68
+ /******/ (function(modules) { // webpackBootstrap
69
+ /******/ // The module cache
70
+ /******/ var installedModules = {};
71
+ /******/
72
+ /******/ // The require function
73
+ /******/ function __webpack_require__(moduleId) {
74
+ /******/
75
+ /******/ // Check if module is in cache
76
+ /******/ if(installedModules[moduleId]) {
77
+ /******/ return installedModules[moduleId].exports;
78
+ /******/ }
79
+ /******/ // Create a new module (and put it into the cache)
80
+ /******/ var module = installedModules[moduleId] = {
81
+ /******/ i: moduleId,
82
+ /******/ l: false,
83
+ /******/ exports: {}
84
+ /******/ };
85
+ /******/
86
+ /******/ // Execute the module function
87
+ /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
88
+ /******/
89
+ /******/ // Flag the module as loaded
90
+ /******/ module.l = true;
91
+ /******/
92
+ /******/ // Return the exports of the module
93
+ /******/ return module.exports;
94
+ /******/ }
95
+ /******/
96
+ /******/
97
+ /******/ // expose the modules object (__webpack_modules__)
98
+ /******/ __webpack_require__.m = modules;
99
+ /******/
100
+ /******/ // expose the module cache
101
+ /******/ __webpack_require__.c = installedModules;
102
+ /******/
103
+ /******/ // identity function for calling harmony imports with the correct context
104
+ /******/ __webpack_require__.i = function(value) { return value; };
105
+ /******/
106
+ /******/ // define getter function for harmony exports
107
+ /******/ __webpack_require__.d = function(exports, name, getter) {
108
+ /******/ if(!__webpack_require__.o(exports, name)) {
109
+ /******/ Object.defineProperty(exports, name, {
110
+ /******/ configurable: false,
111
+ /******/ enumerable: true,
112
+ /******/ get: getter
113
+ /******/ });
114
+ /******/ }
115
+ /******/ };
116
+ /******/
117
+ /******/ // getDefaultExport function for compatibility with non-harmony modules
118
+ /******/ __webpack_require__.n = function(module) {
119
+ /******/ var getter = module && module.__esModule ?
120
+ /******/ function getDefault() { return module['default']; } :
121
+ /******/ function getModuleExports() { return module; };
122
+ /******/ __webpack_require__.d(getter, 'a', getter);
123
+ /******/ return getter;
124
+ /******/ };
125
+ /******/
126
+ /******/ // Object.prototype.hasOwnProperty.call
127
+ /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
128
+ /******/
129
+ /******/ // __webpack_public_path__
130
+ /******/ __webpack_require__.p = "";
131
+ /******/
132
+ /******/ // Load entry module and return exports
133
+ /******/ return __webpack_require__(__webpack_require__.s = 4);
134
+ /******/ })
135
+ /************************************************************************/
136
+ /******/ ([
137
+ /* 0 */
138
+ /***/ (function(module, exports, __webpack_require__) {
139
+
140
+ /*jshint curly:true, eqeqeq:true, laxbreak:true, noempty:false */
141
+ /*
142
+
143
+ The MIT License (MIT)
144
+
145
+ Copyright (c) 2007-2017 Einar Lielmanis, Liam Newman, and contributors.
146
+
147
+ Permission is hereby granted, free of charge, to any person
148
+ obtaining a copy of this software and associated documentation files
149
+ (the "Software"), to deal in the Software without restriction,
150
+ including without limitation the rights to use, copy, modify, merge,
151
+ publish, distribute, sublicense, and/or sell copies of the Software,
152
+ and to permit persons to whom the Software is furnished to do so,
153
+ subject to the following conditions:
154
+
155
+ The above copyright notice and this permission notice shall be
156
+ included in all copies or substantial portions of the Software.
157
+
158
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
159
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
160
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
161
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
162
+ BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
163
+ ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
164
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
165
+ SOFTWARE.
166
+ */
167
+
168
+ var mergeOpts = __webpack_require__(2).mergeOpts;
169
+ var acorn = __webpack_require__(1);
170
+ var Output = __webpack_require__(3).Output;
171
+
172
+
173
+ var lineBreak = acorn.lineBreak;
174
+ var allLineBreaks = acorn.allLineBreaks;
175
+
176
+ function Beautifier(source_text, options) {
177
+ options = options || {};
178
+
179
+ // Allow the setting of language/file-type specific options
180
+ // with inheritance of overall settings
181
+ options = mergeOpts(options, 'css');
182
+
183
+ source_text = source_text || '';
184
+
185
+ var newlinesFromLastWSEat = 0;
186
+ var indentSize = options.indent_size ? parseInt(options.indent_size, 10) : 4;
187
+ var indentCharacter = options.indent_char || ' ';
188
+ var preserve_newlines = (options.preserve_newlines === undefined) ? false : options.preserve_newlines;
189
+ var selectorSeparatorNewline = (options.selector_separator_newline === undefined) ? true : options.selector_separator_newline;
190
+ var end_with_newline = (options.end_with_newline === undefined) ? false : options.end_with_newline;
191
+ var newline_between_rules = (options.newline_between_rules === undefined) ? true : options.newline_between_rules;
192
+ var space_around_combinator = (options.space_around_combinator === undefined) ? false : options.space_around_combinator;
193
+ space_around_combinator = space_around_combinator || ((options.space_around_selector_separator === undefined) ? false : options.space_around_selector_separator);
194
+ var eol = options.eol ? options.eol : 'auto';
195
+
196
+ if (options.indent_with_tabs) {
197
+ indentCharacter = '\t';
198
+ indentSize = 1;
199
+ }
200
+
201
+ if (eol === 'auto') {
202
+ eol = '\n';
203
+ if (source_text && lineBreak.test(source_text || '')) {
204
+ eol = source_text.match(lineBreak)[0];
205
+ }
206
+ }
207
+
208
+ eol = eol.replace(/\\r/, '\r').replace(/\\n/, '\n');
209
+
210
+ // HACK: newline parsing inconsistent. This brute force normalizes the input.
211
+ source_text = source_text.replace(allLineBreaks, '\n');
212
+
213
+ // tokenizer
214
+ var whiteRe = /^\s+$/;
215
+
216
+ var pos = -1,
217
+ ch;
218
+ var parenLevel = 0;
219
+
220
+ function next() {
221
+ ch = source_text.charAt(++pos);
222
+ return ch || '';
223
+ }
224
+
225
+ function peek(skipWhitespace) {
226
+ var result = '';
227
+ var prev_pos = pos;
228
+ if (skipWhitespace) {
229
+ eatWhitespace();
230
+ }
231
+ result = source_text.charAt(pos + 1) || '';
232
+ pos = prev_pos - 1;
233
+ next();
234
+ return result;
235
+ }
236
+
237
+ function eatString(endChars) {
238
+ var start = pos;
239
+ while (next()) {
240
+ if (ch === "\\") {
241
+ next();
242
+ } else if (endChars.indexOf(ch) !== -1) {
243
+ break;
244
+ } else if (ch === "\n") {
245
+ break;
246
+ }
247
+ }
248
+ return source_text.substring(start, pos + 1);
249
+ }
250
+
251
+ function peekString(endChar) {
252
+ var prev_pos = pos;
253
+ var str = eatString(endChar);
254
+ pos = prev_pos - 1;
255
+ next();
256
+ return str;
257
+ }
258
+
259
+ function eatWhitespace(preserve_newlines_local) {
260
+ var result = 0;
261
+ while (whiteRe.test(peek())) {
262
+ next();
263
+ if (ch === '\n' && preserve_newlines_local && preserve_newlines) {
264
+ output.add_new_line(true);
265
+ result++;
266
+ }
267
+ }
268
+ newlinesFromLastWSEat = result;
269
+ return result;
270
+ }
271
+
272
+ function skipWhitespace() {
273
+ var result = '';
274
+ if (ch && whiteRe.test(ch)) {
275
+ result = ch;
276
+ }
277
+ while (whiteRe.test(next())) {
278
+ result += ch;
279
+ }
280
+ return result;
281
+ }
282
+
283
+ function eatComment() {
284
+ var start = pos;
285
+ var singleLine = peek() === "/";
286
+ next();
287
+ while (next()) {
288
+ if (!singleLine && ch === "*" && peek() === "/") {
289
+ next();
290
+ break;
291
+ } else if (singleLine && ch === "\n") {
292
+ return source_text.substring(start, pos);
293
+ }
294
+ }
295
+
296
+ return source_text.substring(start, pos) + ch;
297
+ }
298
+
299
+
300
+ function lookBack(str) {
301
+ return source_text.substring(pos - str.length, pos).toLowerCase() ===
302
+ str;
303
+ }
304
+
305
+ // Nested pseudo-class if we are insideRule
306
+ // and the next special character found opens
307
+ // a new block
308
+ function foundNestedPseudoClass() {
309
+ var openParen = 0;
310
+ for (var i = pos + 1; i < source_text.length; i++) {
311
+ var ch = source_text.charAt(i);
312
+ if (ch === "{") {
313
+ return true;
314
+ } else if (ch === '(') {
315
+ // pseudoclasses can contain ()
316
+ openParen += 1;
317
+ } else if (ch === ')') {
318
+ if (openParen === 0) {
319
+ return false;
320
+ }
321
+ openParen -= 1;
322
+ } else if (ch === ";" || ch === "}") {
323
+ return false;
324
+ }
325
+ }
326
+ return false;
327
+ }
328
+
329
+ // printer
330
+ var baseIndentString = '';
331
+ var preindent_index = 0;
332
+ if (source_text && source_text.length) {
333
+ while ((source_text.charAt(preindent_index) === ' ' ||
334
+ source_text.charAt(preindent_index) === '\t')) {
335
+ preindent_index += 1;
336
+ }
337
+ baseIndentString = source_text.substring(0, preindent_index);
338
+ js_source_text = source_text.substring(preindent_index);
339
+ }
340
+
341
+
342
+ var singleIndent = new Array(indentSize + 1).join(indentCharacter);
343
+ var indentLevel;
344
+ var nestedLevel;
345
+ var output;
346
+
347
+ function print_string(output_string) {
348
+ if (output.just_added_newline()) {
349
+ output.set_indent(indentLevel);
350
+ }
351
+ output.add_token(output_string);
352
+ }
353
+
354
+ function preserveSingleSpace(isAfterSpace) {
355
+ if (isAfterSpace) {
356
+ output.space_before_token = true;
357
+ }
358
+ }
359
+
360
+ function indent() {
361
+ indentLevel++;
362
+ }
363
+
364
+ function outdent() {
365
+ if (indentLevel > 0) {
366
+ indentLevel--;
367
+ }
368
+ }
369
+
370
+ /*_____________________--------------------_____________________*/
371
+
372
+ this.beautify = function() {
373
+ // reset
374
+ output = new Output(singleIndent, baseIndentString);
375
+ indentLevel = 0;
376
+ nestedLevel = 0;
377
+
378
+ pos = -1;
379
+ ch = null;
380
+ parenLevel = 0;
381
+
382
+ var insideRule = false;
383
+ var insidePropertyValue = false;
384
+ var enteringConditionalGroup = false;
385
+ var top_ch = '';
386
+ var last_top_ch = '';
387
+
388
+ while (true) {
389
+ var whitespace = skipWhitespace();
390
+ var isAfterSpace = whitespace !== '';
391
+ var isAfterNewline = whitespace.indexOf('\n') !== -1;
392
+ last_top_ch = top_ch;
393
+ top_ch = ch;
394
+
395
+ if (!ch) {
396
+ break;
397
+ } else if (ch === '/' && peek() === '*') { /* css comment */
398
+ var header = indentLevel === 0;
399
+
400
+ if (isAfterNewline || header) {
401
+ output.add_new_line();
402
+ }
403
+
404
+ print_string(eatComment());
405
+ output.add_new_line();
406
+ if (header) {
407
+ output.add_new_line(true);
408
+ }
409
+ } else if (ch === '/' && peek() === '/') { // single line comment
410
+ if (!isAfterNewline && last_top_ch !== '{') {
411
+ output.trim(true);
412
+ }
413
+ output.space_before_token = true;
414
+ print_string(eatComment());
415
+ output.add_new_line();
416
+ } else if (ch === '@') {
417
+ preserveSingleSpace(isAfterSpace);
418
+
419
+ // deal with less propery mixins @{...}
420
+ if (peek() === '{') {
421
+ print_string(eatString('}'));
422
+ } else {
423
+ print_string(ch);
424
+
425
+ // strip trailing space, if present, for hash property checks
426
+ var variableOrRule = peekString(": ,;{}()[]/='\"");
427
+
428
+ if (variableOrRule.match(/[ :]$/)) {
429
+ // we have a variable or pseudo-class, add it and insert one space before continuing
430
+ next();
431
+ variableOrRule = eatString(": ").replace(/\s$/, '');
432
+ print_string(variableOrRule);
433
+ output.space_before_token = true;
434
+ }
435
+
436
+ variableOrRule = variableOrRule.replace(/\s$/, '');
437
+
438
+ // might be a nesting at-rule
439
+ if (variableOrRule in this.NESTED_AT_RULE) {
440
+ nestedLevel += 1;
441
+ if (variableOrRule in this.CONDITIONAL_GROUP_RULE) {
442
+ enteringConditionalGroup = true;
443
+ }
444
+ }
445
+ }
446
+ } else if (ch === '#' && peek() === '{') {
447
+ preserveSingleSpace(isAfterSpace);
448
+ print_string(eatString('}'));
449
+ } else if (ch === '{') {
450
+ if (peek(true) === '}') {
451
+ eatWhitespace();
452
+ next();
453
+ output.space_before_token = true;
454
+ print_string("{}");
455
+ if (!eatWhitespace(true)) {
456
+ output.add_new_line();
457
+ }
458
+
459
+ if (newlinesFromLastWSEat < 2 && newline_between_rules && indentLevel === 0) {
460
+ output.add_new_line(true);
461
+ }
462
+ } else {
463
+ indent();
464
+ output.space_before_token = true;
465
+ print_string(ch);
466
+ if (!eatWhitespace(true)) {
467
+ output.add_new_line();
468
+ }
469
+
470
+ // when entering conditional groups, only rulesets are allowed
471
+ if (enteringConditionalGroup) {
472
+ enteringConditionalGroup = false;
473
+ insideRule = (indentLevel > nestedLevel);
474
+ } else {
475
+ // otherwise, declarations are also allowed
476
+ insideRule = (indentLevel >= nestedLevel);
477
+ }
478
+ }
479
+ } else if (ch === '}') {
480
+ outdent();
481
+ output.add_new_line();
482
+ print_string(ch);
483
+ insideRule = false;
484
+ insidePropertyValue = false;
485
+ if (nestedLevel) {
486
+ nestedLevel--;
487
+ }
488
+
489
+ if (!eatWhitespace(true)) {
490
+ output.add_new_line();
491
+ }
492
+
493
+ if (newlinesFromLastWSEat < 2 && newline_between_rules && indentLevel === 0) {
494
+ output.add_new_line(true);
495
+ }
496
+ } else if (ch === ":") {
497
+ eatWhitespace();
498
+ if ((insideRule || enteringConditionalGroup) &&
499
+ !(lookBack("&") || foundNestedPseudoClass()) &&
500
+ !lookBack("(")) {
501
+ // 'property: value' delimiter
502
+ // which could be in a conditional group query
503
+ print_string(':');
504
+ if (!insidePropertyValue) {
505
+ insidePropertyValue = true;
506
+ output.space_before_token = true;
507
+ }
508
+ } else {
509
+ // sass/less parent reference don't use a space
510
+ // sass nested pseudo-class don't use a space
511
+
512
+ // preserve space before pseudoclasses/pseudoelements, as it means "in any child"
513
+ if (lookBack(" ")) {
514
+ output.space_before_token = true;
515
+ }
516
+ if (peek() === ":") {
517
+ // pseudo-element
518
+ next();
519
+ print_string("::");
520
+ } else {
521
+ // pseudo-class
522
+ print_string(':');
523
+ }
524
+ }
525
+ } else if (ch === '"' || ch === '\'') {
526
+ preserveSingleSpace(isAfterSpace);
527
+ print_string(eatString(ch));
528
+ } else if (ch === ';') {
529
+ insidePropertyValue = false;
530
+ print_string(ch);
531
+ if (!eatWhitespace(true)) {
532
+ output.add_new_line();
533
+ }
534
+ } else if (ch === '(') { // may be a url
535
+ if (lookBack("url")) {
536
+ print_string(ch);
537
+ eatWhitespace();
538
+ if (next()) {
539
+ if (ch !== ')' && ch !== '"' && ch !== '\'') {
540
+ print_string(eatString(')'));
541
+ } else {
542
+ pos--;
543
+ }
544
+ }
545
+ } else {
546
+ parenLevel++;
547
+ preserveSingleSpace(isAfterSpace);
548
+ print_string(ch);
549
+ eatWhitespace();
550
+ }
551
+ } else if (ch === ')') {
552
+ print_string(ch);
553
+ parenLevel--;
554
+ } else if (ch === ',') {
555
+ print_string(ch);
556
+ if (!eatWhitespace(true) && selectorSeparatorNewline && !insidePropertyValue && parenLevel < 1) {
557
+ output.add_new_line();
558
+ } else {
559
+ output.space_before_token = true;
560
+ }
561
+ } else if ((ch === '>' || ch === '+' || ch === '~') &&
562
+ !insidePropertyValue && parenLevel < 1) {
563
+ //handle combinator spacing
564
+ if (space_around_combinator) {
565
+ output.space_before_token = true;
566
+ print_string(ch);
567
+ output.space_before_token = true;
568
+ } else {
569
+ print_string(ch);
570
+ eatWhitespace();
571
+ // squash extra whitespace
572
+ if (ch && whiteRe.test(ch)) {
573
+ ch = '';
574
+ }
575
+ }
576
+ } else if (ch === ']') {
577
+ print_string(ch);
578
+ } else if (ch === '[') {
579
+ preserveSingleSpace(isAfterSpace);
580
+ print_string(ch);
581
+ } else if (ch === '=') { // no whitespace before or after
582
+ eatWhitespace();
583
+ print_string('=');
584
+ if (whiteRe.test(ch)) {
585
+ ch = '';
586
+ }
587
+
588
+ } else {
589
+ preserveSingleSpace(isAfterSpace);
590
+ print_string(ch);
591
+ }
592
+ }
593
+
594
+ var sweetCode = output.get_code(end_with_newline, eol);
595
+
596
+ return sweetCode;
597
+ };
598
+
599
+ // https://developer.mozilla.org/en-US/docs/Web/CSS/At-rule
600
+ this.NESTED_AT_RULE = {
601
+ "@page": true,
602
+ "@font-face": true,
603
+ "@keyframes": true,
604
+ // also in CONDITIONAL_GROUP_RULE below
605
+ "@media": true,
606
+ "@supports": true,
607
+ "@document": true
608
+ };
609
+ this.CONDITIONAL_GROUP_RULE = {
610
+ "@media": true,
611
+ "@supports": true,
612
+ "@document": true
613
+ };
614
+ }
615
+
616
+ module.exports.Beautifier = Beautifier;
617
+
618
+
619
+ /***/ }),
620
+ /* 1 */
621
+ /***/ (function(module, exports) {
622
+
623
+ /* jshint curly: false */
624
+ // This section of code is taken from acorn.
625
+ //
626
+ // Acorn was written by Marijn Haverbeke and released under an MIT
627
+ // license. The Unicode regexps (for identifiers and whitespace) were
628
+ // taken from [Esprima](http://esprima.org) by Ariya Hidayat.
629
+ //
630
+ // Git repositories for Acorn are available at
631
+ //
632
+ // http://marijnhaverbeke.nl/git/acorn
633
+ // https://github.com/marijnh/acorn.git
634
+
635
+ // ## Character categories
636
+
637
+ // Big ugly regular expressions that match characters in the
638
+ // whitespace, identifier, and identifier-start categories. These
639
+ // are only applied when a character is found to actually have a
640
+ // code point above 128.
641
+
642
+ var nonASCIIwhitespace = /[\u1680\u180e\u2000-\u200a\u202f\u205f\u3000\ufeff]/; // jshint ignore:line
643
+ var nonASCIIidentifierStartChars = "\xaa\xb5\xba\xc0-\xd6\xd8-\xf6\xf8-\u02c1\u02c6-\u02d1\u02e0-\u02e4\u02ec\u02ee\u0370-\u0374\u0376\u0377\u037a-\u037d\u0386\u0388-\u038a\u038c\u038e-\u03a1\u03a3-\u03f5\u03f7-\u0481\u048a-\u0527\u0531-\u0556\u0559\u0561-\u0587\u05d0-\u05ea\u05f0-\u05f2\u0620-\u064a\u066e\u066f\u0671-\u06d3\u06d5\u06e5\u06e6\u06ee\u06ef\u06fa-\u06fc\u06ff\u0710\u0712-\u072f\u074d-\u07a5\u07b1\u07ca-\u07ea\u07f4\u07f5\u07fa\u0800-\u0815\u081a\u0824\u0828\u0840-\u0858\u08a0\u08a2-\u08ac\u0904-\u0939\u093d\u0950\u0958-\u0961\u0971-\u0977\u0979-\u097f\u0985-\u098c\u098f\u0990\u0993-\u09a8\u09aa-\u09b0\u09b2\u09b6-\u09b9\u09bd\u09ce\u09dc\u09dd\u09df-\u09e1\u09f0\u09f1\u0a05-\u0a0a\u0a0f\u0a10\u0a13-\u0a28\u0a2a-\u0a30\u0a32\u0a33\u0a35\u0a36\u0a38\u0a39\u0a59-\u0a5c\u0a5e\u0a72-\u0a74\u0a85-\u0a8d\u0a8f-\u0a91\u0a93-\u0aa8\u0aaa-\u0ab0\u0ab2\u0ab3\u0ab5-\u0ab9\u0abd\u0ad0\u0ae0\u0ae1\u0b05-\u0b0c\u0b0f\u0b10\u0b13-\u0b28\u0b2a-\u0b30\u0b32\u0b33\u0b35-\u0b39\u0b3d\u0b5c\u0b5d\u0b5f-\u0b61\u0b71\u0b83\u0b85-\u0b8a\u0b8e-\u0b90\u0b92-\u0b95\u0b99\u0b9a\u0b9c\u0b9e\u0b9f\u0ba3\u0ba4\u0ba8-\u0baa\u0bae-\u0bb9\u0bd0\u0c05-\u0c0c\u0c0e-\u0c10\u0c12-\u0c28\u0c2a-\u0c33\u0c35-\u0c39\u0c3d\u0c58\u0c59\u0c60\u0c61\u0c85-\u0c8c\u0c8e-\u0c90\u0c92-\u0ca8\u0caa-\u0cb3\u0cb5-\u0cb9\u0cbd\u0cde\u0ce0\u0ce1\u0cf1\u0cf2\u0d05-\u0d0c\u0d0e-\u0d10\u0d12-\u0d3a\u0d3d\u0d4e\u0d60\u0d61\u0d7a-\u0d7f\u0d85-\u0d96\u0d9a-\u0db1\u0db3-\u0dbb\u0dbd\u0dc0-\u0dc6\u0e01-\u0e30\u0e32\u0e33\u0e40-\u0e46\u0e81\u0e82\u0e84\u0e87\u0e88\u0e8a\u0e8d\u0e94-\u0e97\u0e99-\u0e9f\u0ea1-\u0ea3\u0ea5\u0ea7\u0eaa\u0eab\u0ead-\u0eb0\u0eb2\u0eb3\u0ebd\u0ec0-\u0ec4\u0ec6\u0edc-\u0edf\u0f00\u0f40-\u0f47\u0f49-\u0f6c\u0f88-\u0f8c\u1000-\u102a\u103f\u1050-\u1055\u105a-\u105d\u1061\u1065\u1066\u106e-\u1070\u1075-\u1081\u108e\u10a0-\u10c5\u10c7\u10cd\u10d0-\u10fa\u10fc-\u1248\u124a-\u124d\u1250-\u1256\u1258\u125a-\u125d\u1260-\u1288\u128a-\u128d\u1290-\u12b0\u12b2-\u12b5\u12b8-\u12be\u12c0\u12c2-\u12c5\u12c8-\u12d6\u12d8-\u1310\u1312-\u1315\u1318-\u135a\u1380-\u138f\u13a0-\u13f4\u1401-\u166c\u166f-\u167f\u1681-\u169a\u16a0-\u16ea\u16ee-\u16f0\u1700-\u170c\u170e-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176c\u176e-\u1770\u1780-\u17b3\u17d7\u17dc\u1820-\u1877\u1880-\u18a8\u18aa\u18b0-\u18f5\u1900-\u191c\u1950-\u196d\u1970-\u1974\u1980-\u19ab\u19c1-\u19c7\u1a00-\u1a16\u1a20-\u1a54\u1aa7\u1b05-\u1b33\u1b45-\u1b4b\u1b83-\u1ba0\u1bae\u1baf\u1bba-\u1be5\u1c00-\u1c23\u1c4d-\u1c4f\u1c5a-\u1c7d\u1ce9-\u1cec\u1cee-\u1cf1\u1cf5\u1cf6\u1d00-\u1dbf\u1e00-\u1f15\u1f18-\u1f1d\u1f20-\u1f45\u1f48-\u1f4d\u1f50-\u1f57\u1f59\u1f5b\u1f5d\u1f5f-\u1f7d\u1f80-\u1fb4\u1fb6-\u1fbc\u1fbe\u1fc2-\u1fc4\u1fc6-\u1fcc\u1fd0-\u1fd3\u1fd6-\u1fdb\u1fe0-\u1fec\u1ff2-\u1ff4\u1ff6-\u1ffc\u2071\u207f\u2090-\u209c\u2102\u2107\u210a-\u2113\u2115\u2119-\u211d\u2124\u2126\u2128\u212a-\u212d\u212f-\u2139\u213c-\u213f\u2145-\u2149\u214e\u2160-\u2188\u2c00-\u2c2e\u2c30-\u2c5e\u2c60-\u2ce4\u2ceb-\u2cee\u2cf2\u2cf3\u2d00-\u2d25\u2d27\u2d2d\u2d30-\u2d67\u2d6f\u2d80-\u2d96\u2da0-\u2da6\u2da8-\u2dae\u2db0-\u2db6\u2db8-\u2dbe\u2dc0-\u2dc6\u2dc8-\u2dce\u2dd0-\u2dd6\u2dd8-\u2dde\u2e2f\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303c\u3041-\u3096\u309d-\u309f\u30a1-\u30fa\u30fc-\u30ff\u3105-\u312d\u3131-\u318e\u31a0-\u31ba\u31f0-\u31ff\u3400-\u4db5\u4e00-\u9fcc\ua000-\ua48c\ua4d0-\ua4fd\ua500-\ua60c\ua610-\ua61f\ua62a\ua62b\ua640-\ua66e\ua67f-\ua697\ua6a0-\ua6ef\ua717-\ua71f\ua722-\ua788\ua78b-\ua78e\ua790-\ua793\ua7a0-\ua7aa\ua7f8-\ua801\ua803-\ua805\ua807-\ua80a\ua80c-\ua822\ua840-\ua873\ua882-\ua8b3\ua8f2-\ua8f7\ua8fb\ua90a-\ua925\ua930-\ua946\ua960-\ua97c\ua984-\ua9b2\ua9cf\uaa00-\uaa28\uaa40-\uaa42\uaa44-\uaa4b\uaa60-\uaa76\uaa7a\uaa80-\uaaaf\uaab1\uaab5\uaab6\uaab9-\uaabd\uaac0\uaac2\uaadb-\uaadd\uaae0-\uaaea\uaaf2-\uaaf4\uab01-\uab06\uab09-\uab0e\uab11-\uab16\uab20-\uab26\uab28-\uab2e\uabc0-\uabe2\uac00-\ud7a3\ud7b0-\ud7c6\ud7cb-\ud7fb\uf900-\ufa6d\ufa70-\ufad9\ufb00-\ufb06\ufb13-\ufb17\ufb1d\ufb1f-\ufb28\ufb2a-\ufb36\ufb38-\ufb3c\ufb3e\ufb40\ufb41\ufb43\ufb44\ufb46-\ufbb1\ufbd3-\ufd3d\ufd50-\ufd8f\ufd92-\ufdc7\ufdf0-\ufdfb\ufe70-\ufe74\ufe76-\ufefc\uff21-\uff3a\uff41-\uff5a\uff66-\uffbe\uffc2-\uffc7\uffca-\uffcf\uffd2-\uffd7\uffda-\uffdc";
644
+ var nonASCIIidentifierChars = "\u0300-\u036f\u0483-\u0487\u0591-\u05bd\u05bf\u05c1\u05c2\u05c4\u05c5\u05c7\u0610-\u061a\u0620-\u0649\u0672-\u06d3\u06e7-\u06e8\u06fb-\u06fc\u0730-\u074a\u0800-\u0814\u081b-\u0823\u0825-\u0827\u0829-\u082d\u0840-\u0857\u08e4-\u08fe\u0900-\u0903\u093a-\u093c\u093e-\u094f\u0951-\u0957\u0962-\u0963\u0966-\u096f\u0981-\u0983\u09bc\u09be-\u09c4\u09c7\u09c8\u09d7\u09df-\u09e0\u0a01-\u0a03\u0a3c\u0a3e-\u0a42\u0a47\u0a48\u0a4b-\u0a4d\u0a51\u0a66-\u0a71\u0a75\u0a81-\u0a83\u0abc\u0abe-\u0ac5\u0ac7-\u0ac9\u0acb-\u0acd\u0ae2-\u0ae3\u0ae6-\u0aef\u0b01-\u0b03\u0b3c\u0b3e-\u0b44\u0b47\u0b48\u0b4b-\u0b4d\u0b56\u0b57\u0b5f-\u0b60\u0b66-\u0b6f\u0b82\u0bbe-\u0bc2\u0bc6-\u0bc8\u0bca-\u0bcd\u0bd7\u0be6-\u0bef\u0c01-\u0c03\u0c46-\u0c48\u0c4a-\u0c4d\u0c55\u0c56\u0c62-\u0c63\u0c66-\u0c6f\u0c82\u0c83\u0cbc\u0cbe-\u0cc4\u0cc6-\u0cc8\u0cca-\u0ccd\u0cd5\u0cd6\u0ce2-\u0ce3\u0ce6-\u0cef\u0d02\u0d03\u0d46-\u0d48\u0d57\u0d62-\u0d63\u0d66-\u0d6f\u0d82\u0d83\u0dca\u0dcf-\u0dd4\u0dd6\u0dd8-\u0ddf\u0df2\u0df3\u0e34-\u0e3a\u0e40-\u0e45\u0e50-\u0e59\u0eb4-\u0eb9\u0ec8-\u0ecd\u0ed0-\u0ed9\u0f18\u0f19\u0f20-\u0f29\u0f35\u0f37\u0f39\u0f41-\u0f47\u0f71-\u0f84\u0f86-\u0f87\u0f8d-\u0f97\u0f99-\u0fbc\u0fc6\u1000-\u1029\u1040-\u1049\u1067-\u106d\u1071-\u1074\u1082-\u108d\u108f-\u109d\u135d-\u135f\u170e-\u1710\u1720-\u1730\u1740-\u1750\u1772\u1773\u1780-\u17b2\u17dd\u17e0-\u17e9\u180b-\u180d\u1810-\u1819\u1920-\u192b\u1930-\u193b\u1951-\u196d\u19b0-\u19c0\u19c8-\u19c9\u19d0-\u19d9\u1a00-\u1a15\u1a20-\u1a53\u1a60-\u1a7c\u1a7f-\u1a89\u1a90-\u1a99\u1b46-\u1b4b\u1b50-\u1b59\u1b6b-\u1b73\u1bb0-\u1bb9\u1be6-\u1bf3\u1c00-\u1c22\u1c40-\u1c49\u1c5b-\u1c7d\u1cd0-\u1cd2\u1d00-\u1dbe\u1e01-\u1f15\u200c\u200d\u203f\u2040\u2054\u20d0-\u20dc\u20e1\u20e5-\u20f0\u2d81-\u2d96\u2de0-\u2dff\u3021-\u3028\u3099\u309a\ua640-\ua66d\ua674-\ua67d\ua69f\ua6f0-\ua6f1\ua7f8-\ua800\ua806\ua80b\ua823-\ua827\ua880-\ua881\ua8b4-\ua8c4\ua8d0-\ua8d9\ua8f3-\ua8f7\ua900-\ua909\ua926-\ua92d\ua930-\ua945\ua980-\ua983\ua9b3-\ua9c0\uaa00-\uaa27\uaa40-\uaa41\uaa4c-\uaa4d\uaa50-\uaa59\uaa7b\uaae0-\uaae9\uaaf2-\uaaf3\uabc0-\uabe1\uabec\uabed\uabf0-\uabf9\ufb20-\ufb28\ufe00-\ufe0f\ufe20-\ufe26\ufe33\ufe34\ufe4d-\ufe4f\uff10-\uff19\uff3f";
645
+ var nonASCIIidentifierStart = new RegExp("[" + nonASCIIidentifierStartChars + "]");
646
+ var nonASCIIidentifier = new RegExp("[" + nonASCIIidentifierStartChars + nonASCIIidentifierChars + "]");
647
+
648
+ // Whether a single character denotes a newline.
649
+
650
+ exports.newline = /[\n\r\u2028\u2029]/;
651
+
652
+ // Matches a whole line break (where CRLF is considered a single
653
+ // line break). Used to count lines.
654
+
655
+ // in javascript, these two differ
656
+ // in python they are the same, different methods are called on them
657
+ exports.lineBreak = new RegExp('\r\n|' + exports.newline.source);
658
+ exports.allLineBreaks = new RegExp(exports.lineBreak.source, 'g');
659
+
660
+
661
+ // Test whether a given character code starts an identifier.
662
+
663
+ exports.isIdentifierStart = function(code) {
664
+ // permit $ (36) and @ (64). @ is used in ES7 decorators.
665
+ if (code < 65) return code === 36 || code === 64;
666
+ // 65 through 91 are uppercase letters.
667
+ if (code < 91) return true;
668
+ // permit _ (95).
669
+ if (code < 97) return code === 95;
670
+ // 97 through 123 are lowercase letters.
671
+ if (code < 123) return true;
672
+ return code >= 0xaa && nonASCIIidentifierStart.test(String.fromCharCode(code));
673
+ };
674
+
675
+ // Test whether a given character is part of an identifier.
676
+
677
+ exports.isIdentifierChar = function(code) {
678
+ if (code < 48) return code === 36;
679
+ if (code < 58) return true;
680
+ if (code < 65) return false;
681
+ if (code < 91) return true;
682
+ if (code < 97) return code === 95;
683
+ if (code < 123) return true;
684
+ return code >= 0xaa && nonASCIIidentifier.test(String.fromCharCode(code));
685
+ };
686
+
687
+
688
+ /***/ }),
689
+ /* 2 */
690
+ /***/ (function(module, exports) {
691
+
692
+ /*jshint curly:true, eqeqeq:true, laxbreak:true, noempty:false */
693
+ /*
694
+
695
+ The MIT License (MIT)
696
+
697
+ Copyright (c) 2007-2017 Einar Lielmanis, Liam Newman, and contributors.
698
+
699
+ Permission is hereby granted, free of charge, to any person
700
+ obtaining a copy of this software and associated documentation files
701
+ (the "Software"), to deal in the Software without restriction,
702
+ including without limitation the rights to use, copy, modify, merge,
703
+ publish, distribute, sublicense, and/or sell copies of the Software,
704
+ and to permit persons to whom the Software is furnished to do so,
705
+ subject to the following conditions:
706
+
707
+ The above copyright notice and this permission notice shall be
708
+ included in all copies or substantial portions of the Software.
709
+
710
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
711
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
712
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
713
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
714
+ BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
715
+ ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
716
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
717
+ SOFTWARE.
718
+ */
719
+
720
+ function mergeOpts(allOptions, targetType) {
721
+ var finalOpts = {};
722
+ var name;
723
+
724
+ for (name in allOptions) {
725
+ if (name !== targetType) {
726
+ finalOpts[name] = allOptions[name];
727
+ }
728
+ }
729
+
730
+ //merge in the per type settings for the targetType
731
+ if (targetType in allOptions) {
732
+ for (name in allOptions[targetType]) {
733
+ finalOpts[name] = allOptions[targetType][name];
734
+ }
735
+ }
736
+ return finalOpts;
737
+ }
738
+
739
+ module.exports.mergeOpts = mergeOpts;
740
+
741
+
742
+ /***/ }),
743
+ /* 3 */
744
+ /***/ (function(module, exports) {
745
+
746
+ /*jshint curly:true, eqeqeq:true, laxbreak:true, noempty:false */
747
+ /*
748
+
749
+ The MIT License (MIT)
750
+
751
+ Copyright (c) 2007-2017 Einar Lielmanis, Liam Newman, and contributors.
752
+
753
+ Permission is hereby granted, free of charge, to any person
754
+ obtaining a copy of this software and associated documentation files
755
+ (the "Software"), to deal in the Software without restriction,
756
+ including without limitation the rights to use, copy, modify, merge,
757
+ publish, distribute, sublicense, and/or sell copies of the Software,
758
+ and to permit persons to whom the Software is furnished to do so,
759
+ subject to the following conditions:
760
+
761
+ The above copyright notice and this permission notice shall be
762
+ included in all copies or substantial portions of the Software.
763
+
764
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
765
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
766
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
767
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
768
+ BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
769
+ ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
770
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
771
+ SOFTWARE.
772
+ */
773
+
774
+ function OutputLine(parent) {
775
+ var _character_count = 0;
776
+ // use indent_count as a marker for lines that have preserved indentation
777
+ var _indent_count = -1;
778
+
779
+ var _items = [];
780
+ var _empty = true;
781
+
782
+ this.set_indent = function(level) {
783
+ _character_count = parent.baseIndentLength + level * parent.indent_length;
784
+ _indent_count = level;
785
+ };
786
+
787
+ this.get_character_count = function() {
788
+ return _character_count;
789
+ };
790
+
791
+ this.is_empty = function() {
792
+ return _empty;
793
+ };
794
+
795
+ this.last = function() {
796
+ if (!this._empty) {
797
+ return _items[_items.length - 1];
798
+ } else {
799
+ return null;
800
+ }
801
+ };
802
+
803
+ this.push = function(input) {
804
+ _items.push(input);
805
+ _character_count += input.length;
806
+ _empty = false;
807
+ };
808
+
809
+ this.pop = function() {
810
+ var item = null;
811
+ if (!_empty) {
812
+ item = _items.pop();
813
+ _character_count -= item.length;
814
+ _empty = _items.length === 0;
815
+ }
816
+ return item;
817
+ };
818
+
819
+ this.remove_indent = function() {
820
+ if (_indent_count > 0) {
821
+ _indent_count -= 1;
822
+ _character_count -= parent.indent_length;
823
+ }
824
+ };
825
+
826
+ this.trim = function() {
827
+ while (this.last() === ' ') {
828
+ _items.pop();
829
+ _character_count -= 1;
830
+ }
831
+ _empty = _items.length === 0;
832
+ };
833
+
834
+ this.toString = function() {
835
+ var result = '';
836
+ if (!this._empty) {
837
+ if (_indent_count >= 0) {
838
+ result = parent.indent_cache[_indent_count];
839
+ }
840
+ result += _items.join('');
841
+ }
842
+ return result;
843
+ };
844
+ }
845
+
846
+ function Output(indent_string, baseIndentString) {
847
+ baseIndentString = baseIndentString || '';
848
+ this.indent_cache = [baseIndentString];
849
+ this.baseIndentLength = baseIndentString.length;
850
+ this.indent_length = indent_string.length;
851
+ this.raw = false;
852
+
853
+ var lines = [];
854
+ this.baseIndentString = baseIndentString;
855
+ this.indent_string = indent_string;
856
+ this.previous_line = null;
857
+ this.current_line = null;
858
+ this.space_before_token = false;
859
+
860
+ this.add_outputline = function() {
861
+ this.previous_line = this.current_line;
862
+ this.current_line = new OutputLine(this);
863
+ lines.push(this.current_line);
864
+ };
865
+
866
+ // initialize
867
+ this.add_outputline();
868
+
869
+
870
+ this.get_line_number = function() {
871
+ return lines.length;
872
+ };
873
+
874
+ // Using object instead of string to allow for later expansion of info about each line
875
+ this.add_new_line = function(force_newline) {
876
+ if (this.get_line_number() === 1 && this.just_added_newline()) {
877
+ return false; // no newline on start of file
878
+ }
879
+
880
+ if (force_newline || !this.just_added_newline()) {
881
+ if (!this.raw) {
882
+ this.add_outputline();
883
+ }
884
+ return true;
885
+ }
886
+
887
+ return false;
888
+ };
889
+
890
+ this.get_code = function(end_with_newline, eol) {
891
+ var sweet_code = lines.join('\n').replace(/[\r\n\t ]+$/, '');
892
+
893
+ if (end_with_newline) {
894
+ sweet_code += '\n';
895
+ }
896
+
897
+ if (eol !== '\n') {
898
+ sweet_code = sweet_code.replace(/[\n]/g, eol);
899
+ }
900
+
901
+ return sweet_code;
902
+ };
903
+
904
+ this.set_indent = function(level) {
905
+ // Never indent your first output indent at the start of the file
906
+ if (lines.length > 1) {
907
+ while (level >= this.indent_cache.length) {
908
+ this.indent_cache.push(this.indent_cache[this.indent_cache.length - 1] + this.indent_string);
909
+ }
910
+
911
+ this.current_line.set_indent(level);
912
+ return true;
913
+ }
914
+ this.current_line.set_indent(0);
915
+ return false;
916
+ };
917
+
918
+ this.add_raw_token = function(token) {
919
+ for (var x = 0; x < token.newlines; x++) {
920
+ this.add_outputline();
921
+ }
922
+ this.current_line.push(token.whitespace_before);
923
+ this.current_line.push(token.text);
924
+ this.space_before_token = false;
925
+ };
926
+
927
+ this.add_token = function(printable_token) {
928
+ this.add_space_before_token();
929
+ this.current_line.push(printable_token);
930
+ };
931
+
932
+ this.add_space_before_token = function() {
933
+ if (this.space_before_token && !this.just_added_newline()) {
934
+ this.current_line.push(' ');
935
+ }
936
+ this.space_before_token = false;
937
+ };
938
+
939
+ this.remove_indent = function(index) {
940
+ var output_length = lines.length;
941
+ while (index < output_length) {
942
+ lines[index].remove_indent();
943
+ index++;
944
+ }
945
+ };
946
+
947
+ this.trim = function(eat_newlines) {
948
+ eat_newlines = (eat_newlines === undefined) ? false : eat_newlines;
949
+
950
+ this.current_line.trim(indent_string, baseIndentString);
951
+
952
+ while (eat_newlines && lines.length > 1 &&
953
+ this.current_line.is_empty()) {
954
+ lines.pop();
955
+ this.current_line = lines[lines.length - 1];
956
+ this.current_line.trim();
957
+ }
958
+
959
+ this.previous_line = lines.length > 1 ? lines[lines.length - 2] : null;
960
+ };
961
+
962
+ this.just_added_newline = function() {
963
+ return this.current_line.is_empty();
964
+ };
965
+
966
+ this.just_added_blankline = function() {
967
+ if (this.just_added_newline()) {
968
+ if (lines.length === 1) {
969
+ return true; // start of the file and newline = blank
970
+ }
971
+
972
+ var line = lines[lines.length - 2];
973
+ return line.is_empty();
974
+ }
975
+ return false;
976
+ };
977
+ }
978
+
979
+ module.exports.Output = Output;
980
+
981
+
982
+ /***/ }),
983
+ /* 4 */
984
+ /***/ (function(module, exports, __webpack_require__) {
985
+
986
+ /*jshint curly:true, eqeqeq:true, laxbreak:true, noempty:false */
987
+ /*
988
+
989
+ The MIT License (MIT)
990
+
991
+ Copyright (c) 2007-2017 Einar Lielmanis, Liam Newman, and contributors.
992
+
993
+ Permission is hereby granted, free of charge, to any person
994
+ obtaining a copy of this software and associated documentation files
995
+ (the "Software"), to deal in the Software without restriction,
996
+ including without limitation the rights to use, copy, modify, merge,
997
+ publish, distribute, sublicense, and/or sell copies of the Software,
998
+ and to permit persons to whom the Software is furnished to do so,
999
+ subject to the following conditions:
1000
+
1001
+ The above copyright notice and this permission notice shall be
1002
+ included in all copies or substantial portions of the Software.
1003
+
1004
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
1005
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
1006
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
1007
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
1008
+ BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
1009
+ ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
1010
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
1011
+ SOFTWARE.
1012
+ */
1013
+
1014
+ var Beautifier = __webpack_require__(0).Beautifier;
1015
+
1016
+ function css_beautify(source_text, options) {
1017
+ var beautifier = new Beautifier(source_text, options);
1018
+ return beautifier.beautify();
1019
+ }
1020
+
1021
+ module.exports = css_beautify;
1022
+
1023
+ /***/ })
1024
+ /******/ ]);
1025
+ var css_beautify = legacy_beautify_css;
1026
+ /* Footer */
1027
+ if (typeof define === "function" && define.amd) {
1028
+ // Add support for AMD ( https://github.com/amdjs/amdjs-api/wiki/AMD#defineamd-property- )
1029
+ define([], function() {
1030
+ return {
1031
+ css_beautify: css_beautify
1032
+ };
1033
+ });
1034
+ } else if (typeof exports !== "undefined") {
1035
+ // Add support for CommonJS. Just put this file somewhere on your require.paths
1036
+ // and you will be able to `var html_beautify = require("beautify").html_beautify`.
1037
+ exports.css_beautify = css_beautify;
1038
+ } else if (typeof window !== "undefined") {
1039
+ // If we're running a web page and don't have either of the above, add our one global
1040
+ window.css_beautify = css_beautify;
1041
+ } else if (typeof global !== "undefined") {
1042
+ // If we don't even have window, try global.
1043
+ global.css_beautify = css_beautify;
1044
+ }
1045
+
1046
+ }());