| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426 |
-
- /* AUTO-GENERATED. DO NOT MODIFY. */
- /*
- The MIT License (MIT)
- Copyright (c) 2007-2018 Einar Lielmanis, Liam Newman, and contributors.
- Permission is hereby granted, free of charge, to any person
- obtaining a copy of this software and associated documentation files
- (the "Software"), to deal in the Software without restriction,
- including without limitation the rights to use, copy, modify, merge,
- publish, distribute, sublicense, and/or sell copies of the Software,
- and to permit persons to whom the Software is furnished to do so,
- subject to the following conditions:
- The above copyright notice and this permission notice shall be
- included in all copies or substantial portions of the Software.
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- SOFTWARE.
- CSS Beautifier
- ---------------
- Written by Harutyun Amirjanyan, (amirjanyan@gmail.com)
- Based on code initially developed by: Einar Lielmanis, <einar@beautifier.io>
- https://beautifier.io/
- Usage:
- css_beautify(source_text);
- css_beautify(source_text, options);
- The options are (default in brackets):
- indent_size (4) 鈥� indentation size,
- indent_char (space) 鈥� character to indent with,
- selector_separator_newline (true) - separate selectors with newline or
- not (e.g. "a,\nbr" or "a, br")
- end_with_newline (false) - end with a newline
- newline_between_rules (true) - add a new line after every css rule
- space_around_selector_separator (false) - ensure space around selector separators:
- '>', '+', '~' (e.g. "a>b" -> "a > b")
- e.g
- css_beautify(css_source_text, {
- 'indent_size': 1,
- 'indent_char': '\t',
- 'selector_separator': ' ',
- 'end_with_newline': false,
- 'newline_between_rules': true,
- 'space_around_selector_separator': true
- });
- */
- // http://www.w3.org/TR/CSS21/syndata.html#tokenization
- // http://www.w3.org/TR/css3-syntax/
- (function() {
- /* GENERATED_BUILD_OUTPUT */
- var legacy_beautify_css =
- /******/ (function(modules) { // webpackBootstrap
- /******/ // The module cache
- /******/ var installedModules = {};
- /******/
- /******/ // The require function
- /******/ function __webpack_require__(moduleId) {
- /******/
- /******/ // Check if module is in cache
- /******/ if(installedModules[moduleId]) {
- /******/ return installedModules[moduleId].exports;
- /******/ }
- /******/ // Create a new module (and put it into the cache)
- /******/ var module = installedModules[moduleId] = {
- /******/ i: moduleId,
- /******/ l: false,
- /******/ exports: {}
- /******/ };
- /******/
- /******/ // Execute the module function
- /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
- /******/
- /******/ // Flag the module as loaded
- /******/ module.l = true;
- /******/
- /******/ // Return the exports of the module
- /******/ return module.exports;
- /******/ }
- /******/
- /******/
- /******/ // expose the modules object (__webpack_modules__)
- /******/ __webpack_require__.m = modules;
- /******/
- /******/ // expose the module cache
- /******/ __webpack_require__.c = installedModules;
- /******/
- /******/ // define getter function for harmony exports
- /******/ __webpack_require__.d = function(exports, name, getter) {
- /******/ if(!__webpack_require__.o(exports, name)) {
- /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
- /******/ }
- /******/ };
- /******/
- /******/ // define __esModule on exports
- /******/ __webpack_require__.r = function(exports) {
- /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
- /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
- /******/ }
- /******/ Object.defineProperty(exports, '__esModule', { value: true });
- /******/ };
- /******/
- /******/ // create a fake namespace object
- /******/ // mode & 1: value is a module id, require it
- /******/ // mode & 2: merge all properties of value into the ns
- /******/ // mode & 4: return value when already ns object
- /******/ // mode & 8|1: behave like require
- /******/ __webpack_require__.t = function(value, mode) {
- /******/ if(mode & 1) value = __webpack_require__(value);
- /******/ if(mode & 8) return value;
- /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
- /******/ var ns = Object.create(null);
- /******/ __webpack_require__.r(ns);
- /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
- /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
- /******/ return ns;
- /******/ };
- /******/
- /******/ // getDefaultExport function for compatibility with non-harmony modules
- /******/ __webpack_require__.n = function(module) {
- /******/ var getter = module && module.__esModule ?
- /******/ function getDefault() { return module['default']; } :
- /******/ function getModuleExports() { return module; };
- /******/ __webpack_require__.d(getter, 'a', getter);
- /******/ return getter;
- /******/ };
- /******/
- /******/ // Object.prototype.hasOwnProperty.call
- /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
- /******/
- /******/ // __webpack_public_path__
- /******/ __webpack_require__.p = "";
- /******/
- /******/
- /******/ // Load entry module and return exports
- /******/ return __webpack_require__(__webpack_require__.s = 12);
- /******/ })
- /************************************************************************/
- /******/ ([
- /* 0 */,
- /* 1 */,
- /* 2 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- /*jshint node:true */
- /*
- The MIT License (MIT)
- Copyright (c) 2007-2018 Einar Lielmanis, Liam Newman, and contributors.
- Permission is hereby granted, free of charge, to any person
- obtaining a copy of this software and associated documentation files
- (the "Software"), to deal in the Software without restriction,
- including without limitation the rights to use, copy, modify, merge,
- publish, distribute, sublicense, and/or sell copies of the Software,
- and to permit persons to whom the Software is furnished to do so,
- subject to the following conditions:
- The above copyright notice and this permission notice shall be
- included in all copies or substantial portions of the Software.
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- SOFTWARE.
- */
- function OutputLine(parent) {
- this.__parent = parent;
- this.__character_count = 0;
- // use indent_count as a marker for this.__lines that have preserved indentation
- this.__indent_count = -1;
- this.__alignment_count = 0;
- this.__items = [];
- }
- OutputLine.prototype.item = function(index) {
- if (index < 0) {
- return this.__items[this.__items.length + index];
- } else {
- return this.__items[index];
- }
- };
- OutputLine.prototype.has_match = function(pattern) {
- for (var lastCheckedOutput = this.__items.length - 1; lastCheckedOutput >= 0; lastCheckedOutput--) {
- if (this.__items[lastCheckedOutput].match(pattern)) {
- return true;
- }
- }
- return false;
- };
- OutputLine.prototype.set_indent = function(indent, alignment) {
- this.__indent_count = indent || 0;
- this.__alignment_count = alignment || 0;
- this.__character_count = this.__parent.get_indent_size(this.__indent_count, this.__alignment_count);
- };
- OutputLine.prototype.get_character_count = function() {
- return this.__character_count;
- };
- OutputLine.prototype.is_empty = function() {
- return this.__items.length === 0;
- };
- OutputLine.prototype.last = function() {
- if (!this.is_empty()) {
- return this.__items[this.__items.length - 1];
- } else {
- return null;
- }
- };
- OutputLine.prototype.push = function(item) {
- this.__items.push(item);
- this.__character_count += item.length;
- };
- OutputLine.prototype.push_raw = function(item) {
- this.push(item);
- var last_newline_index = item.lastIndexOf('\n');
- if (last_newline_index !== -1) {
- this.__character_count = item.length - last_newline_index;
- }
- };
- OutputLine.prototype.pop = function() {
- var item = null;
- if (!this.is_empty()) {
- item = this.__items.pop();
- this.__character_count -= item.length;
- }
- return item;
- };
- OutputLine.prototype.remove_indent = function() {
- if (this.__indent_count > 0) {
- this.__indent_count -= 1;
- this.__character_count -= this.__parent.indent_size;
- }
- };
- OutputLine.prototype.trim = function() {
- while (this.last() === ' ') {
- this.__items.pop();
- this.__character_count -= 1;
- }
- };
- OutputLine.prototype.toString = function() {
- var result = '';
- if (!this.is_empty()) {
- result = this.__parent.get_indent_string(this.__indent_count, this.__alignment_count);
- result += this.__items.join('');
- }
- return result;
- };
- function IndentStringCache(options, baseIndentString) {
- this.__cache = [''];
- this.__indent_size = options.indent_size;
- this.__indent_string = options.indent_char;
- if (!options.indent_with_tabs) {
- this.__indent_string = new Array(options.indent_size + 1).join(options.indent_char);
- }
- // Set to null to continue support for auto detection of base indent
- baseIndentString = baseIndentString || '';
- if (options.indent_level > 0) {
- baseIndentString = new Array(options.indent_level + 1).join(this.__indent_string);
- }
- this.__base_string = baseIndentString;
- this.__base_string_length = baseIndentString.length;
- }
- IndentStringCache.prototype.get_indent_size = function(indent, column) {
- var result = this.__base_string_length;
- column = column || 0;
- if (indent < 0) {
- result = 0;
- }
- result += indent * this.__indent_size;
- result += column;
- return result;
- };
- IndentStringCache.prototype.get_indent_string = function(indent_level, column) {
- var result = this.__base_string;
- column = column || 0;
- if (indent_level < 0) {
- indent_level = 0;
- result = '';
- }
- column += indent_level * this.__indent_size;
- this.__ensure_cache(column);
- result += this.__cache[column];
- return result;
- };
- IndentStringCache.prototype.__ensure_cache = function(column) {
- while (column >= this.__cache.length) {
- this.__add_column();
- }
- };
- IndentStringCache.prototype.__add_column = function() {
- var column = this.__cache.length;
- var indent = 0;
- var result = '';
- if (this.__indent_size && column >= this.__indent_size) {
- indent = Math.floor(column / this.__indent_size);
- column -= indent * this.__indent_size;
- result = new Array(indent + 1).join(this.__indent_string);
- }
- if (column) {
- result += new Array(column + 1).join(' ');
- }
- this.__cache.push(result);
- };
- function Output(options, baseIndentString) {
- this.__indent_cache = new IndentStringCache(options, baseIndentString);
- this.raw = false;
- this._end_with_newline = options.end_with_newline;
- this.indent_size = options.indent_size;
- this.__lines = [];
- this.previous_line = null;
- this.current_line = null;
- this.space_before_token = false;
- // initialize
- this.__add_outputline();
- }
- Output.prototype.__add_outputline = function() {
- this.previous_line = this.current_line;
- this.current_line = new OutputLine(this);
- this.__lines.push(this.current_line);
- };
- Output.prototype.get_line_number = function() {
- return this.__lines.length;
- };
- Output.prototype.get_indent_string = function(indent, column) {
- return this.__indent_cache.get_indent_string(indent, column);
- };
- Output.prototype.get_indent_size = function(indent, column) {
- return this.__indent_cache.get_indent_size(indent, column);
- };
- Output.prototype.is_empty = function() {
- return !this.previous_line && this.current_line.is_empty();
- };
- Output.prototype.add_new_line = function(force_newline) {
- // never newline at the start of file
- // otherwise, newline only if we didn't just add one or we're forced
- if (this.is_empty() ||
- (!force_newline && this.just_added_newline())) {
- return false;
- }
- // if raw output is enabled, don't print additional newlines,
- // but still return True as though you had
- if (!this.raw) {
- this.__add_outputline();
- }
- return true;
- };
- Output.prototype.get_code = function(eol) {
- var sweet_code = this.__lines.join('\n').replace(/[\r\n\t ]+$/, '');
- if (this._end_with_newline) {
- sweet_code += '\n';
- }
- if (eol !== '\n') {
- sweet_code = sweet_code.replace(/[\n]/g, eol);
- }
- return sweet_code;
- };
- Output.prototype.set_indent = function(indent, alignment) {
- indent = indent || 0;
- alignment = alignment || 0;
- // Never indent your first output indent at the start of the file
- if (this.__lines.length > 1) {
- this.current_line.set_indent(indent, alignment);
- return true;
- }
- this.current_line.set_indent();
- return false;
- };
- Output.prototype.add_raw_token = function(token) {
- for (var x = 0; x < token.newlines; x++) {
- this.__add_outputline();
- }
- this.current_line.push(token.whitespace_before);
- this.current_line.push_raw(token.text);
- this.space_before_token = false;
- };
- Output.prototype.add_token = function(printable_token) {
- this.add_space_before_token();
- this.current_line.push(printable_token);
- };
- Output.prototype.add_space_before_token = function() {
- if (this.space_before_token && !this.just_added_newline()) {
- this.current_line.push(' ');
- }
- this.space_before_token = false;
- };
- Output.prototype.remove_indent = function(index) {
- var output_length = this.__lines.length;
- while (index < output_length) {
- this.__lines[index].remove_indent();
- index++;
- }
- };
- Output.prototype.trim = function(eat_newlines) {
- eat_newlines = (eat_newlines === undefined) ? false : eat_newlines;
- this.current_line.trim(this.indent_string, this.baseIndentString);
- while (eat_newlines && this.__lines.length > 1 &&
- this.current_line.is_empty()) {
- this.__lines.pop();
- this.current_line = this.__lines[this.__lines.length - 1];
- this.current_line.trim();
- }
- this.previous_line = this.__lines.length > 1 ?
- this.__lines[this.__lines.length - 2] : null;
- };
- Output.prototype.just_added_newline = function() {
- return this.current_line.is_empty();
- };
- Output.prototype.just_added_blankline = function() {
- return this.is_empty() ||
- (this.current_line.is_empty() && this.previous_line.is_empty());
- };
- Output.prototype.ensure_empty_line_above = function(starts_with, ends_with) {
- var index = this.__lines.length - 2;
- while (index >= 0) {
- var potentialEmptyLine = this.__lines[index];
- if (potentialEmptyLine.is_empty()) {
- break;
- } else if (potentialEmptyLine.item(0).indexOf(starts_with) !== 0 &&
- potentialEmptyLine.item(-1) !== ends_with) {
- this.__lines.splice(index + 1, 0, new OutputLine(this));
- this.previous_line = this.__lines[this.__lines.length - 2];
- break;
- }
- index--;
- }
- };
- module.exports.Output = Output;
- /***/ }),
- /* 3 */,
- /* 4 */,
- /* 5 */,
- /* 6 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- /*jshint node:true */
- /*
- The MIT License (MIT)
- Copyright (c) 2007-2018 Einar Lielmanis, Liam Newman, and contributors.
- Permission is hereby granted, free of charge, to any person
- obtaining a copy of this software and associated documentation files
- (the "Software"), to deal in the Software without restriction,
- including without limitation the rights to use, copy, modify, merge,
- publish, distribute, sublicense, and/or sell copies of the Software,
- and to permit persons to whom the Software is furnished to do so,
- subject to the following conditions:
- The above copyright notice and this permission notice shall be
- included in all copies or substantial portions of the Software.
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- SOFTWARE.
- */
- function Options(options, merge_child_field) {
- this.raw_options = _mergeOpts(options, merge_child_field);
- // Support passing the source text back with no change
- this.disabled = this._get_boolean('disabled');
- this.eol = this._get_characters('eol', 'auto');
- this.end_with_newline = this._get_boolean('end_with_newline');
- this.indent_size = this._get_number('indent_size', 4);
- this.indent_char = this._get_characters('indent_char', ' ');
- this.indent_level = this._get_number('indent_level');
- this.preserve_newlines = this._get_boolean('preserve_newlines', true);
- this.max_preserve_newlines = this._get_number('max_preserve_newlines', 32786);
- if (!this.preserve_newlines) {
- this.max_preserve_newlines = 0;
- }
- this.indent_with_tabs = this._get_boolean('indent_with_tabs', this.indent_char === '\t');
- if (this.indent_with_tabs) {
- this.indent_char = '\t';
- // indent_size behavior changed after 1.8.6
- // It used to be that indent_size would be
- // set to 1 for indent_with_tabs. That is no longer needed and
- // actually doesn't make sense - why not use spaces? Further,
- // that might produce unexpected behavior - tabs being used
- // for single-column alignment. So, when indent_with_tabs is true
- // and indent_size is 1, reset indent_size to 4.
- if (this.indent_size === 1) {
- this.indent_size = 4;
- }
- }
- // Backwards compat with 1.3.x
- this.wrap_line_length = this._get_number('wrap_line_length', this._get_number('max_char'));
- }
- Options.prototype._get_array = function(name, default_value) {
- var option_value = this.raw_options[name];
- var result = default_value || [];
- if (typeof option_value === 'object') {
- if (option_value !== null && typeof option_value.concat === 'function') {
- result = option_value.concat();
- }
- } else if (typeof option_value === 'string') {
- result = option_value.split(/[^a-zA-Z0-9_\/\-]+/);
- }
- return result;
- };
- Options.prototype._get_boolean = function(name, default_value) {
- var option_value = this.raw_options[name];
- var result = option_value === undefined ? !!default_value : !!option_value;
- return result;
- };
- Options.prototype._get_characters = function(name, default_value) {
- var option_value = this.raw_options[name];
- var result = default_value || '';
- if (typeof option_value === 'string') {
- result = option_value.replace(/\\r/, '\r').replace(/\\n/, '\n').replace(/\\t/, '\t');
- }
- return result;
- };
- Options.prototype._get_number = function(name, default_value) {
- var option_value = this.raw_options[name];
- default_value = parseInt(default_value, 10);
- if (isNaN(default_value)) {
- default_value = 0;
- }
- var result = parseInt(option_value, 10);
- if (isNaN(result)) {
- result = default_value;
- }
- return result;
- };
- Options.prototype._get_selection = function(name, selection_list, default_value) {
- var result = this._get_selection_list(name, selection_list, default_value);
- if (result.length !== 1) {
- throw new Error(
- "Invalid Option Value: The option '" + name + "' can only be one of the following values:\n" +
- selection_list + "\nYou passed in: '" + this.raw_options[name] + "'");
- }
- return result[0];
- };
- Options.prototype._get_selection_list = function(name, selection_list, default_value) {
- if (!selection_list || selection_list.length === 0) {
- throw new Error("Selection list cannot be empty.");
- }
- default_value = default_value || [selection_list[0]];
- if (!this._is_valid_selection(default_value, selection_list)) {
- throw new Error("Invalid Default Value!");
- }
- var result = this._get_array(name, default_value);
- if (!this._is_valid_selection(result, selection_list)) {
- throw new Error(
- "Invalid Option Value: The option '" + name + "' can contain only the following values:\n" +
- selection_list + "\nYou passed in: '" + this.raw_options[name] + "'");
- }
- return result;
- };
- Options.prototype._is_valid_selection = function(result, selection_list) {
- return result.length && selection_list.length &&
- !result.some(function(item) { return selection_list.indexOf(item) === -1; });
- };
- // merges child options up with the parent options object
- // Example: obj = {a: 1, b: {a: 2}}
- // mergeOpts(obj, 'b')
- //
- // Returns: {a: 2}
- function _mergeOpts(allOptions, childFieldName) {
- var finalOpts = {};
- allOptions = _normalizeOpts(allOptions);
- var name;
- for (name in allOptions) {
- if (name !== childFieldName) {
- finalOpts[name] = allOptions[name];
- }
- }
- //merge in the per type settings for the childFieldName
- if (childFieldName && allOptions[childFieldName]) {
- for (name in allOptions[childFieldName]) {
- finalOpts[name] = allOptions[childFieldName][name];
- }
- }
- return finalOpts;
- }
- function _normalizeOpts(options) {
- var convertedOpts = {};
- var key;
- for (key in options) {
- var newKey = key.replace(/-/g, "_");
- convertedOpts[newKey] = options[key];
- }
- return convertedOpts;
- }
- module.exports.Options = Options;
- module.exports.normalizeOpts = _normalizeOpts;
- module.exports.mergeOpts = _mergeOpts;
- /***/ }),
- /* 7 */,
- /* 8 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- /*jshint node:true */
- /*
- The MIT License (MIT)
- Copyright (c) 2007-2018 Einar Lielmanis, Liam Newman, and contributors.
- Permission is hereby granted, free of charge, to any person
- obtaining a copy of this software and associated documentation files
- (the "Software"), to deal in the Software without restriction,
- including without limitation the rights to use, copy, modify, merge,
- publish, distribute, sublicense, and/or sell copies of the Software,
- and to permit persons to whom the Software is furnished to do so,
- subject to the following conditions:
- The above copyright notice and this permission notice shall be
- included in all copies or substantial portions of the Software.
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- SOFTWARE.
- */
- function InputScanner(input_string) {
- this.__input = input_string || '';
- this.__input_length = this.__input.length;
- this.__position = 0;
- }
- InputScanner.prototype.restart = function() {
- this.__position = 0;
- };
- InputScanner.prototype.back = function() {
- if (this.__position > 0) {
- this.__position -= 1;
- }
- };
- InputScanner.prototype.hasNext = function() {
- return this.__position < this.__input_length;
- };
- InputScanner.prototype.next = function() {
- var val = null;
- if (this.hasNext()) {
- val = this.__input.charAt(this.__position);
- this.__position += 1;
- }
- return val;
- };
- InputScanner.prototype.peek = function(index) {
- var val = null;
- index = index || 0;
- index += this.__position;
- if (index >= 0 && index < this.__input_length) {
- val = this.__input.charAt(index);
- }
- return val;
- };
- InputScanner.prototype.test = function(pattern, index) {
- index = index || 0;
- index += this.__position;
- pattern.lastIndex = index;
- if (index >= 0 && index < this.__input_length) {
- var pattern_match = pattern.exec(this.__input);
- return pattern_match && pattern_match.index === index;
- } else {
- return false;
- }
- };
- InputScanner.prototype.testChar = function(pattern, index) {
- // test one character regex match
- var val = this.peek(index);
- return val !== null && pattern.test(val);
- };
- InputScanner.prototype.match = function(pattern) {
- pattern.lastIndex = this.__position;
- var pattern_match = pattern.exec(this.__input);
- if (pattern_match && pattern_match.index === this.__position) {
- this.__position += pattern_match[0].length;
- } else {
- pattern_match = null;
- }
- return pattern_match;
- };
- InputScanner.prototype.read = function(pattern) {
- var val = '';
- var match = this.match(pattern);
- if (match) {
- val = match[0];
- }
- return val;
- };
- InputScanner.prototype.readUntil = function(pattern, include_match) {
- var val = '';
- var match_index = this.__position;
- pattern.lastIndex = this.__position;
- var pattern_match = pattern.exec(this.__input);
- if (pattern_match) {
- if (include_match) {
- match_index = pattern_match.index + pattern_match[0].length;
- } else {
- match_index = pattern_match.index;
- }
- } else {
- match_index = this.__input_length;
- }
- val = this.__input.substring(this.__position, match_index);
- this.__position = match_index;
- return val;
- };
- InputScanner.prototype.readUntilAfter = function(pattern) {
- return this.readUntil(pattern, true);
- };
- /* css beautifier legacy helpers */
- InputScanner.prototype.peekUntilAfter = function(pattern) {
- var start = this.__position;
- var val = this.readUntilAfter(pattern);
- this.__position = start;
- return val;
- };
- InputScanner.prototype.lookBack = function(testVal) {
- var start = this.__position - 1;
- return start >= testVal.length && this.__input.substring(start - testVal.length, start)
- .toLowerCase() === testVal;
- };
- module.exports.InputScanner = InputScanner;
- /***/ }),
- /* 9 */,
- /* 10 */,
- /* 11 */,
- /* 12 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- /*jshint node:true */
- /*
- The MIT License (MIT)
- Copyright (c) 2007-2018 Einar Lielmanis, Liam Newman, and contributors.
- Permission is hereby granted, free of charge, to any person
- obtaining a copy of this software and associated documentation files
- (the "Software"), to deal in the Software without restriction,
- including without limitation the rights to use, copy, modify, merge,
- publish, distribute, sublicense, and/or sell copies of the Software,
- and to permit persons to whom the Software is furnished to do so,
- subject to the following conditions:
- The above copyright notice and this permission notice shall be
- included in all copies or substantial portions of the Software.
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- SOFTWARE.
- */
- var Beautifier = __webpack_require__(13).Beautifier,
- Options = __webpack_require__(14).Options;
- function css_beautify(source_text, options) {
- var beautifier = new Beautifier(source_text, options);
- return beautifier.beautify();
- }
- module.exports = css_beautify;
- module.exports.defaultOptions = function() {
- return new Options();
- };
- /***/ }),
- /* 13 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- /*jshint node:true */
- /*
- The MIT License (MIT)
- Copyright (c) 2007-2018 Einar Lielmanis, Liam Newman, and contributors.
- Permission is hereby granted, free of charge, to any person
- obtaining a copy of this software and associated documentation files
- (the "Software"), to deal in the Software without restriction,
- including without limitation the rights to use, copy, modify, merge,
- publish, distribute, sublicense, and/or sell copies of the Software,
- and to permit persons to whom the Software is furnished to do so,
- subject to the following conditions:
- The above copyright notice and this permission notice shall be
- included in all copies or substantial portions of the Software.
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- SOFTWARE.
- */
- var Options = __webpack_require__(14).Options;
- var Output = __webpack_require__(2).Output;
- var InputScanner = __webpack_require__(8).InputScanner;
- var lineBreak = /\r\n|[\r\n]/;
- var allLineBreaks = /\r\n|[\r\n]/g;
- // tokenizer
- var whitespaceChar = /\s/;
- var whitespacePattern = /(?:\s|\n)+/g;
- var block_comment_pattern = /\/\*(?:[\s\S]*?)((?:\*\/)|$)/g;
- var comment_pattern = /\/\/(?:[^\n\r\u2028\u2029]*)/g;
- function Beautifier(source_text, options) {
- this._source_text = source_text || '';
- // Allow the setting of language/file-type specific options
- // with inheritance of overall settings
- this._options = new Options(options);
- this._ch = null;
- this._input = null;
- // https://developer.mozilla.org/en-US/docs/Web/CSS/At-rule
- this.NESTED_AT_RULE = {
- "@page": true,
- "@font-face": true,
- "@keyframes": true,
- // also in CONDITIONAL_GROUP_RULE below
- "@media": true,
- "@supports": true,
- "@document": true
- };
- this.CONDITIONAL_GROUP_RULE = {
- "@media": true,
- "@supports": true,
- "@document": true
- };
- }
- Beautifier.prototype.eatString = function(endChars) {
- var result = '';
- this._ch = this._input.next();
- while (this._ch) {
- result += this._ch;
- if (this._ch === "\\") {
- result += this._input.next();
- } else if (endChars.indexOf(this._ch) !== -1 || this._ch === "\n") {
- break;
- }
- this._ch = this._input.next();
- }
- return result;
- };
- // Skips any white space in the source text from the current position.
- // When allowAtLeastOneNewLine is true, will output new lines for each
- // newline character found; if the user has preserve_newlines off, only
- // the first newline will be output
- Beautifier.prototype.eatWhitespace = function(allowAtLeastOneNewLine) {
- var result = whitespaceChar.test(this._input.peek());
- var isFirstNewLine = true;
- while (whitespaceChar.test(this._input.peek())) {
- this._ch = this._input.next();
- if (allowAtLeastOneNewLine && this._ch === '\n') {
- if (this._options.preserve_newlines || isFirstNewLine) {
- isFirstNewLine = false;
- this._output.add_new_line(true);
- }
- }
- }
- return result;
- };
- // Nested pseudo-class if we are insideRule
- // and the next special character found opens
- // a new block
- Beautifier.prototype.foundNestedPseudoClass = function() {
- var openParen = 0;
- var i = 1;
- var ch = this._input.peek(i);
- while (ch) {
- if (ch === "{") {
- return true;
- } else if (ch === '(') {
- // pseudoclasses can contain ()
- openParen += 1;
- } else if (ch === ')') {
- if (openParen === 0) {
- return false;
- }
- openParen -= 1;
- } else if (ch === ";" || ch === "}") {
- return false;
- }
- i++;
- ch = this._input.peek(i);
- }
- return false;
- };
- Beautifier.prototype.print_string = function(output_string) {
- if (this._output.just_added_newline()) {
- this._output.set_indent(this._indentLevel);
- }
- this._output.add_token(output_string);
- };
- Beautifier.prototype.preserveSingleSpace = function(isAfterSpace) {
- if (isAfterSpace) {
- this._output.space_before_token = true;
- }
- };
- Beautifier.prototype.indent = function() {
- this._indentLevel++;
- };
- Beautifier.prototype.outdent = function() {
- if (this._indentLevel > 0) {
- this._indentLevel--;
- }
- };
- /*_____________________--------------------_____________________*/
- Beautifier.prototype.beautify = function() {
- if (this._options.disabled) {
- return this._source_text;
- }
- var source_text = this._source_text;
- var eol = this._options.eol;
- if (eol === 'auto') {
- eol = '\n';
- if (source_text && lineBreak.test(source_text || '')) {
- eol = source_text.match(lineBreak)[0];
- }
- }
- // HACK: newline parsing inconsistent. This brute force normalizes the this._input.
- source_text = source_text.replace(allLineBreaks, '\n');
- // reset
- var baseIndentString = source_text.match(/^[\t ]*/)[0];
- this._output = new Output(this._options, baseIndentString);
- this._input = new InputScanner(source_text);
- this._indentLevel = 0;
- this._nestedLevel = 0;
- this._ch = null;
- var parenLevel = 0;
- var insideRule = false;
- // This is the value side of a property value pair (blue in the following ex)
- // label { content: blue }
- var insidePropertyValue = false;
- var enteringConditionalGroup = false;
- var insideAtExtend = false;
- var insideAtImport = false;
- var topCharacter = this._ch;
- while (true) {
- var whitespace = this._input.read(whitespacePattern);
- var isAfterSpace = whitespace !== '';
- var previous_ch = topCharacter;
- this._ch = this._input.next();
- topCharacter = this._ch;
- if (!this._ch) {
- break;
- } else if (this._ch === '/' && this._input.peek() === '*') {
- // /* css comment */
- // Always start block comments on a new line.
- // This handles scenarios where a block comment immediately
- // follows a property definition on the same line or where
- // minified code is being beautified.
- this._output.add_new_line();
- this._input.back();
- this.print_string(this._input.read(block_comment_pattern));
- // Ensures any new lines following the comment are preserved
- this.eatWhitespace(true);
- // Block comments are followed by a new line so they don't
- // share a line with other properties
- this._output.add_new_line();
- } else if (this._ch === '/' && this._input.peek() === '/') {
- // // single line comment
- // Preserves the space before a comment
- // on the same line as a rule
- this._output.space_before_token = true;
- this._input.back();
- this.print_string(this._input.read(comment_pattern));
- // Ensures any new lines following the comment are preserved
- this.eatWhitespace(true);
- } else if (this._ch === '@') {
- this.preserveSingleSpace(isAfterSpace);
- // deal with less propery mixins @{...}
- if (this._input.peek() === '{') {
- this.print_string(this._ch + this.eatString('}'));
- } else {
- this.print_string(this._ch);
- // strip trailing space, if present, for hash property checks
- var variableOrRule = this._input.peekUntilAfter(/[: ,;{}()[\]\/='"]/g);
- if (variableOrRule.match(/[ :]$/)) {
- // we have a variable or pseudo-class, add it and insert one space before continuing
- variableOrRule = this.eatString(": ").replace(/\s$/, '');
- this.print_string(variableOrRule);
- this._output.space_before_token = true;
- }
- variableOrRule = variableOrRule.replace(/\s$/, '');
- if (variableOrRule === 'extend') {
- insideAtExtend = true;
- } else if (variableOrRule === 'import') {
- insideAtImport = true;
- }
- // might be a nesting at-rule
- if (variableOrRule in this.NESTED_AT_RULE) {
- this._nestedLevel += 1;
- if (variableOrRule in this.CONDITIONAL_GROUP_RULE) {
- enteringConditionalGroup = true;
- }
- // might be less variable
- } else if (!insideRule && parenLevel === 0 && variableOrRule.indexOf(':') !== -1) {
- insidePropertyValue = true;
- this.indent();
- }
- }
- } else if (this._ch === '#' && this._input.peek() === '{') {
- this.preserveSingleSpace(isAfterSpace);
- this.print_string(this._ch + this.eatString('}'));
- } else if (this._ch === '{') {
- if (insidePropertyValue) {
- insidePropertyValue = false;
- this.outdent();
- }
- this.indent();
- this._output.space_before_token = true;
- this.print_string(this._ch);
- // when entering conditional groups, only rulesets are allowed
- if (enteringConditionalGroup) {
- enteringConditionalGroup = false;
- insideRule = (this._indentLevel > this._nestedLevel);
- } else {
- // otherwise, declarations are also allowed
- insideRule = (this._indentLevel >= this._nestedLevel);
- }
- if (this._options.newline_between_rules && insideRule) {
- if (this._output.previous_line && this._output.previous_line.item(-1) !== '{') {
- this._output.ensure_empty_line_above('/', ',');
- }
- }
- this.eatWhitespace(true);
- this._output.add_new_line();
- } else if (this._ch === '}') {
- this.outdent();
- this._output.add_new_line();
- if (previous_ch === '{') {
- this._output.trim(true);
- }
- insideAtImport = false;
- insideAtExtend = false;
- if (insidePropertyValue) {
- this.outdent();
- insidePropertyValue = false;
- }
- this.print_string(this._ch);
- insideRule = false;
- if (this._nestedLevel) {
- this._nestedLevel--;
- }
- this.eatWhitespace(true);
- this._output.add_new_line();
- if (this._options.newline_between_rules && !this._output.just_added_blankline()) {
- if (this._input.peek() !== '}') {
- this._output.add_new_line(true);
- }
- }
- } else if (this._ch === ":") {
- if ((insideRule || enteringConditionalGroup) && !(this._input.lookBack("&") || this.foundNestedPseudoClass()) && !this._input.lookBack("(") && !insideAtExtend) {
- // 'property: value' delimiter
- // which could be in a conditional group query
- this.print_string(':');
- if (!insidePropertyValue) {
- insidePropertyValue = true;
- this._output.space_before_token = true;
- this.eatWhitespace(true);
- this.indent();
- }
- } else {
- // sass/less parent reference don't use a space
- // sass nested pseudo-class don't use a space
- // preserve space before pseudoclasses/pseudoelements, as it means "in any child"
- if (this._input.lookBack(" ")) {
- this._output.space_before_token = true;
- }
- if (this._input.peek() === ":") {
- // pseudo-element
- this._ch = this._input.next();
- this.print_string("::");
- } else {
- // pseudo-class
- this.print_string(':');
- }
- }
- } else if (this._ch === '"' || this._ch === '\'') {
- this.preserveSingleSpace(isAfterSpace);
- this.print_string(this._ch + this.eatString(this._ch));
- this.eatWhitespace(true);
- } else if (this._ch === ';') {
- if (insidePropertyValue) {
- this.outdent();
- insidePropertyValue = false;
- }
- insideAtExtend = false;
- insideAtImport = false;
- this.print_string(this._ch);
- this.eatWhitespace(true);
- // This maintains single line comments on the same
- // line. Block comments are also affected, but
- // a new line is always output before one inside
- // that section
- if (this._input.peek() !== '/') {
- this._output.add_new_line();
- }
- } else if (this._ch === '(') { // may be a url
- if (this._input.lookBack("url")) {
- this.print_string(this._ch);
- this.eatWhitespace();
- this._ch = this._input.next();
- if (this._ch === ')' || this._ch === '"' || this._ch === '\'') {
- this._input.back();
- parenLevel++;
- } else if (this._ch) {
- this.print_string(this._ch + this.eatString(')'));
- }
- } else {
- parenLevel++;
- this.preserveSingleSpace(isAfterSpace);
- this.print_string(this._ch);
- this.eatWhitespace();
- }
- } else if (this._ch === ')') {
- this.print_string(this._ch);
- parenLevel--;
- } else if (this._ch === ',') {
- this.print_string(this._ch);
- this.eatWhitespace(true);
- if (this._options.selector_separator_newline && !insidePropertyValue && parenLevel < 1 && !insideAtImport) {
- this._output.add_new_line();
- } else {
- this._output.space_before_token = true;
- }
- } else if ((this._ch === '>' || this._ch === '+' || this._ch === '~') && !insidePropertyValue && parenLevel < 1) {
- //handle combinator spacing
- if (this._options.space_around_combinator) {
- this._output.space_before_token = true;
- this.print_string(this._ch);
- this._output.space_before_token = true;
- } else {
- this.print_string(this._ch);
- this.eatWhitespace();
- // squash extra whitespace
- if (this._ch && whitespaceChar.test(this._ch)) {
- this._ch = '';
- }
- }
- } else if (this._ch === ']') {
- this.print_string(this._ch);
- } else if (this._ch === '[') {
- this.preserveSingleSpace(isAfterSpace);
- this.print_string(this._ch);
- } else if (this._ch === '=') { // no whitespace before or after
- this.eatWhitespace();
- this.print_string('=');
- if (whitespaceChar.test(this._ch)) {
- this._ch = '';
- }
- } else if (this._ch === '!') { // !important
- this.print_string(' ');
- this.print_string(this._ch);
- } else {
- this.preserveSingleSpace(isAfterSpace);
- this.print_string(this._ch);
- }
- }
- var sweetCode = this._output.get_code(eol);
- return sweetCode;
- };
- module.exports.Beautifier = Beautifier;
- /***/ }),
- /* 14 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- /*jshint node:true */
- /*
- The MIT License (MIT)
- Copyright (c) 2007-2018 Einar Lielmanis, Liam Newman, and contributors.
- Permission is hereby granted, free of charge, to any person
- obtaining a copy of this software and associated documentation files
- (the "Software"), to deal in the Software without restriction,
- including without limitation the rights to use, copy, modify, merge,
- publish, distribute, sublicense, and/or sell copies of the Software,
- and to permit persons to whom the Software is furnished to do so,
- subject to the following conditions:
- The above copyright notice and this permission notice shall be
- included in all copies or substantial portions of the Software.
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- SOFTWARE.
- */
- var BaseOptions = __webpack_require__(6).Options;
- function Options(options) {
- BaseOptions.call(this, options, 'css');
- this.selector_separator_newline = this._get_boolean('selector_separator_newline', true);
- this.newline_between_rules = this._get_boolean('newline_between_rules', true);
- var space_around_selector_separator = this._get_boolean('space_around_selector_separator');
- this.space_around_combinator = this._get_boolean('space_around_combinator') || space_around_selector_separator;
- }
- Options.prototype = new BaseOptions();
- module.exports.Options = Options;
- /***/ })
- /******/ ]);
- var css_beautify = legacy_beautify_css;
- /* Footer */
- if (typeof define === "function" && define.amd) {
- // Add support for AMD ( https://github.com/amdjs/amdjs-api/wiki/AMD#defineamd-property- )
- define([], function() {
- return {
- css_beautify: css_beautify
- };
- });
- } else if (typeof exports !== "undefined") {
- // Add support for CommonJS. Just put this file somewhere on your require.paths
- // and you will be able to `var html_beautify = require("beautify").html_beautify`.
- exports.css_beautify = css_beautify;
- } else if (typeof window !== "undefined") {
- // If we're running a web page and don't have either of the above, add our one global
- window.css_beautify = css_beautify;
- } else if (typeof global !== "undefined") {
- // If we don't even have window, try global.
- global.css_beautify = css_beautify;
- }
- }());
|