vscode-html-languageservice
Advanced tools
Comparing version 2.1.7 to 2.1.8
// copied from js-beautify/js/lib/beautify-css.js | ||
// version: 1.8.1 | ||
/*jshint curly:false, eqeqeq:true, laxbreak:true, noempty:false */ | ||
// version: 1.8.6 | ||
/* AUTO-GENERATED. DO NOT MODIFY. */ | ||
@@ -37,4 +36,4 @@ /* | ||
Based on code initially developed by: Einar Lielmanis, <einar@jsbeautifier.org> | ||
http://jsbeautifier.org/ | ||
Based on code initially developed by: Einar Lielmanis, <einar@beautifier.io> | ||
https://beautifier.io/ | ||
@@ -69,3 +68,6 @@ Usage: | ||
export const css_beautify = | ||
(function() { | ||
/* GENERATED_BUILD_OUTPUT */ | ||
var legacy_beautify_css = | ||
/******/ (function(modules) { // webpackBootstrap | ||
@@ -154,3 +156,3 @@ /******/ // The module cache | ||
/******/ // Load entry module and return exports | ||
/******/ return __webpack_require__(__webpack_require__.s = 11); | ||
/******/ return __webpack_require__(__webpack_require__.s = 12); | ||
/******/ }) | ||
@@ -195,154 +197,2 @@ /************************************************************************/ | ||
// merges child options up with the parent options object | ||
// Example: obj = {a: 1, b: {a: 2}} | ||
// mergeOpts(obj, 'b') | ||
// | ||
// Returns: {a: 2, b: {a: 2}} | ||
function mergeOpts(allOptions, childFieldName) { | ||
var finalOpts = {}; | ||
var name; | ||
for (name in allOptions) { | ||
if (name !== childFieldName) { | ||
finalOpts[name] = allOptions[name]; | ||
} | ||
} | ||
//merge in the per type settings for the childFieldName | ||
if (childFieldName in allOptions) { | ||
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.mergeOpts = mergeOpts; | ||
module.exports.normalizeOpts = normalizeOpts; | ||
/***/ }), | ||
/* 3 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
"use strict"; | ||
/* jshint node: true, curly: false */ | ||
// This section of code is taken from acorn. | ||
// | ||
// Acorn was written by Marijn Haverbeke and released under an MIT | ||
// license. The Unicode regexps (for identifiers and whitespace) were | ||
// taken from [Esprima](http://esprima.org) by Ariya Hidayat. | ||
// | ||
// Git repositories for Acorn are available at | ||
// | ||
// http://marijnhaverbeke.nl/git/acorn | ||
// https://github.com/marijnh/acorn.git | ||
// ## Character categories | ||
// Big ugly regular expressions that match characters in the | ||
// whitespace, identifier, and identifier-start categories. These | ||
// are only applied when a character is found to actually have a | ||
// code point above 128. | ||
var nonASCIIwhitespace = /[\u1680\u180e\u2000-\u200a\u202f\u205f\u3000\ufeff]/; // jshint ignore:line | ||
var baseASCIIidentifierStartChars = "\x24\x40\x41-\x5a\x5f\x61-\x7a"; | ||
var nonASCIIidentifierStartChars = "\xaa\xb5\xba\xc0-\xd6\xd8-\xf6\xf8-\u02c1\u02c6-\u02d1\u02e0-\u02e4\u02ec\u02ee\u0370-\u0374\u0376\u0377\u037a-\u037d\u0386\u0388-\u038a\u038c\u038e-\u03a1\u03a3-\u03f5\u03f7-\u0481\u048a-\u0527\u0531-\u0556\u0559\u0561-\u0587\u05d0-\u05ea\u05f0-\u05f2\u0620-\u064a\u066e\u066f\u0671-\u06d3\u06d5\u06e5\u06e6\u06ee\u06ef\u06fa-\u06fc\u06ff\u0710\u0712-\u072f\u074d-\u07a5\u07b1\u07ca-\u07ea\u07f4\u07f5\u07fa\u0800-\u0815\u081a\u0824\u0828\u0840-\u0858\u08a0\u08a2-\u08ac\u0904-\u0939\u093d\u0950\u0958-\u0961\u0971-\u0977\u0979-\u097f\u0985-\u098c\u098f\u0990\u0993-\u09a8\u09aa-\u09b0\u09b2\u09b6-\u09b9\u09bd\u09ce\u09dc\u09dd\u09df-\u09e1\u09f0\u09f1\u0a05-\u0a0a\u0a0f\u0a10\u0a13-\u0a28\u0a2a-\u0a30\u0a32\u0a33\u0a35\u0a36\u0a38\u0a39\u0a59-\u0a5c\u0a5e\u0a72-\u0a74\u0a85-\u0a8d\u0a8f-\u0a91\u0a93-\u0aa8\u0aaa-\u0ab0\u0ab2\u0ab3\u0ab5-\u0ab9\u0abd\u0ad0\u0ae0\u0ae1\u0b05-\u0b0c\u0b0f\u0b10\u0b13-\u0b28\u0b2a-\u0b30\u0b32\u0b33\u0b35-\u0b39\u0b3d\u0b5c\u0b5d\u0b5f-\u0b61\u0b71\u0b83\u0b85-\u0b8a\u0b8e-\u0b90\u0b92-\u0b95\u0b99\u0b9a\u0b9c\u0b9e\u0b9f\u0ba3\u0ba4\u0ba8-\u0baa\u0bae-\u0bb9\u0bd0\u0c05-\u0c0c\u0c0e-\u0c10\u0c12-\u0c28\u0c2a-\u0c33\u0c35-\u0c39\u0c3d\u0c58\u0c59\u0c60\u0c61\u0c85-\u0c8c\u0c8e-\u0c90\u0c92-\u0ca8\u0caa-\u0cb3\u0cb5-\u0cb9\u0cbd\u0cde\u0ce0\u0ce1\u0cf1\u0cf2\u0d05-\u0d0c\u0d0e-\u0d10\u0d12-\u0d3a\u0d3d\u0d4e\u0d60\u0d61\u0d7a-\u0d7f\u0d85-\u0d96\u0d9a-\u0db1\u0db3-\u0dbb\u0dbd\u0dc0-\u0dc6\u0e01-\u0e30\u0e32\u0e33\u0e40-\u0e46\u0e81\u0e82\u0e84\u0e87\u0e88\u0e8a\u0e8d\u0e94-\u0e97\u0e99-\u0e9f\u0ea1-\u0ea3\u0ea5\u0ea7\u0eaa\u0eab\u0ead-\u0eb0\u0eb2\u0eb3\u0ebd\u0ec0-\u0ec4\u0ec6\u0edc-\u0edf\u0f00\u0f40-\u0f47\u0f49-\u0f6c\u0f88-\u0f8c\u1000-\u102a\u103f\u1050-\u1055\u105a-\u105d\u1061\u1065\u1066\u106e-\u1070\u1075-\u1081\u108e\u10a0-\u10c5\u10c7\u10cd\u10d0-\u10fa\u10fc-\u1248\u124a-\u124d\u1250-\u1256\u1258\u125a-\u125d\u1260-\u1288\u128a-\u128d\u1290-\u12b0\u12b2-\u12b5\u12b8-\u12be\u12c0\u12c2-\u12c5\u12c8-\u12d6\u12d8-\u1310\u1312-\u1315\u1318-\u135a\u1380-\u138f\u13a0-\u13f4\u1401-\u166c\u166f-\u167f\u1681-\u169a\u16a0-\u16ea\u16ee-\u16f0\u1700-\u170c\u170e-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176c\u176e-\u1770\u1780-\u17b3\u17d7\u17dc\u1820-\u1877\u1880-\u18a8\u18aa\u18b0-\u18f5\u1900-\u191c\u1950-\u196d\u1970-\u1974\u1980-\u19ab\u19c1-\u19c7\u1a00-\u1a16\u1a20-\u1a54\u1aa7\u1b05-\u1b33\u1b45-\u1b4b\u1b83-\u1ba0\u1bae\u1baf\u1bba-\u1be5\u1c00-\u1c23\u1c4d-\u1c4f\u1c5a-\u1c7d\u1ce9-\u1cec\u1cee-\u1cf1\u1cf5\u1cf6\u1d00-\u1dbf\u1e00-\u1f15\u1f18-\u1f1d\u1f20-\u1f45\u1f48-\u1f4d\u1f50-\u1f57\u1f59\u1f5b\u1f5d\u1f5f-\u1f7d\u1f80-\u1fb4\u1fb6-\u1fbc\u1fbe\u1fc2-\u1fc4\u1fc6-\u1fcc\u1fd0-\u1fd3\u1fd6-\u1fdb\u1fe0-\u1fec\u1ff2-\u1ff4\u1ff6-\u1ffc\u2071\u207f\u2090-\u209c\u2102\u2107\u210a-\u2113\u2115\u2119-\u211d\u2124\u2126\u2128\u212a-\u212d\u212f-\u2139\u213c-\u213f\u2145-\u2149\u214e\u2160-\u2188\u2c00-\u2c2e\u2c30-\u2c5e\u2c60-\u2ce4\u2ceb-\u2cee\u2cf2\u2cf3\u2d00-\u2d25\u2d27\u2d2d\u2d30-\u2d67\u2d6f\u2d80-\u2d96\u2da0-\u2da6\u2da8-\u2dae\u2db0-\u2db6\u2db8-\u2dbe\u2dc0-\u2dc6\u2dc8-\u2dce\u2dd0-\u2dd6\u2dd8-\u2dde\u2e2f\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303c\u3041-\u3096\u309d-\u309f\u30a1-\u30fa\u30fc-\u30ff\u3105-\u312d\u3131-\u318e\u31a0-\u31ba\u31f0-\u31ff\u3400-\u4db5\u4e00-\u9fcc\ua000-\ua48c\ua4d0-\ua4fd\ua500-\ua60c\ua610-\ua61f\ua62a\ua62b\ua640-\ua66e\ua67f-\ua697\ua6a0-\ua6ef\ua717-\ua71f\ua722-\ua788\ua78b-\ua78e\ua790-\ua793\ua7a0-\ua7aa\ua7f8-\ua801\ua803-\ua805\ua807-\ua80a\ua80c-\ua822\ua840-\ua873\ua882-\ua8b3\ua8f2-\ua8f7\ua8fb\ua90a-\ua925\ua930-\ua946\ua960-\ua97c\ua984-\ua9b2\ua9cf\uaa00-\uaa28\uaa40-\uaa42\uaa44-\uaa4b\uaa60-\uaa76\uaa7a\uaa80-\uaaaf\uaab1\uaab5\uaab6\uaab9-\uaabd\uaac0\uaac2\uaadb-\uaadd\uaae0-\uaaea\uaaf2-\uaaf4\uab01-\uab06\uab09-\uab0e\uab11-\uab16\uab20-\uab26\uab28-\uab2e\uabc0-\uabe2\uac00-\ud7a3\ud7b0-\ud7c6\ud7cb-\ud7fb\uf900-\ufa6d\ufa70-\ufad9\ufb00-\ufb06\ufb13-\ufb17\ufb1d\ufb1f-\ufb28\ufb2a-\ufb36\ufb38-\ufb3c\ufb3e\ufb40\ufb41\ufb43\ufb44\ufb46-\ufbb1\ufbd3-\ufd3d\ufd50-\ufd8f\ufd92-\ufdc7\ufdf0-\ufdfb\ufe70-\ufe74\ufe76-\ufefc\uff21-\uff3a\uff41-\uff5a\uff66-\uffbe\uffc2-\uffc7\uffca-\uffcf\uffd2-\uffd7\uffda-\uffdc"; | ||
var baseASCIIidentifierChars = "\x24\x30-\x39\x41-\x5a\x5f\x61-\x7a"; | ||
var nonASCIIidentifierChars = "\u0300-\u036f\u0483-\u0487\u0591-\u05bd\u05bf\u05c1\u05c2\u05c4\u05c5\u05c7\u0610-\u061a\u0620-\u0649\u0672-\u06d3\u06e7-\u06e8\u06fb-\u06fc\u0730-\u074a\u0800-\u0814\u081b-\u0823\u0825-\u0827\u0829-\u082d\u0840-\u0857\u08e4-\u08fe\u0900-\u0903\u093a-\u093c\u093e-\u094f\u0951-\u0957\u0962-\u0963\u0966-\u096f\u0981-\u0983\u09bc\u09be-\u09c4\u09c7\u09c8\u09d7\u09df-\u09e0\u0a01-\u0a03\u0a3c\u0a3e-\u0a42\u0a47\u0a48\u0a4b-\u0a4d\u0a51\u0a66-\u0a71\u0a75\u0a81-\u0a83\u0abc\u0abe-\u0ac5\u0ac7-\u0ac9\u0acb-\u0acd\u0ae2-\u0ae3\u0ae6-\u0aef\u0b01-\u0b03\u0b3c\u0b3e-\u0b44\u0b47\u0b48\u0b4b-\u0b4d\u0b56\u0b57\u0b5f-\u0b60\u0b66-\u0b6f\u0b82\u0bbe-\u0bc2\u0bc6-\u0bc8\u0bca-\u0bcd\u0bd7\u0be6-\u0bef\u0c01-\u0c03\u0c46-\u0c48\u0c4a-\u0c4d\u0c55\u0c56\u0c62-\u0c63\u0c66-\u0c6f\u0c82\u0c83\u0cbc\u0cbe-\u0cc4\u0cc6-\u0cc8\u0cca-\u0ccd\u0cd5\u0cd6\u0ce2-\u0ce3\u0ce6-\u0cef\u0d02\u0d03\u0d46-\u0d48\u0d57\u0d62-\u0d63\u0d66-\u0d6f\u0d82\u0d83\u0dca\u0dcf-\u0dd4\u0dd6\u0dd8-\u0ddf\u0df2\u0df3\u0e34-\u0e3a\u0e40-\u0e45\u0e50-\u0e59\u0eb4-\u0eb9\u0ec8-\u0ecd\u0ed0-\u0ed9\u0f18\u0f19\u0f20-\u0f29\u0f35\u0f37\u0f39\u0f41-\u0f47\u0f71-\u0f84\u0f86-\u0f87\u0f8d-\u0f97\u0f99-\u0fbc\u0fc6\u1000-\u1029\u1040-\u1049\u1067-\u106d\u1071-\u1074\u1082-\u108d\u108f-\u109d\u135d-\u135f\u170e-\u1710\u1720-\u1730\u1740-\u1750\u1772\u1773\u1780-\u17b2\u17dd\u17e0-\u17e9\u180b-\u180d\u1810-\u1819\u1920-\u192b\u1930-\u193b\u1951-\u196d\u19b0-\u19c0\u19c8-\u19c9\u19d0-\u19d9\u1a00-\u1a15\u1a20-\u1a53\u1a60-\u1a7c\u1a7f-\u1a89\u1a90-\u1a99\u1b46-\u1b4b\u1b50-\u1b59\u1b6b-\u1b73\u1bb0-\u1bb9\u1be6-\u1bf3\u1c00-\u1c22\u1c40-\u1c49\u1c5b-\u1c7d\u1cd0-\u1cd2\u1d00-\u1dbe\u1e01-\u1f15\u200c\u200d\u203f\u2040\u2054\u20d0-\u20dc\u20e1\u20e5-\u20f0\u2d81-\u2d96\u2de0-\u2dff\u3021-\u3028\u3099\u309a\ua640-\ua66d\ua674-\ua67d\ua69f\ua6f0-\ua6f1\ua7f8-\ua800\ua806\ua80b\ua823-\ua827\ua880-\ua881\ua8b4-\ua8c4\ua8d0-\ua8d9\ua8f3-\ua8f7\ua900-\ua909\ua926-\ua92d\ua930-\ua945\ua980-\ua983\ua9b3-\ua9c0\uaa00-\uaa27\uaa40-\uaa41\uaa4c-\uaa4d\uaa50-\uaa59\uaa7b\uaae0-\uaae9\uaaf2-\uaaf3\uabc0-\uabe1\uabec\uabed\uabf0-\uabf9\ufb20-\ufb28\ufe00-\ufe0f\ufe20-\ufe26\ufe33\ufe34\ufe4d-\ufe4f\uff10-\uff19\uff3f"; | ||
//var nonASCIIidentifierStart = new RegExp("[" + nonASCIIidentifierStartChars + "]"); | ||
//var nonASCIIidentifier = new RegExp("[" + nonASCIIidentifierStartChars + nonASCIIidentifierChars + "]"); | ||
var identifierStart = new RegExp("[" + baseASCIIidentifierStartChars + nonASCIIidentifierStartChars + "]"); | ||
var identifierChars = new RegExp("[" + baseASCIIidentifierChars + nonASCIIidentifierStartChars + nonASCIIidentifierChars + "]"); | ||
exports.identifier = new RegExp("[" + baseASCIIidentifierStartChars + nonASCIIidentifierStartChars + "][" + baseASCIIidentifierChars + nonASCIIidentifierStartChars + nonASCIIidentifierChars + "]*", 'g'); | ||
// Whether a single character denotes a newline. | ||
exports.newline = /[\n\r\u2028\u2029]/; | ||
// Matches a whole line break (where CRLF is considered a single | ||
// line break). Used to count lines. | ||
// in javascript, these two differ | ||
// in python they are the same, different methods are called on them | ||
exports.lineBreak = new RegExp('\r\n|' + exports.newline.source); | ||
exports.allLineBreaks = new RegExp(exports.lineBreak.source, 'g'); | ||
// Test whether a given character code starts an identifier. | ||
exports.isIdentifierStart = function(code) { | ||
// // permit $ (36) and @ (64). @ is used in ES7 decorators. | ||
// if (code < 65) return code === 36 || code === 64; | ||
// // 65 through 91 are uppercase letters. | ||
// if (code < 91) return true; | ||
// // permit _ (95). | ||
// if (code < 97) return code === 95; | ||
// // 97 through 123 are lowercase letters. | ||
// if (code < 123) return true; | ||
return identifierStart.test(String.fromCharCode(code)); | ||
}; | ||
// Test whether a given character is part of an identifier. | ||
exports.isIdentifierChar = function(code) { | ||
// if (code < 48) return code === 36; | ||
// if (code < 58) return true; | ||
// if (code < 65) return false; | ||
// if (code < 91) return true; | ||
// if (code < 97) return code === 95; | ||
// if (code < 123) return true; | ||
return identifierChars.test(String.fromCharCode(code)); | ||
}; | ||
/***/ }), | ||
/* 4 */ | ||
/***/ (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) { | ||
@@ -464,4 +314,14 @@ this.__parent = parent; | ||
function Output(indent_string, baseIndentString) { | ||
function Output(options, baseIndentString) { | ||
var indent_string = options.indent_char; | ||
if (options.indent_size > 1) { | ||
indent_string = new Array(options.indent_size + 1).join(options.indent_char); | ||
} | ||
// Set to null to continue support for auto detection of base indent level. | ||
baseIndentString = baseIndentString || ''; | ||
if (options.indent_level > 0) { | ||
baseIndentString = new Array(options.indent_level + 1).join(indent_string); | ||
} | ||
this.__indent_cache = new IndentCache(baseIndentString, indent_string); | ||
@@ -472,2 +332,3 @@ this.__alignment_cache = new IndentCache('', ' '); | ||
this.raw = false; | ||
this._end_with_newline = options.end_with_newline; | ||
@@ -520,6 +381,6 @@ this.__lines = []; | ||
Output.prototype.get_code = function(end_with_newline, eol) { | ||
Output.prototype.get_code = function(eol) { | ||
var sweet_code = this.__lines.join('\n').replace(/[\r\n\t ]+$/, ''); | ||
if (end_with_newline) { | ||
if (this._end_with_newline) { | ||
sweet_code += '\n'; | ||
@@ -621,2 +482,4 @@ } | ||
/***/ }), | ||
/* 3 */, | ||
/* 4 */, | ||
/* 5 */, | ||
@@ -657,2 +520,187 @@ /* 6 */ | ||
function Options(options, merge_child_field) { | ||
options = _mergeOpts(options, merge_child_field); | ||
this.raw_options = _normalizeOpts(options); | ||
// 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'); | ||
if (this.indent_with_tabs) { | ||
this.indent_char = '\t'; | ||
this.indent_size = 1; | ||
} | ||
// 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, b: {a: 2}} | ||
function _mergeOpts(allOptions, childFieldName) { | ||
var finalOpts = {}; | ||
allOptions = 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) { | ||
@@ -778,7 +826,6 @@ this.__input = input_string || ''; | ||
/***/ }), | ||
/* 7 */, | ||
/* 8 */, | ||
/* 9 */, | ||
/* 10 */, | ||
/* 11 */ | ||
/* 11 */, | ||
/* 12 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
@@ -817,3 +864,3 @@ | ||
var Beautifier = __webpack_require__(12).Beautifier; | ||
var Beautifier = __webpack_require__(13).Beautifier; | ||
@@ -828,3 +875,3 @@ function css_beautify(source_text, options) { | ||
/***/ }), | ||
/* 12 */ | ||
/* 13 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
@@ -863,455 +910,464 @@ | ||
var mergeOpts = __webpack_require__(2).mergeOpts; | ||
var normalizeOpts = __webpack_require__(2).normalizeOpts; | ||
var acorn = __webpack_require__(3); | ||
var Output = __webpack_require__(4).Output; | ||
var InputScanner = __webpack_require__(6).InputScanner; | ||
var Options = __webpack_require__(14).Options; | ||
var Output = __webpack_require__(2).Output; | ||
var InputScanner = __webpack_require__(8).InputScanner; | ||
var lineBreak = acorn.lineBreak; | ||
var allLineBreaks = acorn.allLineBreaks; | ||
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 || ''; | ||
options = options || {}; | ||
// Allow the setting of language/file-type specific options | ||
// with inheritance of overall settings | ||
options = mergeOpts(options, 'css'); | ||
options = normalizeOpts(options); | ||
this._options = {}; | ||
this._options = new Options(options); | ||
this._ch = null; | ||
this._input = null; | ||
var indentSize = options.indent_size ? parseInt(options.indent_size, 10) : 4; | ||
var indentCharacter = options.indent_char || ' '; | ||
var preserve_newlines = (options.preserve_newlines === undefined) ? false : options.preserve_newlines; | ||
var selectorSeparatorNewline = (options.selector_separator_newline === undefined) ? true : options.selector_separator_newline; | ||
var end_with_newline = (options.end_with_newline === undefined) ? false : options.end_with_newline; | ||
var newline_between_rules = (options.newline_between_rules === undefined) ? true : options.newline_between_rules; | ||
var space_around_combinator = (options.space_around_combinator === undefined) ? false : options.space_around_combinator; | ||
space_around_combinator = space_around_combinator || ((options.space_around_selector_separator === undefined) ? false : options.space_around_selector_separator); | ||
var eol = options.eol ? options.eol : 'auto'; | ||
// 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 | ||
}; | ||
// Support passing the source text back with no change | ||
this._options.disabled = (options.disabled === undefined) ? false : options.disabled; | ||
} | ||
if (options.indent_with_tabs) { | ||
indentCharacter = '\t'; | ||
indentSize = 1; | ||
} | ||
eol = eol.replace(/\\r/, '\r').replace(/\\n/, '\n'); | ||
// tokenizer | ||
var whitespaceChar = /\s/; | ||
var whitespacePattern = /(?:\s|\n)+/g; | ||
var block_comment_pattern = /\/\*(?:[\s\S]*?)((?:\*\/)|$)/g; | ||
var comment_pattern = /\/\/(?:[^\n\r\u2028\u2029]*)/g; | ||
var ch; | ||
var parenLevel = 0; | ||
var input; | ||
function eatString(endChars) { | ||
var result = ''; | ||
ch = input.next(); | ||
while (ch) { | ||
result += ch; | ||
if (ch === "\\") { | ||
result += input.next(); | ||
} else if (endChars.indexOf(ch) !== -1 || ch === "\n") { | ||
break; | ||
} | ||
ch = input.next(); | ||
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; | ||
} | ||
return result; | ||
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 | ||
function eatWhitespace(allowAtLeastOneNewLine) { | ||
var result = whitespaceChar.test(input.peek()); | ||
var isFirstNewLine = true; | ||
// 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(input.peek())) { | ||
ch = input.next(); | ||
if (allowAtLeastOneNewLine && ch === '\n') { | ||
if (preserve_newlines || isFirstNewLine) { | ||
isFirstNewLine = false; | ||
output.add_new_line(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; | ||
} | ||
return result; | ||
}; | ||
// Nested pseudo-class if we are insideRule | ||
// and the next special character found opens | ||
// a new block | ||
function foundNestedPseudoClass() { | ||
var openParen = 0; | ||
var i = 1; | ||
var ch = 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 === "}") { | ||
// 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; | ||
} | ||
i++; | ||
ch = input.peek(i); | ||
openParen -= 1; | ||
} else if (ch === ";" || ch === "}") { | ||
return false; | ||
} | ||
return false; | ||
i++; | ||
ch = this._input.peek(i); | ||
} | ||
return false; | ||
}; | ||
var indentLevel; | ||
var nestedLevel; | ||
var output; | ||
function print_string(output_string) { | ||
if (output.just_added_newline()) { | ||
output.set_indent(indentLevel); | ||
} | ||
output.add_token(output_string); | ||
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); | ||
}; | ||
function preserveSingleSpace(isAfterSpace) { | ||
if (isAfterSpace) { | ||
output.space_before_token = true; | ||
} | ||
Beautifier.prototype.preserveSingleSpace = function(isAfterSpace) { | ||
if (isAfterSpace) { | ||
this._output.space_before_token = true; | ||
} | ||
}; | ||
function indent() { | ||
indentLevel++; | ||
} | ||
Beautifier.prototype.indent = function() { | ||
this._indentLevel++; | ||
}; | ||
function outdent() { | ||
if (indentLevel > 0) { | ||
indentLevel--; | ||
} | ||
Beautifier.prototype.outdent = function() { | ||
if (this._indentLevel > 0) { | ||
this._indentLevel--; | ||
} | ||
}; | ||
/*_____________________--------------------_____________________*/ | ||
/*_____________________--------------------_____________________*/ | ||
this.beautify = function() { | ||
if (this._options.disabled) { | ||
return this._source_text; | ||
} | ||
Beautifier.prototype.beautify = function() { | ||
if (this._options.disabled) { | ||
return this._source_text; | ||
} | ||
var source_text = this._source_text; | ||
if (eol === 'auto') { | ||
eol = '\n'; | ||
if (source_text && lineBreak.test(source_text || '')) { | ||
eol = source_text.match(lineBreak)[0]; | ||
} | ||
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 input. | ||
source_text = source_text.replace(allLineBreaks, '\n'); | ||
// HACK: newline parsing inconsistent. This brute force normalizes the this._input. | ||
source_text = source_text.replace(allLineBreaks, '\n'); | ||
// reset | ||
var singleIndent = new Array(indentSize + 1).join(indentCharacter); | ||
var baseIndentString = ''; | ||
var preindent_index = 0; | ||
if (source_text && source_text.length) { | ||
while ((source_text.charAt(preindent_index) === ' ' || | ||
source_text.charAt(preindent_index) === '\t')) { | ||
preindent_index += 1; | ||
} | ||
baseIndentString = source_text.substring(0, preindent_index); | ||
source_text = source_text.substring(preindent_index); | ||
} | ||
// reset | ||
var baseIndentString = source_text.match(/^[\t ]*/)[0]; | ||
output = new Output(singleIndent, baseIndentString); | ||
input = new InputScanner(source_text); | ||
indentLevel = 0; | ||
nestedLevel = 0; | ||
this._output = new Output(this._options, baseIndentString); | ||
this._input = new InputScanner(source_text); | ||
this._indentLevel = 0; | ||
this._nestedLevel = 0; | ||
ch = null; | ||
parenLevel = 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 = ch; | ||
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 = input.read(whitespacePattern); | ||
var isAfterSpace = whitespace !== ''; | ||
var previous_ch = topCharacter; | ||
ch = input.next(); | ||
topCharacter = 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 (!ch) { | ||
break; | ||
} else if (ch === '/' && 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. | ||
output.add_new_line(); | ||
input.back(); | ||
print_string(input.read(block_comment_pattern)); | ||
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 | ||
eatWhitespace(true); | ||
// 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 | ||
output.add_new_line(); | ||
} else if (ch === '/' && input.peek() === '/') { | ||
// // single line comment | ||
// Preserves the space before a comment | ||
// on the same line as a rule | ||
output.space_before_token = true; | ||
input.back(); | ||
print_string(input.read(comment_pattern)); | ||
// 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 | ||
eatWhitespace(true); | ||
} else if (ch === '@') { | ||
preserveSingleSpace(isAfterSpace); | ||
// 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 (input.peek() === '{') { | ||
print_string(ch + eatString('}')); | ||
} else { | ||
print_string(ch); | ||
// 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 = input.peekUntilAfter(/[: ,;{}()[\]\/='"]/g); | ||
// 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 = eatString(": ").replace(/\s$/, ''); | ||
print_string(variableOrRule); | ||
output.space_before_token = true; | ||
} | ||
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$/, ''); | ||
variableOrRule = variableOrRule.replace(/\s$/, ''); | ||
if (variableOrRule === 'extend') { | ||
insideAtExtend = true; | ||
} else if (variableOrRule === 'import') { | ||
insideAtImport = true; | ||
} | ||
if (variableOrRule === 'extend') { | ||
insideAtExtend = true; | ||
} else if (variableOrRule === 'import') { | ||
insideAtImport = true; | ||
} | ||
// might be a nesting at-rule | ||
if (variableOrRule in this.NESTED_AT_RULE) { | ||
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; | ||
indent(); | ||
// 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 (ch === '#' && input.peek() === '{') { | ||
preserveSingleSpace(isAfterSpace); | ||
print_string(ch + eatString('}')); | ||
} else if (ch === '{') { | ||
if (insidePropertyValue) { | ||
insidePropertyValue = false; | ||
outdent(); | ||
} | ||
} 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('/', ','); | ||
} | ||
indent(); | ||
output.space_before_token = true; | ||
print_string(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); | ||
} | ||
insideAtImport = false; | ||
insideAtExtend = false; | ||
if (insidePropertyValue) { | ||
this.outdent(); | ||
insidePropertyValue = false; | ||
} | ||
this.print_string(this._ch); | ||
insideRule = false; | ||
if (this._nestedLevel) { | ||
this._nestedLevel--; | ||
} | ||
// when entering conditional groups, only rulesets are allowed | ||
if (enteringConditionalGroup) { | ||
enteringConditionalGroup = false; | ||
insideRule = (indentLevel > nestedLevel); | ||
} else { | ||
// otherwise, declarations are also allowed | ||
insideRule = (indentLevel >= 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 (newline_between_rules && insideRule) { | ||
if (output.previous_line && output.previous_line.item(-1) !== '{') { | ||
output.ensure_empty_line_above('/', ','); | ||
} | ||
} | ||
} 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(); | ||
} | ||
eatWhitespace(true); | ||
output.add_new_line(); | ||
} else if (ch === '}') { | ||
outdent(); | ||
output.add_new_line(); | ||
if (previous_ch === '{') { | ||
output.trim(true); | ||
} | ||
insideAtImport = false; | ||
insideAtExtend = false; | ||
if (insidePropertyValue) { | ||
outdent(); | ||
insidePropertyValue = false; | ||
} | ||
print_string(ch); | ||
insideRule = false; | ||
if (nestedLevel) { | ||
nestedLevel--; | ||
} | ||
} else { | ||
// sass/less parent reference don't use a space | ||
// sass nested pseudo-class don't use a space | ||
eatWhitespace(true); | ||
output.add_new_line(); | ||
if (newline_between_rules && !output.just_added_blankline()) { | ||
if (input.peek() !== '}') { | ||
output.add_new_line(true); | ||
} | ||
// preserve space before pseudoclasses/pseudoelements, as it means "in any child" | ||
if (this._input.lookBack(" ")) { | ||
this._output.space_before_token = true; | ||
} | ||
} else if (ch === ":") { | ||
if ((insideRule || enteringConditionalGroup) && | ||
!(input.lookBack("&") || foundNestedPseudoClass()) && | ||
!input.lookBack("(") && !insideAtExtend) { | ||
// 'property: value' delimiter | ||
// which could be in a conditional group query | ||
print_string(':'); | ||
if (!insidePropertyValue) { | ||
insidePropertyValue = true; | ||
output.space_before_token = true; | ||
eatWhitespace(true); | ||
indent(); | ||
} | ||
if (this._input.peek() === ":") { | ||
// pseudo-element | ||
this._ch = this._input.next(); | ||
this.print_string("::"); | ||
} 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 (input.lookBack(" ")) { | ||
output.space_before_token = true; | ||
} | ||
if (input.peek() === ":") { | ||
// pseudo-element | ||
ch = input.next(); | ||
print_string("::"); | ||
} else { | ||
// pseudo-class | ||
print_string(':'); | ||
} | ||
// pseudo-class | ||
this.print_string(':'); | ||
} | ||
} else if (ch === '"' || ch === '\'') { | ||
preserveSingleSpace(isAfterSpace); | ||
print_string(ch + eatString(ch)); | ||
eatWhitespace(true); | ||
} else if (ch === ';') { | ||
if (insidePropertyValue) { | ||
outdent(); | ||
insidePropertyValue = false; | ||
} | ||
insideAtExtend = false; | ||
insideAtImport = false; | ||
print_string(ch); | ||
eatWhitespace(true); | ||
} | ||
} 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 (input.peek() !== '/') { | ||
output.add_new_line(); | ||
} | ||
} else if (ch === '(') { // may be a url | ||
if (input.lookBack("url")) { | ||
print_string(ch); | ||
eatWhitespace(); | ||
ch = input.next(); | ||
if (ch === ')' || ch === '"' || ch !== '\'') { | ||
input.back(); | ||
parenLevel++; | ||
} else if (ch) { | ||
print_string(ch + eatString(')')); | ||
} | ||
} else { | ||
// 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++; | ||
preserveSingleSpace(isAfterSpace); | ||
print_string(ch); | ||
eatWhitespace(); | ||
} else if (this._ch) { | ||
this.print_string(this._ch + this.eatString(')')); | ||
} | ||
} else if (ch === ')') { | ||
print_string(ch); | ||
parenLevel--; | ||
} else if (ch === ',') { | ||
print_string(ch); | ||
eatWhitespace(true); | ||
if (selectorSeparatorNewline && !insidePropertyValue && parenLevel < 1 && !insideAtImport) { | ||
output.add_new_line(); | ||
} else { | ||
output.space_before_token = true; | ||
} | ||
} else if ((ch === '>' || ch === '+' || ch === '~') && | ||
!insidePropertyValue && parenLevel < 1) { | ||
//handle combinator spacing | ||
if (space_around_combinator) { | ||
output.space_before_token = true; | ||
print_string(ch); | ||
output.space_before_token = true; | ||
} else { | ||
print_string(ch); | ||
eatWhitespace(); | ||
// squash extra whitespace | ||
if (ch && whitespaceChar.test(ch)) { | ||
ch = ''; | ||
} | ||
} | ||
} else if (ch === ']') { | ||
print_string(ch); | ||
} else if (ch === '[') { | ||
preserveSingleSpace(isAfterSpace); | ||
print_string(ch); | ||
} else if (ch === '=') { // no whitespace before or after | ||
eatWhitespace(); | ||
print_string('='); | ||
if (whitespaceChar.test(ch)) { | ||
ch = ''; | ||
} | ||
} else if (ch === '!') { // !important | ||
print_string(' '); | ||
print_string(ch); | ||
} else { | ||
preserveSingleSpace(isAfterSpace); | ||
print_string(ch); | ||
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 = output.get_code(end_with_newline, eol); | ||
var sweetCode = this._output.get_code(eol); | ||
return sweetCode; | ||
}; | ||
return sweetCode; | ||
}; | ||
// 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 | ||
}; | ||
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.Beautifier = Beautifier; | ||
module.exports.Options = Options; | ||
/***/ }) | ||
/******/ ]); |
@@ -71,2 +71,3 @@ /*--------------------------------------------------------------------------------------------- | ||
var endTagStart = -1; | ||
var endTagName = null; | ||
var pendingAttribute = null; | ||
@@ -91,17 +92,2 @@ var token = scanner.scan(); | ||
break; | ||
case TokenType.EndTagOpen: | ||
endTagStart = scanner.getTokenOffset(); | ||
break; | ||
case TokenType.EndTag: | ||
var closeTag = scanner.getTokenText().toLowerCase(); | ||
while (!curr.isSameTag(closeTag) && curr.parent) { | ||
curr.end = endTagStart; | ||
curr.closed = false; | ||
curr = curr.parent; | ||
} | ||
if (curr !== htmlDocument) { | ||
curr.closed = true; | ||
curr.endTagStart = endTagStart; | ||
} | ||
break; | ||
case TokenType.StartTagSelfClose: | ||
@@ -114,6 +100,27 @@ if (curr.parent) { | ||
break; | ||
case TokenType.EndTagOpen: | ||
endTagStart = scanner.getTokenOffset(); | ||
endTagName = null; | ||
break; | ||
case TokenType.EndTag: | ||
endTagName = scanner.getTokenText().toLowerCase(); | ||
break; | ||
case TokenType.EndTagClose: | ||
if (curr.parent) { | ||
curr.end = scanner.getTokenEnd(); | ||
curr = curr.parent; | ||
if (endTagName) { | ||
var node = curr; | ||
// see if we can find a matching tag | ||
while (!node.isSameTag(endTagName) && node.parent) { | ||
node = node.parent; | ||
} | ||
if (node.parent) { | ||
while (curr !== node) { | ||
curr.end = endTagStart; | ||
curr.closed = false; | ||
curr = curr.parent; | ||
} | ||
curr.closed = true; | ||
curr.endTagStart = endTagStart; | ||
curr.end = scanner.getTokenEnd(); | ||
curr = curr.parent; | ||
} | ||
} | ||
@@ -120,0 +127,0 @@ break; |
@@ -276,3 +276,4 @@ /*--------------------------------------------------------------------------------------------- | ||
'banner', 'complementary', 'contentinfo', 'form', 'main', 'navigation', 'region', 'search', | ||
'doc-abstract', 'doc-acknowledgments', 'doc-afterword', 'doc-appendix', 'doc-backlink', 'doc-biblioentry', 'doc-bibliography', 'doc-biblioref', 'doc-chapter', 'doc-colophon', 'doc-conclusion', 'doc-cover', 'doc-credit', 'doc-credits', 'doc-dedication', 'doc-endnote', 'doc-endnotes', 'doc-epigraph', 'doc-epilogue', 'doc-errata', 'doc-example', 'doc-footnote', 'doc-foreword', 'doc-glossary', 'doc-glossref', 'doc-index', 'doc-introduction', 'doc-noteref', 'doc-notice', 'doc-pagebreak', 'doc-pagelist', 'doc-part', 'doc-preface', 'doc-prologue', 'doc-pullquote', 'doc-qna', 'doc-subtitle', 'doc-tip', 'doc-toc'] | ||
'doc-abstract', 'doc-acknowledgments', 'doc-afterword', 'doc-appendix', 'doc-backlink', 'doc-biblioentry', 'doc-bibliography', 'doc-biblioref', 'doc-chapter', 'doc-colophon', 'doc-conclusion', 'doc-cover', 'doc-credit', 'doc-credits', 'doc-dedication', 'doc-endnote', 'doc-endnotes', 'doc-epigraph', 'doc-epilogue', 'doc-errata', 'doc-example', 'doc-footnote', 'doc-foreword', 'doc-glossary', 'doc-glossref', 'doc-index', 'doc-introduction', 'doc-noteref', 'doc-notice', 'doc-pagebreak', 'doc-pagelist', 'doc-part', 'doc-preface', 'doc-prologue', 'doc-pullquote', 'doc-qna', 'doc-subtitle', 'doc-tip', 'doc-toc'], | ||
metanames: ['application-name', 'author', 'description', 'format-detection', 'generator', 'keywords', 'publisher', 'referrer', 'robots', 'theme-color', 'viewport'] | ||
}; | ||
@@ -279,0 +280,0 @@ return { |
// copied from js-beautify/js/lib/beautify-css.js | ||
// version: 1.8.1 | ||
/*jshint curly:false, eqeqeq:true, laxbreak:true, noempty:false */ | ||
// version: 1.8.6 | ||
/* AUTO-GENERATED. DO NOT MODIFY. */ | ||
@@ -37,4 +36,4 @@ /* | ||
Based on code initially developed by: Einar Lielmanis, <einar@jsbeautifier.org> | ||
http://jsbeautifier.org/ | ||
Based on code initially developed by: Einar Lielmanis, <einar@beautifier.io> | ||
https://beautifier.io/ | ||
@@ -70,2 +69,4 @@ Usage: | ||
(function() { | ||
/* GENERATED_BUILD_OUTPUT */ | ||
var legacy_beautify_css = | ||
@@ -155,3 +156,3 @@ /******/ (function(modules) { // webpackBootstrap | ||
/******/ // Load entry module and return exports | ||
/******/ return __webpack_require__(__webpack_require__.s = 11); | ||
/******/ return __webpack_require__(__webpack_require__.s = 12); | ||
/******/ }) | ||
@@ -196,154 +197,2 @@ /************************************************************************/ | ||
// merges child options up with the parent options object | ||
// Example: obj = {a: 1, b: {a: 2}} | ||
// mergeOpts(obj, 'b') | ||
// | ||
// Returns: {a: 2, b: {a: 2}} | ||
function mergeOpts(allOptions, childFieldName) { | ||
var finalOpts = {}; | ||
var name; | ||
for (name in allOptions) { | ||
if (name !== childFieldName) { | ||
finalOpts[name] = allOptions[name]; | ||
} | ||
} | ||
//merge in the per type settings for the childFieldName | ||
if (childFieldName in allOptions) { | ||
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.mergeOpts = mergeOpts; | ||
module.exports.normalizeOpts = normalizeOpts; | ||
/***/ }), | ||
/* 3 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
"use strict"; | ||
/* jshint node: true, curly: false */ | ||
// This section of code is taken from acorn. | ||
// | ||
// Acorn was written by Marijn Haverbeke and released under an MIT | ||
// license. The Unicode regexps (for identifiers and whitespace) were | ||
// taken from [Esprima](http://esprima.org) by Ariya Hidayat. | ||
// | ||
// Git repositories for Acorn are available at | ||
// | ||
// http://marijnhaverbeke.nl/git/acorn | ||
// https://github.com/marijnh/acorn.git | ||
// ## Character categories | ||
// Big ugly regular expressions that match characters in the | ||
// whitespace, identifier, and identifier-start categories. These | ||
// are only applied when a character is found to actually have a | ||
// code point above 128. | ||
var nonASCIIwhitespace = /[\u1680\u180e\u2000-\u200a\u202f\u205f\u3000\ufeff]/; // jshint ignore:line | ||
var baseASCIIidentifierStartChars = "\x24\x40\x41-\x5a\x5f\x61-\x7a"; | ||
var nonASCIIidentifierStartChars = "\xaa\xb5\xba\xc0-\xd6\xd8-\xf6\xf8-\u02c1\u02c6-\u02d1\u02e0-\u02e4\u02ec\u02ee\u0370-\u0374\u0376\u0377\u037a-\u037d\u0386\u0388-\u038a\u038c\u038e-\u03a1\u03a3-\u03f5\u03f7-\u0481\u048a-\u0527\u0531-\u0556\u0559\u0561-\u0587\u05d0-\u05ea\u05f0-\u05f2\u0620-\u064a\u066e\u066f\u0671-\u06d3\u06d5\u06e5\u06e6\u06ee\u06ef\u06fa-\u06fc\u06ff\u0710\u0712-\u072f\u074d-\u07a5\u07b1\u07ca-\u07ea\u07f4\u07f5\u07fa\u0800-\u0815\u081a\u0824\u0828\u0840-\u0858\u08a0\u08a2-\u08ac\u0904-\u0939\u093d\u0950\u0958-\u0961\u0971-\u0977\u0979-\u097f\u0985-\u098c\u098f\u0990\u0993-\u09a8\u09aa-\u09b0\u09b2\u09b6-\u09b9\u09bd\u09ce\u09dc\u09dd\u09df-\u09e1\u09f0\u09f1\u0a05-\u0a0a\u0a0f\u0a10\u0a13-\u0a28\u0a2a-\u0a30\u0a32\u0a33\u0a35\u0a36\u0a38\u0a39\u0a59-\u0a5c\u0a5e\u0a72-\u0a74\u0a85-\u0a8d\u0a8f-\u0a91\u0a93-\u0aa8\u0aaa-\u0ab0\u0ab2\u0ab3\u0ab5-\u0ab9\u0abd\u0ad0\u0ae0\u0ae1\u0b05-\u0b0c\u0b0f\u0b10\u0b13-\u0b28\u0b2a-\u0b30\u0b32\u0b33\u0b35-\u0b39\u0b3d\u0b5c\u0b5d\u0b5f-\u0b61\u0b71\u0b83\u0b85-\u0b8a\u0b8e-\u0b90\u0b92-\u0b95\u0b99\u0b9a\u0b9c\u0b9e\u0b9f\u0ba3\u0ba4\u0ba8-\u0baa\u0bae-\u0bb9\u0bd0\u0c05-\u0c0c\u0c0e-\u0c10\u0c12-\u0c28\u0c2a-\u0c33\u0c35-\u0c39\u0c3d\u0c58\u0c59\u0c60\u0c61\u0c85-\u0c8c\u0c8e-\u0c90\u0c92-\u0ca8\u0caa-\u0cb3\u0cb5-\u0cb9\u0cbd\u0cde\u0ce0\u0ce1\u0cf1\u0cf2\u0d05-\u0d0c\u0d0e-\u0d10\u0d12-\u0d3a\u0d3d\u0d4e\u0d60\u0d61\u0d7a-\u0d7f\u0d85-\u0d96\u0d9a-\u0db1\u0db3-\u0dbb\u0dbd\u0dc0-\u0dc6\u0e01-\u0e30\u0e32\u0e33\u0e40-\u0e46\u0e81\u0e82\u0e84\u0e87\u0e88\u0e8a\u0e8d\u0e94-\u0e97\u0e99-\u0e9f\u0ea1-\u0ea3\u0ea5\u0ea7\u0eaa\u0eab\u0ead-\u0eb0\u0eb2\u0eb3\u0ebd\u0ec0-\u0ec4\u0ec6\u0edc-\u0edf\u0f00\u0f40-\u0f47\u0f49-\u0f6c\u0f88-\u0f8c\u1000-\u102a\u103f\u1050-\u1055\u105a-\u105d\u1061\u1065\u1066\u106e-\u1070\u1075-\u1081\u108e\u10a0-\u10c5\u10c7\u10cd\u10d0-\u10fa\u10fc-\u1248\u124a-\u124d\u1250-\u1256\u1258\u125a-\u125d\u1260-\u1288\u128a-\u128d\u1290-\u12b0\u12b2-\u12b5\u12b8-\u12be\u12c0\u12c2-\u12c5\u12c8-\u12d6\u12d8-\u1310\u1312-\u1315\u1318-\u135a\u1380-\u138f\u13a0-\u13f4\u1401-\u166c\u166f-\u167f\u1681-\u169a\u16a0-\u16ea\u16ee-\u16f0\u1700-\u170c\u170e-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176c\u176e-\u1770\u1780-\u17b3\u17d7\u17dc\u1820-\u1877\u1880-\u18a8\u18aa\u18b0-\u18f5\u1900-\u191c\u1950-\u196d\u1970-\u1974\u1980-\u19ab\u19c1-\u19c7\u1a00-\u1a16\u1a20-\u1a54\u1aa7\u1b05-\u1b33\u1b45-\u1b4b\u1b83-\u1ba0\u1bae\u1baf\u1bba-\u1be5\u1c00-\u1c23\u1c4d-\u1c4f\u1c5a-\u1c7d\u1ce9-\u1cec\u1cee-\u1cf1\u1cf5\u1cf6\u1d00-\u1dbf\u1e00-\u1f15\u1f18-\u1f1d\u1f20-\u1f45\u1f48-\u1f4d\u1f50-\u1f57\u1f59\u1f5b\u1f5d\u1f5f-\u1f7d\u1f80-\u1fb4\u1fb6-\u1fbc\u1fbe\u1fc2-\u1fc4\u1fc6-\u1fcc\u1fd0-\u1fd3\u1fd6-\u1fdb\u1fe0-\u1fec\u1ff2-\u1ff4\u1ff6-\u1ffc\u2071\u207f\u2090-\u209c\u2102\u2107\u210a-\u2113\u2115\u2119-\u211d\u2124\u2126\u2128\u212a-\u212d\u212f-\u2139\u213c-\u213f\u2145-\u2149\u214e\u2160-\u2188\u2c00-\u2c2e\u2c30-\u2c5e\u2c60-\u2ce4\u2ceb-\u2cee\u2cf2\u2cf3\u2d00-\u2d25\u2d27\u2d2d\u2d30-\u2d67\u2d6f\u2d80-\u2d96\u2da0-\u2da6\u2da8-\u2dae\u2db0-\u2db6\u2db8-\u2dbe\u2dc0-\u2dc6\u2dc8-\u2dce\u2dd0-\u2dd6\u2dd8-\u2dde\u2e2f\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303c\u3041-\u3096\u309d-\u309f\u30a1-\u30fa\u30fc-\u30ff\u3105-\u312d\u3131-\u318e\u31a0-\u31ba\u31f0-\u31ff\u3400-\u4db5\u4e00-\u9fcc\ua000-\ua48c\ua4d0-\ua4fd\ua500-\ua60c\ua610-\ua61f\ua62a\ua62b\ua640-\ua66e\ua67f-\ua697\ua6a0-\ua6ef\ua717-\ua71f\ua722-\ua788\ua78b-\ua78e\ua790-\ua793\ua7a0-\ua7aa\ua7f8-\ua801\ua803-\ua805\ua807-\ua80a\ua80c-\ua822\ua840-\ua873\ua882-\ua8b3\ua8f2-\ua8f7\ua8fb\ua90a-\ua925\ua930-\ua946\ua960-\ua97c\ua984-\ua9b2\ua9cf\uaa00-\uaa28\uaa40-\uaa42\uaa44-\uaa4b\uaa60-\uaa76\uaa7a\uaa80-\uaaaf\uaab1\uaab5\uaab6\uaab9-\uaabd\uaac0\uaac2\uaadb-\uaadd\uaae0-\uaaea\uaaf2-\uaaf4\uab01-\uab06\uab09-\uab0e\uab11-\uab16\uab20-\uab26\uab28-\uab2e\uabc0-\uabe2\uac00-\ud7a3\ud7b0-\ud7c6\ud7cb-\ud7fb\uf900-\ufa6d\ufa70-\ufad9\ufb00-\ufb06\ufb13-\ufb17\ufb1d\ufb1f-\ufb28\ufb2a-\ufb36\ufb38-\ufb3c\ufb3e\ufb40\ufb41\ufb43\ufb44\ufb46-\ufbb1\ufbd3-\ufd3d\ufd50-\ufd8f\ufd92-\ufdc7\ufdf0-\ufdfb\ufe70-\ufe74\ufe76-\ufefc\uff21-\uff3a\uff41-\uff5a\uff66-\uffbe\uffc2-\uffc7\uffca-\uffcf\uffd2-\uffd7\uffda-\uffdc"; | ||
var baseASCIIidentifierChars = "\x24\x30-\x39\x41-\x5a\x5f\x61-\x7a"; | ||
var nonASCIIidentifierChars = "\u0300-\u036f\u0483-\u0487\u0591-\u05bd\u05bf\u05c1\u05c2\u05c4\u05c5\u05c7\u0610-\u061a\u0620-\u0649\u0672-\u06d3\u06e7-\u06e8\u06fb-\u06fc\u0730-\u074a\u0800-\u0814\u081b-\u0823\u0825-\u0827\u0829-\u082d\u0840-\u0857\u08e4-\u08fe\u0900-\u0903\u093a-\u093c\u093e-\u094f\u0951-\u0957\u0962-\u0963\u0966-\u096f\u0981-\u0983\u09bc\u09be-\u09c4\u09c7\u09c8\u09d7\u09df-\u09e0\u0a01-\u0a03\u0a3c\u0a3e-\u0a42\u0a47\u0a48\u0a4b-\u0a4d\u0a51\u0a66-\u0a71\u0a75\u0a81-\u0a83\u0abc\u0abe-\u0ac5\u0ac7-\u0ac9\u0acb-\u0acd\u0ae2-\u0ae3\u0ae6-\u0aef\u0b01-\u0b03\u0b3c\u0b3e-\u0b44\u0b47\u0b48\u0b4b-\u0b4d\u0b56\u0b57\u0b5f-\u0b60\u0b66-\u0b6f\u0b82\u0bbe-\u0bc2\u0bc6-\u0bc8\u0bca-\u0bcd\u0bd7\u0be6-\u0bef\u0c01-\u0c03\u0c46-\u0c48\u0c4a-\u0c4d\u0c55\u0c56\u0c62-\u0c63\u0c66-\u0c6f\u0c82\u0c83\u0cbc\u0cbe-\u0cc4\u0cc6-\u0cc8\u0cca-\u0ccd\u0cd5\u0cd6\u0ce2-\u0ce3\u0ce6-\u0cef\u0d02\u0d03\u0d46-\u0d48\u0d57\u0d62-\u0d63\u0d66-\u0d6f\u0d82\u0d83\u0dca\u0dcf-\u0dd4\u0dd6\u0dd8-\u0ddf\u0df2\u0df3\u0e34-\u0e3a\u0e40-\u0e45\u0e50-\u0e59\u0eb4-\u0eb9\u0ec8-\u0ecd\u0ed0-\u0ed9\u0f18\u0f19\u0f20-\u0f29\u0f35\u0f37\u0f39\u0f41-\u0f47\u0f71-\u0f84\u0f86-\u0f87\u0f8d-\u0f97\u0f99-\u0fbc\u0fc6\u1000-\u1029\u1040-\u1049\u1067-\u106d\u1071-\u1074\u1082-\u108d\u108f-\u109d\u135d-\u135f\u170e-\u1710\u1720-\u1730\u1740-\u1750\u1772\u1773\u1780-\u17b2\u17dd\u17e0-\u17e9\u180b-\u180d\u1810-\u1819\u1920-\u192b\u1930-\u193b\u1951-\u196d\u19b0-\u19c0\u19c8-\u19c9\u19d0-\u19d9\u1a00-\u1a15\u1a20-\u1a53\u1a60-\u1a7c\u1a7f-\u1a89\u1a90-\u1a99\u1b46-\u1b4b\u1b50-\u1b59\u1b6b-\u1b73\u1bb0-\u1bb9\u1be6-\u1bf3\u1c00-\u1c22\u1c40-\u1c49\u1c5b-\u1c7d\u1cd0-\u1cd2\u1d00-\u1dbe\u1e01-\u1f15\u200c\u200d\u203f\u2040\u2054\u20d0-\u20dc\u20e1\u20e5-\u20f0\u2d81-\u2d96\u2de0-\u2dff\u3021-\u3028\u3099\u309a\ua640-\ua66d\ua674-\ua67d\ua69f\ua6f0-\ua6f1\ua7f8-\ua800\ua806\ua80b\ua823-\ua827\ua880-\ua881\ua8b4-\ua8c4\ua8d0-\ua8d9\ua8f3-\ua8f7\ua900-\ua909\ua926-\ua92d\ua930-\ua945\ua980-\ua983\ua9b3-\ua9c0\uaa00-\uaa27\uaa40-\uaa41\uaa4c-\uaa4d\uaa50-\uaa59\uaa7b\uaae0-\uaae9\uaaf2-\uaaf3\uabc0-\uabe1\uabec\uabed\uabf0-\uabf9\ufb20-\ufb28\ufe00-\ufe0f\ufe20-\ufe26\ufe33\ufe34\ufe4d-\ufe4f\uff10-\uff19\uff3f"; | ||
//var nonASCIIidentifierStart = new RegExp("[" + nonASCIIidentifierStartChars + "]"); | ||
//var nonASCIIidentifier = new RegExp("[" + nonASCIIidentifierStartChars + nonASCIIidentifierChars + "]"); | ||
var identifierStart = new RegExp("[" + baseASCIIidentifierStartChars + nonASCIIidentifierStartChars + "]"); | ||
var identifierChars = new RegExp("[" + baseASCIIidentifierChars + nonASCIIidentifierStartChars + nonASCIIidentifierChars + "]"); | ||
exports.identifier = new RegExp("[" + baseASCIIidentifierStartChars + nonASCIIidentifierStartChars + "][" + baseASCIIidentifierChars + nonASCIIidentifierStartChars + nonASCIIidentifierChars + "]*", 'g'); | ||
// Whether a single character denotes a newline. | ||
exports.newline = /[\n\r\u2028\u2029]/; | ||
// Matches a whole line break (where CRLF is considered a single | ||
// line break). Used to count lines. | ||
// in javascript, these two differ | ||
// in python they are the same, different methods are called on them | ||
exports.lineBreak = new RegExp('\r\n|' + exports.newline.source); | ||
exports.allLineBreaks = new RegExp(exports.lineBreak.source, 'g'); | ||
// Test whether a given character code starts an identifier. | ||
exports.isIdentifierStart = function(code) { | ||
// // permit $ (36) and @ (64). @ is used in ES7 decorators. | ||
// if (code < 65) return code === 36 || code === 64; | ||
// // 65 through 91 are uppercase letters. | ||
// if (code < 91) return true; | ||
// // permit _ (95). | ||
// if (code < 97) return code === 95; | ||
// // 97 through 123 are lowercase letters. | ||
// if (code < 123) return true; | ||
return identifierStart.test(String.fromCharCode(code)); | ||
}; | ||
// Test whether a given character is part of an identifier. | ||
exports.isIdentifierChar = function(code) { | ||
// if (code < 48) return code === 36; | ||
// if (code < 58) return true; | ||
// if (code < 65) return false; | ||
// if (code < 91) return true; | ||
// if (code < 97) return code === 95; | ||
// if (code < 123) return true; | ||
return identifierChars.test(String.fromCharCode(code)); | ||
}; | ||
/***/ }), | ||
/* 4 */ | ||
/***/ (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) { | ||
@@ -465,4 +314,14 @@ this.__parent = parent; | ||
function Output(indent_string, baseIndentString) { | ||
function Output(options, baseIndentString) { | ||
var indent_string = options.indent_char; | ||
if (options.indent_size > 1) { | ||
indent_string = new Array(options.indent_size + 1).join(options.indent_char); | ||
} | ||
// Set to null to continue support for auto detection of base indent level. | ||
baseIndentString = baseIndentString || ''; | ||
if (options.indent_level > 0) { | ||
baseIndentString = new Array(options.indent_level + 1).join(indent_string); | ||
} | ||
this.__indent_cache = new IndentCache(baseIndentString, indent_string); | ||
@@ -473,2 +332,3 @@ this.__alignment_cache = new IndentCache('', ' '); | ||
this.raw = false; | ||
this._end_with_newline = options.end_with_newline; | ||
@@ -521,6 +381,6 @@ this.__lines = []; | ||
Output.prototype.get_code = function(end_with_newline, eol) { | ||
Output.prototype.get_code = function(eol) { | ||
var sweet_code = this.__lines.join('\n').replace(/[\r\n\t ]+$/, ''); | ||
if (end_with_newline) { | ||
if (this._end_with_newline) { | ||
sweet_code += '\n'; | ||
@@ -622,2 +482,4 @@ } | ||
/***/ }), | ||
/* 3 */, | ||
/* 4 */, | ||
/* 5 */, | ||
@@ -658,2 +520,187 @@ /* 6 */ | ||
function Options(options, merge_child_field) { | ||
options = _mergeOpts(options, merge_child_field); | ||
this.raw_options = _normalizeOpts(options); | ||
// 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'); | ||
if (this.indent_with_tabs) { | ||
this.indent_char = '\t'; | ||
this.indent_size = 1; | ||
} | ||
// 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, b: {a: 2}} | ||
function _mergeOpts(allOptions, childFieldName) { | ||
var finalOpts = {}; | ||
allOptions = 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) { | ||
@@ -779,7 +826,6 @@ this.__input = input_string || ''; | ||
/***/ }), | ||
/* 7 */, | ||
/* 8 */, | ||
/* 9 */, | ||
/* 10 */, | ||
/* 11 */ | ||
/* 11 */, | ||
/* 12 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
@@ -818,3 +864,3 @@ | ||
var Beautifier = __webpack_require__(12).Beautifier; | ||
var Beautifier = __webpack_require__(13).Beautifier; | ||
@@ -829,3 +875,3 @@ function css_beautify(source_text, options) { | ||
/***/ }), | ||
/* 12 */ | ||
/* 13 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
@@ -864,454 +910,463 @@ | ||
var mergeOpts = __webpack_require__(2).mergeOpts; | ||
var normalizeOpts = __webpack_require__(2).normalizeOpts; | ||
var acorn = __webpack_require__(3); | ||
var Output = __webpack_require__(4).Output; | ||
var InputScanner = __webpack_require__(6).InputScanner; | ||
var Options = __webpack_require__(14).Options; | ||
var Output = __webpack_require__(2).Output; | ||
var InputScanner = __webpack_require__(8).InputScanner; | ||
var lineBreak = acorn.lineBreak; | ||
var allLineBreaks = acorn.allLineBreaks; | ||
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 || ''; | ||
options = options || {}; | ||
// Allow the setting of language/file-type specific options | ||
// with inheritance of overall settings | ||
options = mergeOpts(options, 'css'); | ||
options = normalizeOpts(options); | ||
this._options = {}; | ||
this._options = new Options(options); | ||
this._ch = null; | ||
this._input = null; | ||
var indentSize = options.indent_size ? parseInt(options.indent_size, 10) : 4; | ||
var indentCharacter = options.indent_char || ' '; | ||
var preserve_newlines = (options.preserve_newlines === undefined) ? false : options.preserve_newlines; | ||
var selectorSeparatorNewline = (options.selector_separator_newline === undefined) ? true : options.selector_separator_newline; | ||
var end_with_newline = (options.end_with_newline === undefined) ? false : options.end_with_newline; | ||
var newline_between_rules = (options.newline_between_rules === undefined) ? true : options.newline_between_rules; | ||
var space_around_combinator = (options.space_around_combinator === undefined) ? false : options.space_around_combinator; | ||
space_around_combinator = space_around_combinator || ((options.space_around_selector_separator === undefined) ? false : options.space_around_selector_separator); | ||
var eol = options.eol ? options.eol : 'auto'; | ||
// 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 | ||
}; | ||
// Support passing the source text back with no change | ||
this._options.disabled = (options.disabled === undefined) ? false : options.disabled; | ||
} | ||
if (options.indent_with_tabs) { | ||
indentCharacter = '\t'; | ||
indentSize = 1; | ||
} | ||
eol = eol.replace(/\\r/, '\r').replace(/\\n/, '\n'); | ||
// tokenizer | ||
var whitespaceChar = /\s/; | ||
var whitespacePattern = /(?:\s|\n)+/g; | ||
var block_comment_pattern = /\/\*(?:[\s\S]*?)((?:\*\/)|$)/g; | ||
var comment_pattern = /\/\/(?:[^\n\r\u2028\u2029]*)/g; | ||
var ch; | ||
var parenLevel = 0; | ||
var input; | ||
function eatString(endChars) { | ||
var result = ''; | ||
ch = input.next(); | ||
while (ch) { | ||
result += ch; | ||
if (ch === "\\") { | ||
result += input.next(); | ||
} else if (endChars.indexOf(ch) !== -1 || ch === "\n") { | ||
break; | ||
} | ||
ch = input.next(); | ||
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; | ||
} | ||
return result; | ||
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 | ||
function eatWhitespace(allowAtLeastOneNewLine) { | ||
var result = whitespaceChar.test(input.peek()); | ||
var isFirstNewLine = true; | ||
// 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(input.peek())) { | ||
ch = input.next(); | ||
if (allowAtLeastOneNewLine && ch === '\n') { | ||
if (preserve_newlines || isFirstNewLine) { | ||
isFirstNewLine = false; | ||
output.add_new_line(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; | ||
} | ||
return result; | ||
}; | ||
// Nested pseudo-class if we are insideRule | ||
// and the next special character found opens | ||
// a new block | ||
function foundNestedPseudoClass() { | ||
var openParen = 0; | ||
var i = 1; | ||
var ch = 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 === "}") { | ||
// 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; | ||
} | ||
i++; | ||
ch = input.peek(i); | ||
openParen -= 1; | ||
} else if (ch === ";" || ch === "}") { | ||
return false; | ||
} | ||
return false; | ||
i++; | ||
ch = this._input.peek(i); | ||
} | ||
return false; | ||
}; | ||
var indentLevel; | ||
var nestedLevel; | ||
var output; | ||
function print_string(output_string) { | ||
if (output.just_added_newline()) { | ||
output.set_indent(indentLevel); | ||
} | ||
output.add_token(output_string); | ||
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); | ||
}; | ||
function preserveSingleSpace(isAfterSpace) { | ||
if (isAfterSpace) { | ||
output.space_before_token = true; | ||
} | ||
Beautifier.prototype.preserveSingleSpace = function(isAfterSpace) { | ||
if (isAfterSpace) { | ||
this._output.space_before_token = true; | ||
} | ||
}; | ||
function indent() { | ||
indentLevel++; | ||
} | ||
Beautifier.prototype.indent = function() { | ||
this._indentLevel++; | ||
}; | ||
function outdent() { | ||
if (indentLevel > 0) { | ||
indentLevel--; | ||
} | ||
Beautifier.prototype.outdent = function() { | ||
if (this._indentLevel > 0) { | ||
this._indentLevel--; | ||
} | ||
}; | ||
/*_____________________--------------------_____________________*/ | ||
/*_____________________--------------------_____________________*/ | ||
this.beautify = function() { | ||
if (this._options.disabled) { | ||
return this._source_text; | ||
} | ||
Beautifier.prototype.beautify = function() { | ||
if (this._options.disabled) { | ||
return this._source_text; | ||
} | ||
var source_text = this._source_text; | ||
if (eol === 'auto') { | ||
eol = '\n'; | ||
if (source_text && lineBreak.test(source_text || '')) { | ||
eol = source_text.match(lineBreak)[0]; | ||
} | ||
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 input. | ||
source_text = source_text.replace(allLineBreaks, '\n'); | ||
// HACK: newline parsing inconsistent. This brute force normalizes the this._input. | ||
source_text = source_text.replace(allLineBreaks, '\n'); | ||
// reset | ||
var singleIndent = new Array(indentSize + 1).join(indentCharacter); | ||
var baseIndentString = ''; | ||
var preindent_index = 0; | ||
if (source_text && source_text.length) { | ||
while ((source_text.charAt(preindent_index) === ' ' || | ||
source_text.charAt(preindent_index) === '\t')) { | ||
preindent_index += 1; | ||
} | ||
baseIndentString = source_text.substring(0, preindent_index); | ||
source_text = source_text.substring(preindent_index); | ||
} | ||
// reset | ||
var baseIndentString = source_text.match(/^[\t ]*/)[0]; | ||
output = new Output(singleIndent, baseIndentString); | ||
input = new InputScanner(source_text); | ||
indentLevel = 0; | ||
nestedLevel = 0; | ||
this._output = new Output(this._options, baseIndentString); | ||
this._input = new InputScanner(source_text); | ||
this._indentLevel = 0; | ||
this._nestedLevel = 0; | ||
ch = null; | ||
parenLevel = 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 = ch; | ||
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 = input.read(whitespacePattern); | ||
var isAfterSpace = whitespace !== ''; | ||
var previous_ch = topCharacter; | ||
ch = input.next(); | ||
topCharacter = 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 (!ch) { | ||
break; | ||
} else if (ch === '/' && 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. | ||
output.add_new_line(); | ||
input.back(); | ||
print_string(input.read(block_comment_pattern)); | ||
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 | ||
eatWhitespace(true); | ||
// 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 | ||
output.add_new_line(); | ||
} else if (ch === '/' && input.peek() === '/') { | ||
// // single line comment | ||
// Preserves the space before a comment | ||
// on the same line as a rule | ||
output.space_before_token = true; | ||
input.back(); | ||
print_string(input.read(comment_pattern)); | ||
// 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 | ||
eatWhitespace(true); | ||
} else if (ch === '@') { | ||
preserveSingleSpace(isAfterSpace); | ||
// 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 (input.peek() === '{') { | ||
print_string(ch + eatString('}')); | ||
} else { | ||
print_string(ch); | ||
// 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 = input.peekUntilAfter(/[: ,;{}()[\]\/='"]/g); | ||
// 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 = eatString(": ").replace(/\s$/, ''); | ||
print_string(variableOrRule); | ||
output.space_before_token = true; | ||
} | ||
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$/, ''); | ||
variableOrRule = variableOrRule.replace(/\s$/, ''); | ||
if (variableOrRule === 'extend') { | ||
insideAtExtend = true; | ||
} else if (variableOrRule === 'import') { | ||
insideAtImport = true; | ||
} | ||
if (variableOrRule === 'extend') { | ||
insideAtExtend = true; | ||
} else if (variableOrRule === 'import') { | ||
insideAtImport = true; | ||
} | ||
// might be a nesting at-rule | ||
if (variableOrRule in this.NESTED_AT_RULE) { | ||
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; | ||
indent(); | ||
// 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 (ch === '#' && input.peek() === '{') { | ||
preserveSingleSpace(isAfterSpace); | ||
print_string(ch + eatString('}')); | ||
} else if (ch === '{') { | ||
if (insidePropertyValue) { | ||
insidePropertyValue = false; | ||
outdent(); | ||
} | ||
} 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('/', ','); | ||
} | ||
indent(); | ||
output.space_before_token = true; | ||
print_string(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); | ||
} | ||
insideAtImport = false; | ||
insideAtExtend = false; | ||
if (insidePropertyValue) { | ||
this.outdent(); | ||
insidePropertyValue = false; | ||
} | ||
this.print_string(this._ch); | ||
insideRule = false; | ||
if (this._nestedLevel) { | ||
this._nestedLevel--; | ||
} | ||
// when entering conditional groups, only rulesets are allowed | ||
if (enteringConditionalGroup) { | ||
enteringConditionalGroup = false; | ||
insideRule = (indentLevel > nestedLevel); | ||
} else { | ||
// otherwise, declarations are also allowed | ||
insideRule = (indentLevel >= 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 (newline_between_rules && insideRule) { | ||
if (output.previous_line && output.previous_line.item(-1) !== '{') { | ||
output.ensure_empty_line_above('/', ','); | ||
} | ||
} | ||
} 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(); | ||
} | ||
eatWhitespace(true); | ||
output.add_new_line(); | ||
} else if (ch === '}') { | ||
outdent(); | ||
output.add_new_line(); | ||
if (previous_ch === '{') { | ||
output.trim(true); | ||
} | ||
insideAtImport = false; | ||
insideAtExtend = false; | ||
if (insidePropertyValue) { | ||
outdent(); | ||
insidePropertyValue = false; | ||
} | ||
print_string(ch); | ||
insideRule = false; | ||
if (nestedLevel) { | ||
nestedLevel--; | ||
} | ||
} else { | ||
// sass/less parent reference don't use a space | ||
// sass nested pseudo-class don't use a space | ||
eatWhitespace(true); | ||
output.add_new_line(); | ||
if (newline_between_rules && !output.just_added_blankline()) { | ||
if (input.peek() !== '}') { | ||
output.add_new_line(true); | ||
} | ||
// preserve space before pseudoclasses/pseudoelements, as it means "in any child" | ||
if (this._input.lookBack(" ")) { | ||
this._output.space_before_token = true; | ||
} | ||
} else if (ch === ":") { | ||
if ((insideRule || enteringConditionalGroup) && | ||
!(input.lookBack("&") || foundNestedPseudoClass()) && | ||
!input.lookBack("(") && !insideAtExtend) { | ||
// 'property: value' delimiter | ||
// which could be in a conditional group query | ||
print_string(':'); | ||
if (!insidePropertyValue) { | ||
insidePropertyValue = true; | ||
output.space_before_token = true; | ||
eatWhitespace(true); | ||
indent(); | ||
} | ||
if (this._input.peek() === ":") { | ||
// pseudo-element | ||
this._ch = this._input.next(); | ||
this.print_string("::"); | ||
} 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 (input.lookBack(" ")) { | ||
output.space_before_token = true; | ||
} | ||
if (input.peek() === ":") { | ||
// pseudo-element | ||
ch = input.next(); | ||
print_string("::"); | ||
} else { | ||
// pseudo-class | ||
print_string(':'); | ||
} | ||
// pseudo-class | ||
this.print_string(':'); | ||
} | ||
} else if (ch === '"' || ch === '\'') { | ||
preserveSingleSpace(isAfterSpace); | ||
print_string(ch + eatString(ch)); | ||
eatWhitespace(true); | ||
} else if (ch === ';') { | ||
if (insidePropertyValue) { | ||
outdent(); | ||
insidePropertyValue = false; | ||
} | ||
insideAtExtend = false; | ||
insideAtImport = false; | ||
print_string(ch); | ||
eatWhitespace(true); | ||
} | ||
} 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 (input.peek() !== '/') { | ||
output.add_new_line(); | ||
} | ||
} else if (ch === '(') { // may be a url | ||
if (input.lookBack("url")) { | ||
print_string(ch); | ||
eatWhitespace(); | ||
ch = input.next(); | ||
if (ch === ')' || ch === '"' || ch !== '\'') { | ||
input.back(); | ||
parenLevel++; | ||
} else if (ch) { | ||
print_string(ch + eatString(')')); | ||
} | ||
} else { | ||
// 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++; | ||
preserveSingleSpace(isAfterSpace); | ||
print_string(ch); | ||
eatWhitespace(); | ||
} else if (this._ch) { | ||
this.print_string(this._ch + this.eatString(')')); | ||
} | ||
} else if (ch === ')') { | ||
print_string(ch); | ||
parenLevel--; | ||
} else if (ch === ',') { | ||
print_string(ch); | ||
eatWhitespace(true); | ||
if (selectorSeparatorNewline && !insidePropertyValue && parenLevel < 1 && !insideAtImport) { | ||
output.add_new_line(); | ||
} else { | ||
output.space_before_token = true; | ||
} | ||
} else if ((ch === '>' || ch === '+' || ch === '~') && | ||
!insidePropertyValue && parenLevel < 1) { | ||
//handle combinator spacing | ||
if (space_around_combinator) { | ||
output.space_before_token = true; | ||
print_string(ch); | ||
output.space_before_token = true; | ||
} else { | ||
print_string(ch); | ||
eatWhitespace(); | ||
// squash extra whitespace | ||
if (ch && whitespaceChar.test(ch)) { | ||
ch = ''; | ||
} | ||
} | ||
} else if (ch === ']') { | ||
print_string(ch); | ||
} else if (ch === '[') { | ||
preserveSingleSpace(isAfterSpace); | ||
print_string(ch); | ||
} else if (ch === '=') { // no whitespace before or after | ||
eatWhitespace(); | ||
print_string('='); | ||
if (whitespaceChar.test(ch)) { | ||
ch = ''; | ||
} | ||
} else if (ch === '!') { // !important | ||
print_string(' '); | ||
print_string(ch); | ||
} else { | ||
preserveSingleSpace(isAfterSpace); | ||
print_string(ch); | ||
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 = output.get_code(end_with_newline, eol); | ||
var sweetCode = this._output.get_code(eol); | ||
return sweetCode; | ||
}; | ||
return sweetCode; | ||
}; | ||
// 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 | ||
}; | ||
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.Beautifier = Beautifier; | ||
module.exports.Options = Options; | ||
/***/ }) | ||
@@ -1318,0 +1373,0 @@ /******/ ]); |
@@ -81,2 +81,3 @@ (function (factory) { | ||
var endTagStart = -1; | ||
var endTagName = null; | ||
var pendingAttribute = null; | ||
@@ -101,17 +102,2 @@ var token = scanner.scan(); | ||
break; | ||
case htmlLanguageTypes_1.TokenType.EndTagOpen: | ||
endTagStart = scanner.getTokenOffset(); | ||
break; | ||
case htmlLanguageTypes_1.TokenType.EndTag: | ||
var closeTag = scanner.getTokenText().toLowerCase(); | ||
while (!curr.isSameTag(closeTag) && curr.parent) { | ||
curr.end = endTagStart; | ||
curr.closed = false; | ||
curr = curr.parent; | ||
} | ||
if (curr !== htmlDocument) { | ||
curr.closed = true; | ||
curr.endTagStart = endTagStart; | ||
} | ||
break; | ||
case htmlLanguageTypes_1.TokenType.StartTagSelfClose: | ||
@@ -124,6 +110,27 @@ if (curr.parent) { | ||
break; | ||
case htmlLanguageTypes_1.TokenType.EndTagOpen: | ||
endTagStart = scanner.getTokenOffset(); | ||
endTagName = null; | ||
break; | ||
case htmlLanguageTypes_1.TokenType.EndTag: | ||
endTagName = scanner.getTokenText().toLowerCase(); | ||
break; | ||
case htmlLanguageTypes_1.TokenType.EndTagClose: | ||
if (curr.parent) { | ||
curr.end = scanner.getTokenEnd(); | ||
curr = curr.parent; | ||
if (endTagName) { | ||
var node = curr; | ||
// see if we can find a matching tag | ||
while (!node.isSameTag(endTagName) && node.parent) { | ||
node = node.parent; | ||
} | ||
if (node.parent) { | ||
while (curr !== node) { | ||
curr.end = endTagStart; | ||
curr.closed = false; | ||
curr = curr.parent; | ||
} | ||
curr.closed = true; | ||
curr.endTagStart = endTagStart; | ||
curr.end = scanner.getTokenEnd(); | ||
curr = curr.parent; | ||
} | ||
} | ||
@@ -130,0 +137,0 @@ break; |
@@ -288,3 +288,4 @@ /*--------------------------------------------------------------------------------------------- | ||
'banner', 'complementary', 'contentinfo', 'form', 'main', 'navigation', 'region', 'search', | ||
'doc-abstract', 'doc-acknowledgments', 'doc-afterword', 'doc-appendix', 'doc-backlink', 'doc-biblioentry', 'doc-bibliography', 'doc-biblioref', 'doc-chapter', 'doc-colophon', 'doc-conclusion', 'doc-cover', 'doc-credit', 'doc-credits', 'doc-dedication', 'doc-endnote', 'doc-endnotes', 'doc-epigraph', 'doc-epilogue', 'doc-errata', 'doc-example', 'doc-footnote', 'doc-foreword', 'doc-glossary', 'doc-glossref', 'doc-index', 'doc-introduction', 'doc-noteref', 'doc-notice', 'doc-pagebreak', 'doc-pagelist', 'doc-part', 'doc-preface', 'doc-prologue', 'doc-pullquote', 'doc-qna', 'doc-subtitle', 'doc-tip', 'doc-toc'] | ||
'doc-abstract', 'doc-acknowledgments', 'doc-afterword', 'doc-appendix', 'doc-backlink', 'doc-biblioentry', 'doc-bibliography', 'doc-biblioref', 'doc-chapter', 'doc-colophon', 'doc-conclusion', 'doc-cover', 'doc-credit', 'doc-credits', 'doc-dedication', 'doc-endnote', 'doc-endnotes', 'doc-epigraph', 'doc-epilogue', 'doc-errata', 'doc-example', 'doc-footnote', 'doc-foreword', 'doc-glossary', 'doc-glossref', 'doc-index', 'doc-introduction', 'doc-noteref', 'doc-notice', 'doc-pagebreak', 'doc-pagelist', 'doc-part', 'doc-preface', 'doc-prologue', 'doc-pullquote', 'doc-qna', 'doc-subtitle', 'doc-tip', 'doc-toc'], | ||
metanames: ['application-name', 'author', 'description', 'format-detection', 'generator', 'keywords', 'publisher', 'referrer', 'robots', 'theme-color', 'viewport'] | ||
}; | ||
@@ -291,0 +292,0 @@ return { |
{ | ||
"name": "vscode-html-languageservice", | ||
"version": "2.1.7", | ||
"version": "2.1.8", | ||
"description": "Language service for HTML", | ||
@@ -19,13 +19,13 @@ "main": "./lib/umd/htmlLanguageService.js", | ||
"@types/mocha": "2.2.33", | ||
"@types/node": "7.0.43", | ||
"@types/node": "^8.10.25", | ||
"cpy-cli": "^2.0.0", | ||
"js-beautify": "^1.8.1", | ||
"js-beautify": "^1.8.6", | ||
"mocha": "^5.2.0", | ||
"rimraf": "^2.6.2", | ||
"tslint": "^5.11.0", | ||
"typescript": "^3.0.1" | ||
"typescript": "^3.0.3" | ||
}, | ||
"dependencies": { | ||
"vscode-languageserver-types": "^3.12.0", | ||
"vscode-nls": "^3.2.5", | ||
"vscode-languageserver-types": "^3.13.0", | ||
"vscode-nls": "^4.0.0", | ||
"vscode-uri": "^1.0.6" | ||
@@ -32,0 +32,0 @@ }, |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
High entropy strings
Supply chain riskContains high entropy strings. This could be a sign of encrypted data, leaked secrets or obfuscated code.
Found 1 instance in 1 package
15957
0
706275
+ Addedvscode-nls@4.1.2(transitive)
- Removedvscode-nls@3.2.5(transitive)
Updatedvscode-nls@^4.0.0