js-beautify 1.6.14 → 1.7.3

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 (48) hide show
  1. package/CHANGELOG.md +14 -179
  2. package/README.md +12 -10
  3. package/js/lib/beautify-css.js +768 -293
  4. package/js/lib/beautify-html.js +1016 -757
  5. package/js/lib/beautify.js +2385 -2046
  6. package/js/lib/cli.js +3 -0
  7. package/js/src/core/acorn.js +63 -0
  8. package/js/src/core/inputscanner.js +95 -0
  9. package/js/src/core/options.js +48 -0
  10. package/js/src/core/output.js +234 -0
  11. package/js/src/core/token.js +49 -0
  12. package/js/src/css/beautifier.js +477 -0
  13. package/js/src/css/index.js +36 -0
  14. package/js/src/html/beautifier.js +1035 -0
  15. package/js/src/html/index.js +36 -0
  16. package/js/src/index.js +27 -0
  17. package/js/src/javascript/beautifier.js +1449 -0
  18. package/js/src/javascript/index.js +36 -0
  19. package/js/src/javascript/tokenizer.js +620 -0
  20. package/js/test/generated/beautify-javascript-tests.js +33 -0
  21. package/package.json +5 -4
  22. package/.codeclimate.yml +0 -13
  23. package/.jshintignore +0 -9
  24. package/.jshintrc +0 -10
  25. package/.npmignore +0 -5
  26. package/.travis.yml +0 -14
  27. package/ISSUE_TEMPLATE.md +0 -55
  28. package/appveyor.yml +0 -35
  29. package/bower.json +0 -11
  30. package/build +0 -5
  31. package/jsbeautifyrc +0 -18
  32. package/test/data/css/node.mustache +0 -269
  33. package/test/data/css/python.mustache +0 -270
  34. package/test/data/css/tests.js +0 -445
  35. package/test/data/html/node.mustache +0 -378
  36. package/test/data/html/tests.js +0 -1105
  37. package/test/data/javascript/inputlib.js +0 -84
  38. package/test/data/javascript/node.mustache +0 -1114
  39. package/test/data/javascript/python.mustache +0 -1322
  40. package/test/data/javascript/tests.js +0 -3083
  41. package/test/generate-tests.js +0 -216
  42. package/test/resources/html-with-base64image.html +0 -1
  43. package/test/resources/underscore-min.js +0 -6
  44. package/test/resources/underscore.js +0 -1439
  45. package/tools/build.sh +0 -140
  46. package/tools/generate-changelog.sh +0 -40
  47. package/tools/git-status-clear.sh +0 -18
  48. package/tools/release-all.sh +0 -86
@@ -1,4 +1,5 @@
1
- /*jshint curly:true, eqeqeq:true, laxbreak:true, noempty:false */
1
+ /*jshint curly:false, eqeqeq:true, laxbreak:true, noempty:false */
2
+ /* AUTO-GENERATED. DO NOT MODIFY. */
2
3
  /*
3
4
 
4
5
  The MIT License (MIT)
@@ -41,7 +42,6 @@
41
42
  The options are (default in brackets):
42
43
  indent_size (4) — indentation size,
43
44
  indent_char (space) — character to indent with,
44
- preserve_newlines (default false) - whether existing line breaks should be preserved,
45
45
  selector_separator_newline (true) - separate selectors with newline or
46
46
  not (e.g. "a,\nbr" or "a, br")
47
47
  end_with_newline (false) - end with a newline
@@ -64,256 +64,320 @@
64
64
  // http://www.w3.org/TR/css3-syntax/
65
65
 
66
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__) {
67
139
 
68
- function mergeOpts(allOptions, targetType) {
69
- var finalOpts = {};
70
- var name;
140
+ /*jshint curly:true, eqeqeq:true, laxbreak:true, noempty:false */
141
+ /*
71
142
 
72
- for (name in allOptions) {
73
- if (name !== targetType) {
74
- finalOpts[name] = allOptions[name];
75
- }
76
- }
143
+ The MIT License (MIT)
77
144
 
145
+ Copyright (c) 2007-2017 Einar Lielmanis, Liam Newman, and contributors.
78
146
 
79
- //merge in the per type settings for the targetType
80
- if (targetType in allOptions) {
81
- for (name in allOptions[targetType]) {
82
- finalOpts[name] = allOptions[targetType][name];
83
- }
84
- }
85
- return finalOpts;
86
- }
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:
87
154
 
88
- var lineBreak = /\r\n|[\n\r\u2028\u2029]/;
89
- var allLineBreaks = new RegExp(lineBreak.source, 'g');
155
+ The above copyright notice and this permission notice shall be
156
+ included in all copies or substantial portions of the Software.
90
157
 
91
- function css_beautify(source_text, options) {
92
- options = options || {};
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
+ */
93
167
 
