12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697 |
- /* 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() { // webpackBootstrap
- /******/ "use strict";
- /******/ var __webpack_modules__ = ([
- /* 0 */,
- /* 1 */,
- /* 2 */
- /***/ (function(module) {
- /*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.__wrap_point_index = 0;
- this.__wrap_point_character_count = 0;
- this.__wrap_point_indent_count = -1;
- this.__wrap_point_alignment_count = 0;
- this.__items = [];
- }
- OutputLine.prototype.clone_empty = function() {
- var line = new OutputLine(this.__parent);
- line.set_indent(this.__indent_count, this.__alignment_count);
- return line;
- };
- 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) {
- if (this.is_empty()) {
- 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._set_wrap_point = function() {
- if (this.__parent.wrap_line_length) {
- this.__wrap_point_index = this.__items.length;
- this.__wrap_point_character_count = this.__character_count;
- this.__wrap_point_indent_count = this.__parent.next_line.__indent_count;
- this.__wrap_point_alignment_count = this.__parent.next_line.__alignment_count;
- }
- };
- OutputLine.prototype._should_wrap = function() {
- return this.__wrap_point_index &&
- this.__character_count > this.__parent.wrap_line_length &&
- this.__wrap_point_character_count > this.__parent.next_line.__character_count;
- };
- OutputLine.prototype._allow_wrap = function() {
- if (this._should_wrap()) {
- this.__parent.add_new_line();
- var next = this.__parent.current_line;
- next.set_indent(this.__wrap_point_indent_count, this.__wrap_point_alignment_count);
- next.__items = this.__items.slice(this.__wrap_point_index);
- this.__items = this.__items.slice(0, this.__wrap_point_index);
- next.__character_count += this.__character_count - this.__wrap_point_character_count;
- this.__character_count = this.__wrap_point_character_count;
- if (next.__items[0] === " ") {
- next.__items.splice(0, 1);
- next.__character_count -= 1;
- }
- return true;
- }
- return false;
- };
- 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);
- var last_newline_index = item.lastIndexOf('\n');
- if (last_newline_index !== -1) {
- this.__character_count = item.length - last_newline_index;
- } else {
- this.__character_count += item.length;
- }
- };
- 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._remove_wrap_indent = function() {
- if (this.__wrap_point_indent_count > 0) {
- this.__wrap_point_indent_count -= 1;
- }
- };
- OutputLine.prototype.trim = function() {
- while (this.last() === ' ') {
- this.__items.pop();
- this.__character_count -= 1;
- }
- };
- OutputLine.prototype.toString = function() {
- var result = '';
- if (this.is_empty()) {
- if (this.__parent.indent_empty_lines) {
- result = this.__parent.get_indent_string(this.__indent_count);
- }
- } else {
- 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.wrap_line_length = options.wrap_line_length;
- this.indent_empty_lines = options.indent_empty_lines;
- this.__lines = [];
- this.previous_line = null;
- this.current_line = null;
- this.next_line = new OutputLine(this);
- this.space_before_token = false;
- this.non_breaking_space = false;
- this.previous_token_wrapped = false;
- // initialize
- this.__add_outputline();
- }
- Output.prototype.__add_outputline = function() {
- this.previous_line = this.current_line;
- this.current_line = this.next_line.clone_empty();
- 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) {
- this.trim(true);
- // handle some edge cases where the last tokens
- // has text that ends with newline(s)
- var last_item = this.current_line.pop();
- if (last_item) {
- if (last_item[last_item.length - 1] === '\n') {
- last_item = last_item.replace(/\n+$/g, '');
- }
- this.current_line.push(last_item);
- }
- if (this._end_with_newline) {
- this.__add_outputline();
- }
- var sweet_code = this.__lines.join('\n');
- if (eol !== '\n') {
- sweet_code = sweet_code.replace(/[\n]/g, eol);
- }
- return sweet_code;
- };
- Output.prototype.set_wrap_point = function() {
- this.current_line._set_wrap_point();
- };
- Output.prototype.set_indent = function(indent, alignment) {
- indent = indent || 0;
- alignment = alignment || 0;
- // Next line stores alignment values
- this.next_line.set_indent(indent, alignment);
- // 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.set_indent(-1);
- this.current_line.push(token.whitespace_before);
- this.current_line.push(token.text);
- this.space_before_token = false;
- this.non_breaking_space = false;
- this.previous_token_wrapped = false;
- };
- Output.prototype.add_token = function(printable_token) {
- this.__add_space_before_token();
- this.current_line.push(printable_token);
- this.space_before_token = false;
- this.non_breaking_space = false;
- this.previous_token_wrapped = this.current_line._allow_wrap();
- };
- Output.prototype.__add_space_before_token = function() {
- if (this.space_before_token && !this.just_added_newline()) {
- if (!this.non_breaking_space) {
- this.set_wrap_point();
- }
- this.current_line.push(' ');
- }
- };
- Output.prototype.remove_indent = function(index) {
- var output_length = this.__lines.length;
- while (index < output_length) {
- this.__lines[index]._remove_indent();
- index++;
- }
- this.current_line._remove_wrap_indent();
- };
- Output.prototype.trim = function(eat_newlines) {
- eat_newlines = (eat_newlines === undefined) ? false : eat_newlines;
- this.current_line.trim();
- 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) {
- /*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'));
- this.indent_empty_lines = this._get_boolean('indent_empty_lines');
- // valid templating languages ['django', 'erb', 'handlebars', 'php', 'smarty']
- // For now, 'auto' = all off for javascript, all on for html (and inline javascript).
- // other values ignored
- this.templating = this._get_selection_list('templating', ['auto', 'none', 'django', 'erb', 'handlebars', 'php', 'smarty'], ['auto']);
- }
- 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) {
- /*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 regexp_has_sticky = RegExp.prototype.hasOwnProperty('sticky');
- 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;
- };
- // This is a JavaScript only helper function (not in python)
- // Javascript doesn't have a match method
- // and not all implementation support "sticky" flag.
- // If they do not support sticky then both this.match() and this.test() method
- // must get the match and check the index of the match.
- // If sticky is supported and set, this method will use it.
- // Otherwise it will check that global is set, and fall back to the slower method.
- InputScanner.prototype.__match = function(pattern, index) {
- pattern.lastIndex = index;
- var pattern_match = pattern.exec(this.__input);
- if (pattern_match && !(regexp_has_sticky && pattern.sticky)) {
- if (pattern_match.index !== index) {
- pattern_match = null;
- }
- }
- return pattern_match;
- };
- InputScanner.prototype.test = function(pattern, index) {
- index = index || 0;
- index += this.__position;
- if (index >= 0 && index < this.__input_length) {
- return !!this.__match(pattern, index);
- } else {
- return false;
- }
- };
- InputScanner.prototype.testChar = function(pattern, index) {
- // test one character regex match
- var val = this.peek(index);
- pattern.lastIndex = 0;
- return val !== null && pattern.test(val);
- };
- InputScanner.prototype.match = function(pattern) {
- var pattern_match = this.__match(pattern, this.__position);
- if (pattern_match) {
- this.__position += pattern_match[0].length;
- } else {
- pattern_match = null;
- }
- return pattern_match;
- };
- InputScanner.prototype.read = function(starting_pattern, until_pattern, until_after) {
- var val = '';
- var match;
- if (starting_pattern) {
- match = this.match(starting_pattern);
- if (match) {
- val += match[0];
- }
- }
- if (until_pattern && (match || !starting_pattern)) {
- val += this.readUntil(until_pattern, until_after);
- }
- return val;
- };
- InputScanner.prototype.readUntil = function(pattern, until_after) {
- var val = '';
- var match_index = this.__position;
- pattern.lastIndex = this.__position;
- var pattern_match = pattern.exec(this.__input);
- if (pattern_match) {
- match_index = pattern_match.index;
- if (until_after) {
- match_index += pattern_match[0].length;
- }
- } 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);
- };
- InputScanner.prototype.get_regexp = function(pattern, match_from) {
- var result = null;
- var flags = 'g';
- if (match_from && regexp_has_sticky) {
- flags = 'y';
- }
- // strings are converted to regexp
- if (typeof pattern === "string" && pattern !== '') {
- // result = new RegExp(pattern.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&'), flags);
- result = new RegExp(pattern, flags);
- } else if (pattern) {
- result = new RegExp(pattern.source, flags);
- }
- return result;
- };
- InputScanner.prototype.get_literal_regexp = function(literal_string) {
- return RegExp(literal_string.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&'));
- };
- /* 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 */,
- /* 13 */
- /***/ (function(module) {
- /*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 Directives(start_block_pattern, end_block_pattern) {
- start_block_pattern = typeof start_block_pattern === 'string' ? start_block_pattern : start_block_pattern.source;
- end_block_pattern = typeof end_block_pattern === 'string' ? end_block_pattern : end_block_pattern.source;
- this.__directives_block_pattern = new RegExp(start_block_pattern + / beautify( \w+[:]\w+)+ /.source + end_block_pattern, 'g');
- this.__directive_pattern = / (\w+)[:](\w+)/g;
- this.__directives_end_ignore_pattern = new RegExp(start_block_pattern + /\sbeautify\signore:end\s/.source + end_block_pattern, 'g');
- }
- Directives.prototype.get_directives = function(text) {
- if (!text.match(this.__directives_block_pattern)) {
- return null;
- }
- var directives = {};
- this.__directive_pattern.lastIndex = 0;
- var directive_match = this.__directive_pattern.exec(text);
- while (directive_match) {
- directives[directive_match[1]] = directive_match[2];
- directive_match = this.__directive_pattern.exec(text);
- }
- return directives;
- };
- Directives.prototype.readIgnored = function(input) {
- return input.readUntilAfter(this.__directives_end_ignore_pattern);
- };
- module.exports.Directives = Directives;
- /***/ }),
- /* 14 */,
- /* 15 */
- /***/ (function(module, __unused_webpack_exports, __webpack_require__) {
- /*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__(16).Beautifier),
- Options = (__webpack_require__(17).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();
- };
- /***/ }),
- /* 16 */
- /***/ (function(module, __unused_webpack_exports, __webpack_require__) {
- /*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__(17).Options);
- var Output = (__webpack_require__(2).Output);
- var InputScanner = (__webpack_require__(8).InputScanner);
- var Directives = (__webpack_require__(13).Directives);
- var directives_core = new Directives(/\/\*/, /\*\//);
- 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
- };
- this.NON_SEMICOLON_NEWLINE_PROPERTY = [
- "grid-template-areas",
- "grid-template"
- ];
- }
- 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 newline_count = 0;
- while (whitespaceChar.test(this._input.peek())) {
- this._ch = this._input.next();
- if (allowAtLeastOneNewLine && this._ch === '\n') {
- if (newline_count === 0 || newline_count < this._options.max_preserve_newlines) {
- newline_count++;
- 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) {
- this._output.set_indent(this._indentLevel);
- this._output.non_breaking_space = true;
- 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 insideNonNestedAtRule = false;
- var insideScssMap = false;
- var topCharacter = this._ch;
- var insideNonSemiColonValues = false;
- var whitespace;
- var isAfterSpace;
- var previous_ch;
- while (true) {
- whitespace = this._input.read(whitespacePattern);
- isAfterSpace = whitespace !== '';
- previous_ch = topCharacter;
- this._ch = this._input.next();
- if (this._ch === '\\' && this._input.hasNext()) {
- 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();
- var comment = this._input.read(block_comment_pattern);
- // Handle ignore directive
- var directives = directives_core.get_directives(comment);
- if (directives && directives.ignore === 'start') {
- comment += directives_core.readIgnored(this._input);
- }
- this.print_string(comment);
- // 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);
- this.print_string(this._ch);
- // strip trailing space, if present, for hash property checks
- var variable = this._input.peekUntilAfter(/[: ,;{}()[\]\/='"]/g);
- if (variable.match(/[ :]$/)) {
- // we have a variable or pseudo-class, add it and insert one space before continuing
- variable = this.eatString(": ").replace(/\s$/, '');
- this.print_string(variable);
- this._output.space_before_token = true;
- }
- variable = variable.replace(/\s$/, '');
- // might be sass variable
- if (parenLevel === 0 && variable.indexOf(':') !== -1) {
- insidePropertyValue = true;
- this.indent();
- }
- } else if (this._ch === '@') {
- this.preserveSingleSpace(isAfterSpace);
- // deal with less property 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$/, '');
- // might be less variable
- if (parenLevel === 0 && variableOrRule.indexOf(':') !== -1) {
- insidePropertyValue = true;
- this.indent();
- // might be a nesting at-rule
- } else if (variableOrRule in this.NESTED_AT_RULE) {
- this._nestedLevel += 1;
- if (variableOrRule in this.CONDITIONAL_GROUP_RULE) {
- enteringConditionalGroup = true;
- }
- // might be a non-nested at-rule
- } else if (parenLevel === 0 && !insidePropertyValue) {
- insideNonNestedAtRule = true;
- }
- }
- } 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();
- }
- // non nested at rule becomes nested
- insideNonNestedAtRule = false;
- // 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 - 1);
- }
- 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._output.space_before_token = true;
- // The difference in print_string and indent order is necessary to indent the '{' correctly
- if (this._options.brace_style === 'expand') {
- this._output.add_new_line();
- this.print_string(this._ch);
- this.indent();
- this._output.set_indent(this._indentLevel);
- } else {
- // inside mixin and first param is object
- if (previous_ch === '(') {
- this._output.space_before_token = false;
- } else if (previous_ch !== ',') {
- this.indent();
- }
- this.print_string(this._ch);
- }
- 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);
- }
- 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);
- }
- }
- if (this._input.peek() === ')') {
- this._output.trim(true);
- if (this._options.brace_style === "expand") {
- this._output.add_new_line(true);
- }
- }
- } else if (this._ch === ":") {
- for (var i = 0; i < this.NON_SEMICOLON_NEWLINE_PROPERTY.length; i++) {
- if (this._input.lookBack(this.NON_SEMICOLON_NEWLINE_PROPERTY[i])) {
- insideNonSemiColonValues = true;
- break;
- }
- }
- if ((insideRule || enteringConditionalGroup) && !(this._input.lookBack("&") || this.foundNestedPseudoClass()) && !this._input.lookBack("(") && !insideNonNestedAtRule && parenLevel === 0) {
- // '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 === '\'') {
- var preserveQuoteSpace = previous_ch === '"' || previous_ch === '\'';
- this.preserveSingleSpace(preserveQuoteSpace || isAfterSpace);
- this.print_string(this._ch + this.eatString(this._ch));
- this.eatWhitespace(true);
- } else if (this._ch === ';') {
- insideNonSemiColonValues = false;
- if (parenLevel === 0) {
- if (insidePropertyValue) {
- this.outdent();
- insidePropertyValue = false;
- }
- insideNonNestedAtRule = 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 {
- this.print_string(this._ch);
- this.eatWhitespace(true);
- this._output.space_before_token = true;
- }
- } else if (this._ch === '(') { // may be a url
- if (this._input.lookBack("url")) {
- this.print_string(this._ch);
- this.eatWhitespace();
- parenLevel++;
- this.indent();
- this._ch = this._input.next();
- if (this._ch === ')' || this._ch === '"' || this._ch === '\'') {
- this._input.back();
- } else if (this._ch) {
- this.print_string(this._ch + this.eatString(')'));
- if (parenLevel) {
- parenLevel--;
- this.outdent();
- }
- }
- } else {
- var space_needed = false;
- if (this._input.lookBack("with")) {
- // look back is not an accurate solution, we need tokens to confirm without whitespaces
- space_needed = true;
- }
- this.preserveSingleSpace(isAfterSpace || space_needed);
- this.print_string(this._ch);
- // handle scss/sass map
- if (insidePropertyValue && previous_ch === "$" && this._options.selector_separator_newline) {
- this._output.add_new_line();
- insideScssMap = true;
- } else {
- this.eatWhitespace();
- parenLevel++;
- this.indent();
- }
- }
- } else if (this._ch === ')') {
- if (parenLevel) {
- parenLevel--;
- this.outdent();
- }
- if (insideScssMap && this._input.peek() === ";" && this._options.selector_separator_newline) {
- insideScssMap = false;
- this.outdent();
- this._output.add_new_line();
- }
- this.print_string(this._ch);
- } else if (this._ch === ',') {
- this.print_string(this._ch);
- this.eatWhitespace(true);
- if (this._options.selector_separator_newline && (!insidePropertyValue || insideScssMap) && parenLevel === 0 && !insideNonNestedAtRule) {
- this._output.add_new_line();
- } else {
- this._output.space_before_token = true;
- }
- } else if ((this._ch === '>' || this._ch === '+' || this._ch === '~') && !insidePropertyValue && parenLevel === 0) {
- //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 === '!' && !this._input.lookBack("\\")) { // !important
- this._output.space_before_token = true;
- this.print_string(this._ch);
- } else {
- var preserveAfterSpace = previous_ch === '"' || previous_ch === '\'';
- this.preserveSingleSpace(preserveAfterSpace || isAfterSpace);
- this.print_string(this._ch);
- if (!this._output.just_added_newline() && this._input.peek() === '\n' && insideNonSemiColonValues) {
- this._output.add_new_line();
- }
- }
- }
- var sweetCode = this._output.get_code(eol);
- return sweetCode;
- };
- module.exports.Beautifier = Beautifier;
- /***/ }),
- /* 17 */
- /***/ (function(module, __unused_webpack_exports, __webpack_require__) {
- /*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;
- var brace_style_split = this._get_selection_list('brace_style', ['collapse', 'expand', 'end-expand', 'none', 'preserve-inline']);
- this.brace_style = 'collapse';
- for (var bs = 0; bs < brace_style_split.length; bs++) {
- if (brace_style_split[bs] !== 'expand') {
- // default to collapse, as only collapse|expand is implemented for now
- this.brace_style = 'collapse';
- } else {
- this.brace_style = brace_style_split[bs];
- }
- }
- }
- Options.prototype = new BaseOptions();
- module.exports.Options = Options;
- /***/ })
- /******/ ]);
- /************************************************************************/
- /******/ // The module cache
- /******/ var __webpack_module_cache__ = {};
- /******/
- /******/ // The require function
- /******/ function __webpack_require__(moduleId) {
- /******/ // Check if module is in cache
- /******/ var cachedModule = __webpack_module_cache__[moduleId];
- /******/ if (cachedModule !== undefined) {
- /******/ return cachedModule.exports;
- /******/ }
- /******/ // Create a new module (and put it into the cache)
- /******/ var module = __webpack_module_cache__[moduleId] = {
- /******/ // no module.id needed
- /******/ // no module.loaded needed
- /******/ exports: {}
- /******/ };
- /******/
- /******/ // Execute the module function
- /******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
- /******/
- /******/ // Return the exports of the module
- /******/ return module.exports;
- /******/ }
- /******/
- /************************************************************************/
- /******/
- /******/ // startup
- /******/ // Load entry module and return exports
- /******/ // This entry module is referenced by other modules so it can't be inlined
- /******/ var __webpack_exports__ = __webpack_require__(15);
- /******/ legacy_beautify_css = __webpack_exports__;
- /******/
- /******/ })()
- ;
- 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;
- }
- }());
|