94
- // Allow the setting of language/file-type specific options
95
- // with inheritance of overall settings
96
- options = mergeOpts(options, 'css');
168
+ var mergeOpts = __webpack_require__(2).mergeOpts;
169
+ var acorn = __webpack_require__(1);
170
+ var Output = __webpack_require__(3).Output;
97
171
 
98
- source_text = source_text || '';
99
172
 
100
- var newlinesFromLastWSEat = 0;
101
- var indentSize = options.indent_size ? parseInt(options.indent_size, 10) : 4;
102
- var indentCharacter = options.indent_char || ' ';
103
- var preserve_newlines = (options.preserve_newlines === undefined) ? false : options.preserve_newlines;
104
- var selectorSeparatorNewline = (options.selector_separator_newline === undefined) ? true : options.selector_separator_newline;
105
- var end_with_newline = (options.end_with_newline === undefined) ? false : options.end_with_newline;
106
- var newline_between_rules = (options.newline_between_rules === undefined) ? true : options.newline_between_rules;
107
- var space_around_combinator = (options.space_around_combinator === undefined) ? false : options.space_around_combinator;
108
- space_around_combinator = space_around_combinator || ((options.space_around_selector_separator === undefined) ? false : options.space_around_selector_separator);
109
- var eol = options.eol ? options.eol : 'auto';
173
+ var lineBreak = acorn.lineBreak;
174
+ var allLineBreaks = acorn.allLineBreaks;
110
175
 
111
- if (options.indent_with_tabs) {
112
- indentCharacter = '\t';
113
- indentSize = 1;
114
- }
176
+ function Beautifier(source_text, options) {
177
+ options = options || {};
115
178
 
116
- if (eol === 'auto') {
117
- eol = '\n';
118
- if (source_text && lineBreak.test(source_text || '')) {
119
- eol = source_text.match(lineBreak)[0];
120
- }
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];
121
205
  }
206
+ }
122
207
 
123
- eol = eol.replace(/\\r/, '\r').replace(/\\n/, '\n');
208
+ eol = eol.replace(/\\r/, '\r').replace(/\\n/, '\n');
124
209
 
125
- // HACK: newline parsing inconsistent. This brute force normalizes the input.
126
- source_text = source_text.replace(allLineBreaks, '\n');
210
+ // HACK: newline parsing inconsistent. This brute force normalizes the input.
211
+ source_text = source_text.replace(allLineBreaks, '\n');
127
212
 
128
- // tokenizer
129
- var whiteRe = /^\s+$/;
213
+ // tokenizer
214
+ var whiteRe = /^\s+$/;
130
215
 
131
- var pos = -1,
132
- ch;
133
- var parenLevel = 0;
216
+ var pos = -1,
217
+ ch;
218
+ var parenLevel = 0;
134
219
 
135
- function next() {
136
- ch = source_text.charAt(++pos);
137
- return ch || '';
138
- }
220
+ function next() {
221
+ ch = source_text.charAt(++pos);
222
+ return ch || '';
223
+ }
139
224
 
140
- function peek(skipWhitespace) {
141
- var result = '';
142
- var prev_pos = pos;
143
- if (skipWhitespace) {
144
- eatWhitespace();
145
- }
146
- result = source_text.charAt(pos + 1) || '';
147
- pos = prev_pos - 1;
148
- next();
149
- return result;
225
+ function peek(skipWhitespace) {
226
+ var result = '';
227
+ var prev_pos = pos;
228
+ if (skipWhitespace) {
229
+ eatWhitespace();
150
230
  }
231
+ result = source_text.charAt(pos + 1) || '';
232
+ pos = prev_pos - 1;
233
+ next();
234
+ return result;
235
+ }
151
236
 
152
- function eatString(endChars) {
153
- var start = pos;
154
- while (next()) {
155
- if (ch === "\\") {
156
- next();
157
- } else if (endChars.indexOf(ch) !== -1) {
158
- break;
159
- } else if (ch === "\n") {
160
- break;
161
- }
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;
162
246
  }
163
- return source_text.substring(start, pos + 1);
164
247
  }
248
+ return source_text.substring(start, pos + 1);
249
+ }
165
250
 
166
- function peekString(endChar) {
167
- var prev_pos = pos;
168
- var str = eatString(endChar);
169
- pos = prev_pos - 1;
170
- next();
171
- return str;
172
- }
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
+ }
173
258
 
174
- function eatWhitespace(preserve_newlines_local) {
175
- var result = 0;
176
- while (whiteRe.test(peek())) {
177
- next();
178
- if (ch === '\n' && preserve_newlines_local && preserve_newlines) {
179
- print.newLine(true);
180
- result++;
181
- }
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++;
182
266
  }
183
- newlinesFromLastWSEat = result;
184
- return result;
185
267
  }
268
+ newlinesFromLastWSEat = result;
269
+ return result;
270
+ }
186
271
 
187
- function skipWhitespace() {
188
- var result = '';
189
- if (ch && whiteRe.test(ch)) {
190
- result = ch;
191
- }
192
- while (whiteRe.test(next())) {
193
- result += ch;
194
- }
195
- return result;
272
+ function skipWhitespace() {
273
+ var result = '';
274
+ if (ch && whiteRe.test(ch)) {
275
+ result = ch;
196
276
  }
277
+ while (whiteRe.test(next())) {
278
+ result += ch;
279
+ }
280
+ return result;
281
+ }
197
282
 
198
- function eatComment(singleLine) {
199
- var start = pos;
200
- singleLine = peek() === "/";
201
- next();
202
- while (next()) {
203
- if (!singleLine && ch === "*" && peek() === "/") {
204
- next();
205
- break;
206
- } else if (singleLine && ch === "\n") {
207
- return source_text.substring(start, pos);
208
- }
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);
209
293
  }
210
-
211
- return source_text.substring(start, pos) + ch;
212
294
  }
213
295
 
296
+ return source_text.substring(start, pos) + ch;
297
+ }
214
298
 
215
- function lookBack(str) {
216
- return source_text.substring(pos - str.length, pos).toLowerCase() ===
217
- str;
218
- }
219
299
 
220
- // Nested pseudo-class if we are insideRule
221
- // and the next special character found opens
222
- // a new block
223
- function foundNestedPseudoClass() {
224
- var openParen = 0;
225
- for (var i = pos + 1; i < source_text.length; i++) {
226
- var ch = source_text.charAt(i);
227
- if (ch === "{") {
228
- return true;
229
- } else if (ch === '(') {
230
- // pseudoclasses can contain ()
231
- openParen += 1;
232
- } else if (ch === ')') {
233
- if (openParen === 0) {
234
- return false;
235
- }
236
- openParen -= 1;
237
- } else if (ch === ";" || ch === "}") {
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) {
238
319
  return false;
239
320
  }
321
+ openParen -= 1;
322
+ } else if (ch === ";" || ch === "}") {
323
+ return false;
240
324
  }
241
- return false;
242
325
  }
326
+ return false;
327
+ }
243
328
 
244
- // printer
245
- var basebaseIndentString = source_text.match(/^[\t ]*/)[0];
246
- var singleIndent = new Array(indentSize + 1).join(indentCharacter);
247
- var indentLevel = 0;
248
- var nestedLevel = 0;
249
-
250
- function indent() {
251
- indentLevel++;
252
- basebaseIndentString += singleIndent;
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;
253
336
  }
337
+ baseIndentString = source_text.substring(0, preindent_index);
338
+ js_source_text = source_text.substring(preindent_index);
339
+ }
254
340
 
255
- function outdent() {
256
- indentLevel--;
257
- basebaseIndentString = basebaseIndentString.slice(0, -indentSize);
258
- }
259
341
 
260
- var print = {};
261
- print["{"] = function(ch) {
262
- print.singleSpace();
263
- output.push(ch);
264
- if (!eatWhitespace(true)) {
265
- print.newLine();
266
- }
267
- };
268
- print["}"] = function(newline) {
269
- if (newline) {
270
- print.newLine();
271
- }
272
- output.push('}');
273
- if (!eatWhitespace(true)) {
274
- print.newLine();
275
- }
276
- };
342
+ var singleIndent = new Array(indentSize + 1).join(indentCharacter);
343
+ var indentLevel;
344
+ var nestedLevel;
345
+ var output;
277
346
 
278
- print._lastCharWhitespace = function() {
279
- return whiteRe.test(output[output.length - 1]);
280
- };
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
+ }
281
353
 
282
- print.newLine = function(keepWhitespace) {
283
- if (output.length) {
284
- if (!keepWhitespace && output[output.length - 1] !== '\n') {
285
- print.trim();
286
- } else if (output[output.length - 1] === basebaseIndentString) {
287
- output.pop();
288
- }
289
- output.push('\n');
354
+ function preserveSingleSpace(isAfterSpace) {
355
+ if (isAfterSpace) {
356
+ output.space_before_token = true;
357
+ }
358
+ }
290
359
 
291
- if (basebaseIndentString) {
292
- output.push(basebaseIndentString);
293
- }
294
- }
295
- };
296
- print.singleSpace = function() {
297
- if (output.length && !print._lastCharWhitespace()) {
298
- output.push(' ');
299
- }
300
- };
360
+ function indent() {
361
+ indentLevel++;
362
+ }
301
363
 
302
- print.preserveSingleSpace = function() {
303
- if (isAfterSpace) {
304
- print.singleSpace();
305
- }
306
- };
364
+ function outdent() {
365
+ if (indentLevel > 0) {
366
+ indentLevel--;
367
+ }
368
+ }
307
369
 
308
- print.trim = function() {
309
- while (print._lastCharWhitespace()) {
310
- output.pop();
311
- }
312
- };
370
+ /*_____________________--------------------_____________________*/
313
371
 
372
+ this.beautify = function() {
373
+ // reset
374
+ output = new Output(singleIndent, baseIndentString);
375
+ indentLevel = 0;
376
+ nestedLevel = 0;
314
377
 
315
- var output = [];
316
- /*_____________________--------------------_____________________*/
378
+ pos = -1;
379
+ ch = null;
380
+ parenLevel = 0;
317
381
 
318
382
  var insideRule = false;
319
383
  var insidePropertyValue = false;
@@ -334,29 +398,29 @@
334
398
  var header = indentLevel === 0;
335
399
 
336
400
  if (isAfterNewline || header) {
337
- print.newLine();
401
+ output.add_new_line();
338
402
  }
339
403
 
340
- output.push(eatComment());
341
- print.newLine();
404
+ print_string(eatComment());
405
+ output.add_new_line();
342
406
  if (header) {
343
- print.newLine(true);
407
+ output.add_new_line(true);
344
408
  }
345
409
  } else if (ch === '/' && peek() === '/') { // single line comment
346
410
  if (!isAfterNewline && last_top_ch !== '{') {
347
- print.trim();
411
+ output.trim(true);
348
412
  }
349
- print.singleSpace();
350
- output.push(eatComment());
351
- print.newLine();
413
+ output.space_before_token = true;
414
+ print_string(eatComment());
415
+ output.add_new_line();
352
416
  } else if (ch === '@') {
353
- print.preserveSingleSpace();
417
+ preserveSingleSpace(isAfterSpace);
354
418
 
355
419
  // deal with less propery mixins @{...}
356
420
  if (peek() === '{') {
357
- output.push(eatString('}'));
421
+ print_string(eatString('}'));
358
422
  } else {
359
- output.push(ch);
423
+ print_string(ch);
360
424
 
361
425
  // strip trailing space, if present, for hash property checks
362
426
  var variableOrRule = peekString(": ,;{}()[]/='\"");
@@ -365,36 +429,44 @@
365
429
  // we have a variable or pseudo-class, add it and insert one space before continuing
366
430
  next();
367
431
  variableOrRule = eatString(": ").replace(/\s$/, '');
368
- output.push(variableOrRule);
369
- print.singleSpace();
432
+ print_string(variableOrRule);
433
+ output.space_before_token = true;
370
434
  }
371
435
 
372
436
  variableOrRule = variableOrRule.replace(/\s$/, '');
373
437
 
374
438
  // might be a nesting at-rule
375
- if (variableOrRule in css_beautify.NESTED_AT_RULE) {
439
+ if (variableOrRule in this.NESTED_AT_RULE) {
376
440
  nestedLevel += 1;
377
- if (variableOrRule in css_beautify.CONDITIONAL_GROUP_RULE) {
441
+ if (variableOrRule in this.CONDITIONAL_GROUP_RULE) {
378
442
  enteringConditionalGroup = true;
379
443
  }
380
444
  }
381
445
  }
382
446
  } else if (ch === '#' && peek() === '{') {
383
- print.preserveSingleSpace();
384
- output.push(eatString('}'));
447
+ preserveSingleSpace(isAfterSpace);
448
+ print_string(eatString('}'));
385
449
  } else if (ch === '{') {
386
450
  if (peek(true) === '}') {
387
451
  eatWhitespace();
388
452
  next();
389
- print.singleSpace();
390
- output.push("{");
391
- print['}'](false);
453
+ output.space_before_token = true;
454
+ print_string("{}");
455
+ if (!eatWhitespace(true)) {
456
+ output.add_new_line();
457
+ }
458
+
392
459
  if (newlinesFromLastWSEat < 2 && newline_between_rules && indentLevel === 0) {
393
- print.newLine(true);
460
+ output.add_new_line(true);
394
461
  }
395
462
  } else {
396
463
  indent();
397
- print["{"](ch);
464
+ output.space_before_token = true;
465
+ print_string(ch);
466
+ if (!eatWhitespace(true)) {
467
+ output.add_new_line();
468
+ }
469
+
398
470
  // when entering conditional groups, only rulesets are allowed
399
471
  if (enteringConditionalGroup) {
400
472
  enteringConditionalGroup = false;
@@ -406,14 +478,20 @@
406
478
  }
407
479
  } else if (ch === '}') {
408
480
  outdent();
409
- print["}"](true);
481
+ output.add_new_line();
482
+ print_string(ch);
410
483
  insideRule = false;
411
484
  insidePropertyValue = false;
412
485
  if (nestedLevel) {
413
486
  nestedLevel--;
414
487
  }
488
+
489
+ if (!eatWhitespace(true)) {
490
+ output.add_new_line();
491
+ }
492
+
415
493
  if (newlinesFromLastWSEat < 2 && newline_between_rules && indentLevel === 0) {
416
- print.newLine(true);
494
+ output.add_new_line(true);
417
495
  }
418
496
  } else if (ch === ":") {
419
497
  eatWhitespace();
@@ -422,73 +500,73 @@
422
500
  !lookBack("(")) {
423
501
  // 'property: value' delimiter
424
502
  // which could be in a conditional group query
425
- output.push(':');
503
+ print_string(':');
426
504
  if (!insidePropertyValue) {
427
505
  insidePropertyValue = true;
428
- print.singleSpace();
506
+ output.space_before_token = true;
429
507
  }
430
508
  } else {
431
509
  // sass/less parent reference don't use a space
432
510
  // sass nested pseudo-class don't use a space
433
511
 
434
512
  // preserve space before pseudoclasses/pseudoelements, as it means "in any child"
435
- if (lookBack(" ") && output[output.length - 1] !== " ") {
436
- output.push(" ");
513
+ if (lookBack(" ")) {
514
+ output.space_before_token = true;
437
515
  }
438
516
  if (peek() === ":") {
439
517
  // pseudo-element
440
518
  next();
441
- output.push("::");
519
+ print_string("::");
442
520
  } else {
443
521
  // pseudo-class
444
- output.push(':');
522
+ print_string(':');
445
523
  }
446
524
  }
447
525
  } else if (ch === '"' || ch === '\'') {
448
- print.preserveSingleSpace();
449
- output.push(eatString(ch));
526
+ preserveSingleSpace(isAfterSpace);
527
+ print_string(eatString(ch));
450
528
  } else if (ch === ';') {
451
529
  insidePropertyValue = false;
452
- output.push(ch);
530
+ print_string(ch);
453
531
  if (!eatWhitespace(true)) {
454
- print.newLine();
532
+ output.add_new_line();
455
533
  }
456
534
  } else if (ch === '(') { // may be a url
457
535
  if (lookBack("url")) {
458
- output.push(ch);
536
+ print_string(ch);
459
537
  eatWhitespace();
460
538
  if (next()) {
461
539
  if (ch !== ')' && ch !== '"' && ch !== '\'') {
462
- output.push(eatString(')'));
540
+ print_string(eatString(')'));
463
541
  } else {
464
542
  pos--;
465
543
  }
466
544
  }
467
545
  } else {
468
546
  parenLevel++;
469
- print.preserveSingleSpace();
470
- output.push(ch);
547
+ preserveSingleSpace(isAfterSpace);
548
+ print_string(ch);
471
549
  eatWhitespace();
472
550
  }
473
551
  } else if (ch === ')') {
474
- output.push(ch);
552
+ print_string(ch);
475
553
  parenLevel--;
476
554
  } else if (ch === ',') {
477
- output.push(ch);
555
+ print_string(ch);
478
556
  if (!eatWhitespace(true) && selectorSeparatorNewline && !insidePropertyValue && parenLevel < 1) {
479
- print.newLine();
557
+ output.add_new_line();
480
558
  } else {
481
- print.singleSpace();
559
+ output.space_before_token = true;
482
560
  }
483
561
  } else if ((ch === '>' || ch === '+' || ch === '~') &&
484
562
  !insidePropertyValue && parenLevel < 1) {
485
563
  //handle combinator spacing
486
564
  if (space_around_combinator) {
487
- print.singleSpace();
488
- output.push(ch);
489
- print.singleSpace();
565
+ output.space_before_token = true;
566
+ print_string(ch);
567
+ output.space_before_token = true;
490
568
  } else {
491
- output.push(ch);
569
+ print_string(ch);
492
570
  eatWhitespace();
493
571
  // squash extra whitespace
494
572
  if (ch && whiteRe.test(ch)) {
@@ -496,44 +574,30 @@
496
574
  }
497
575
  }
498
576
  } else if (ch === ']') {
499
- output.push(ch);
577
+ print_string(ch);
500
578
  } else if (ch === '[') {
501
- print.preserveSingleSpace();
502
- output.push(ch);
579
+ preserveSingleSpace(isAfterSpace);
580
+ print_string(ch);
503
581
  } else if (ch === '=') { // no whitespace before or after
504
582
  eatWhitespace();
505
- output.push('=');
583
+ print_string('=');
506
584
  if (whiteRe.test(ch)) {
507
585
  ch = '';
508
586
  }
587
+
509
588
  } else {
510
- print.preserveSingleSpace();
511
- output.push(ch);
589
+ preserveSingleSpace(isAfterSpace);
590
+ print_string(ch);
512
591
  }
513
592
  }
514
593
 
515
-
516
- var sweetCode = '';
517
- if (basebaseIndentString) {
518
- sweetCode += basebaseIndentString;
519
- }
520
-
521
- sweetCode += output.join('').replace(/[\r\n\t ]+$/, '');
522
-
523
- // establish end_with_newline
524
- if (end_with_newline) {
525
- sweetCode += '\n';
526
- }
527
-
528
- if (eol !== '\n') {
529
- sweetCode = sweetCode.replace(/[\n]/g, eol);
530
- }
594
+ var sweetCode = output.get_code(end_with_newline, eol);
531
595
 
532
596
  return sweetCode;
533
- }
597
+ };
534
598
 
535
599
  // https://developer.mozilla.org/en-US/docs/Web/CSS/At-rule
536
- css_beautify.NESTED_AT_RULE = {
600
+ this.NESTED_AT_RULE = {
537
601
  "@page": true,
538
602
  "@font-face": true,
539
603
  "@keyframes": true,
@@ -542,30 +606,441 @@
542
606
  "@supports": true,
543
607
  "@document": true
544
608
  };
545
- css_beautify.CONDITIONAL_GROUP_RULE = {
609
+ this.CONDITIONAL_GROUP_RULE = {
546
610
  "@media": true,
547
611
  "@supports": true,
548
612
  "@document": true
549
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
+ };
550
674
 
551
- /*global define */
552
- if (typeof define === "function" && define.amd) {
553
- // Add support for AMD ( https://github.com/amdjs/amdjs-api/wiki/AMD#defineamd-property- )
554
- define([], function() {
555
- return {
556
- css_beautify: css_beautify
557
- };
558
- });
559
- } else if (typeof exports !== "undefined") {
560
- // Add support for CommonJS. Just put this file somewhere on your require.paths
561
- // and you will be able to `var html_beautify = require("beautify").html_beautify`.
562
- exports.css_beautify = css_beautify;
563
- } else if (typeof window !== "undefined") {
564
- // If we're running a web page and don't have either of the above, add our one global
565
- window.css_beautify = css_beautify;
566
- } else if (typeof global !== "undefined") {
567
- // If we don't even have window, try global.
568
- global.css_beautify = css_beautify;
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
+ }
569
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
+ };
570
833
 
571
- }());
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
+ }());