Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

vscode-html-languageservice

Package Overview
Dependencies
Maintainers
6
Versions
141
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vscode-html-languageservice - npm Package Compare versions

Comparing version 2.1.11-next.7 to 2.1.11-next.8

64

docs/customData.md

@@ -18,5 +18,5 @@ # Custom Data for HTML Language Service

{
"tags": [],
"globalAttributes": [],
"valueSets": []
"tags": [],
"globalAttributes": [],
"valueSets": []
}

@@ -40,31 +40,31 @@ ```

{
"tags": [
{
"name": "foo",
"description": "The foo element",
"attributes": [
{ "name": "bar" },
{
"name": "baz",
"values": [
{
"name": "baz-val-1"
}
]
}
]
}
],
"globalAttributes": [
{ "name": "fooAttr", "description": "Foo Attribute" },
{ "name": "xattr", "description": "X attributes", "valueSet": "x" }
],
"valueSets": {
"x": [
{
"name": "xval",
"description": "x value"
}
]
}
"tags": [
{
"name": "foo",
"description": "The foo element",
"attributes": [
{ "name": "bar" },
{
"name": "baz",
"values": [
{
"name": "baz-val-1"
}
]
}
]
}
],
"globalAttributes": [
{ "name": "fooAttr", "description": "Foo Attribute" },
{ "name": "xattr", "description": "X attributes", "valueSet": "x" }
],
"valueSets": {
"x": [
{
"name": "xval",
"description": "x value"
}
]
}
}

@@ -71,0 +71,0 @@ ```

// copied from js-beautify/js/lib/beautify-css.js
// version: 1.8.6
// version: 1.9.0-beta4
/* AUTO-GENERATED. DO NOT MODIFY. */

@@ -151,3 +151,3 @@ /*

/******/ // Load entry module and return exports
/******/ return __webpack_require__(__webpack_require__.s = 12);
/******/ return __webpack_require__(__webpack_require__.s = 15);
/******/ })

@@ -164,3 +164,2 @@ /************************************************************************/

/*
The MIT License (MIT)

@@ -199,2 +198,6 @@

this.__alignment_count = 0;
this.__wrap_point_index = 0;
this.__wrap_point_character_count = 0;
this.__wrap_point_indent_count = -1;
this.__wrap_point_alignment_count = 0;

@@ -204,2 +207,8 @@ this.__items = [];

OutputLine.prototype.clone_empty = function() {
var line = new OutputLine(this.__parent);
line.set_indent(this.__indent_count, this.__alignment_count);
return line;
};
OutputLine.prototype.item = function(index) {

@@ -223,11 +232,44 @@ if (index < 0) {

OutputLine.prototype.set_indent = function(indent, alignment) {
this.__indent_count = indent || 0;
this.__alignment_count = alignment || 0;
this.__character_count = this.__parent.baseIndentLength + this.__alignment_count + this.__indent_count * this.__parent.indent_length;
if (this.is_empty()) {
this.__indent_count = indent || 0;
this.__alignment_count = alignment || 0;
this.__character_count = this.__parent.get_indent_size(this.__indent_count, this.__alignment_count);
}
};
OutputLine.prototype.get_character_count = function() {
return this.__character_count;
OutputLine.prototype._set_wrap_point = function() {
if (this.__parent.wrap_line_length) {
this.__wrap_point_index = this.__items.length;
this.__wrap_point_character_count = this.__character_count;
this.__wrap_point_indent_count = this.__parent.next_line.__indent_count;
this.__wrap_point_alignment_count = this.__parent.next_line.__alignment_count;
}
};
OutputLine.prototype._should_wrap = function() {
return this.__wrap_point_index &&
this.__character_count > this.__parent.wrap_line_length &&
this.__wrap_point_character_count > this.__parent.next_line.__character_count;
};
OutputLine.prototype._allow_wrap = function() {
if (this._should_wrap()) {
this.__parent.add_new_line();
var next = this.__parent.current_line;
next.set_indent(this.__wrap_point_indent_count, this.__wrap_point_alignment_count);
next.__items = this.__items.slice(this.__wrap_point_index);
this.__items = this.__items.slice(0, this.__wrap_point_index);
next.__character_count += this.__character_count - this.__wrap_point_character_count;
this.__character_count = this.__wrap_point_character_count;
if (next.__items[0] === " ") {
next.__items.splice(0, 1);
next.__character_count -= 1;
}
return true;
}
return false;
};
OutputLine.prototype.is_empty = function() {

@@ -247,10 +289,7 @@ return this.__items.length === 0;

this.__items.push(item);
this.__character_count += item.length;
};
OutputLine.prototype.push_raw = function(item) {
this.push(item);
var last_newline_index = item.lastIndexOf('\n');
if (last_newline_index !== -1) {
this.__character_count = item.length - last_newline_index;
} else {
this.__character_count += item.length;
}

@@ -268,9 +307,15 @@ };

OutputLine.prototype.remove_indent = function() {
OutputLine.prototype._remove_indent = function() {
if (this.__indent_count > 0) {
this.__indent_count -= 1;
this.__character_count -= this.__parent.indent_length;
this.__character_count -= this.__parent.indent_size;
}
};
OutputLine.prototype._remove_wrap_indent = function() {
if (this.__wrap_point_indent_count > 0) {
this.__wrap_point_indent_count -= 1;
}
};
OutputLine.prototype.trim = function() {

@@ -286,8 +331,3 @@ while (this.last() === ' ') {

if (!this.is_empty()) {
if (this.__indent_count >= 0) {
result = this.__parent.get_indent_string(this.__indent_count);
}
if (this.__alignment_count >= 0) {
result += this.__parent.get_alignment_string(this.__alignment_count);
}
result = this.__parent.get_indent_string(this.__indent_count, this.__alignment_count);
result += this.__items.join('');

@@ -298,42 +338,79 @@ }

function IndentCache(base_string, level_string) {
this.__cache = [base_string];
this.__level_string = level_string;
function IndentStringCache(options, baseIndentString) {
this.__cache = [''];
this.__indent_size = options.indent_size;
this.__indent_string = options.indent_char;
if (!options.indent_with_tabs) {
this.__indent_string = new Array(options.indent_size + 1).join(options.indent_char);
}
// Set to null to continue support for auto detection of base indent
baseIndentString = baseIndentString || '';
if (options.indent_level > 0) {
baseIndentString = new Array(options.indent_level + 1).join(this.__indent_string);
}
this.__base_string = baseIndentString;
this.__base_string_length = baseIndentString.length;
}
IndentCache.prototype.__ensure_cache = function(level) {
while (level >= this.__cache.length) {
this.__cache.push(this.__cache[this.__cache.length - 1] + this.__level_string);
IndentStringCache.prototype.get_indent_size = function(indent, column) {
var result = this.__base_string_length;
column = column || 0;
if (indent < 0) {
result = 0;
}
result += indent * this.__indent_size;
result += column;
return result;
};
IndentCache.prototype.get_level_string = function(level) {
this.__ensure_cache(level);
return this.__cache[level];
IndentStringCache.prototype.get_indent_string = function(indent_level, column) {
var result = this.__base_string;
column = column || 0;
if (indent_level < 0) {
indent_level = 0;
result = '';
}
column += indent_level * this.__indent_size;
this.__ensure_cache(column);
result += this.__cache[column];
return result;
};
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);
IndentStringCache.prototype.__ensure_cache = function(column) {
while (column >= this.__cache.length) {
this.__add_column();
}
};
// 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);
IndentStringCache.prototype.__add_column = function() {
var column = this.__cache.length;
var indent = 0;
var result = '';
if (this.__indent_size && column >= this.__indent_size) {
indent = Math.floor(column / this.__indent_size);
column -= indent * this.__indent_size;
result = new Array(indent + 1).join(this.__indent_string);
}
if (column) {
result += new Array(column + 1).join(' ');
}
this.__indent_cache = new IndentCache(baseIndentString, indent_string);
this.__alignment_cache = new IndentCache('', ' ');
this.baseIndentLength = baseIndentString.length;
this.indent_length = indent_string.length;
this.__cache.push(result);
};
function Output(options, baseIndentString) {
this.__indent_cache = new IndentStringCache(options, baseIndentString);
this.raw = false;
this._end_with_newline = options.end_with_newline;
this.indent_size = options.indent_size;
this.wrap_line_length = options.wrap_line_length;
this.__lines = [];
this.previous_line = null;
this.current_line = null;
this.next_line = new OutputLine(this);
this.space_before_token = false;
this.non_breaking_space = false;
this.previous_token_wrapped = false;
// initialize

@@ -345,3 +422,3 @@ this.__add_outputline();

this.previous_line = this.current_line;
this.current_line = new OutputLine(this);
this.current_line = this.next_line.clone_empty();
this.__lines.push(this.current_line);

@@ -354,8 +431,8 @@ };

Output.prototype.get_indent_string = function(level) {
return this.__indent_cache.get_level_string(level);
Output.prototype.get_indent_string = function(indent, column) {
return this.__indent_cache.get_indent_string(indent, column);
};
Output.prototype.get_alignment_string = function(level) {
return this.__alignment_cache.get_level_string(level);
Output.prototype.get_indent_size = function(indent, column) {
return this.__indent_cache.get_indent_size(indent, column);
};

@@ -384,15 +461,30 @@

Output.prototype.get_code = function(eol) {
var sweet_code = this.__lines.join('\n').replace(/[\r\n\t ]+$/, '');
this.trim(true);
// handle some edge cases where the last tokens
// has text that ends with newline(s)
var last_item = this.current_line.pop();
if (last_item) {
if (last_item[last_item.length - 1] === '\n') {
last_item = last_item.replace(/\n+$/g, '');
}
this.current_line.push(last_item);
}
if (this._end_with_newline) {
sweet_code += '\n';
this.__add_outputline();
}
var sweet_code = this.__lines.join('\n');
if (eol !== '\n') {
sweet_code = sweet_code.replace(/[\n]/g, eol);
}
return sweet_code;
};
Output.prototype.set_wrap_point = function() {
this.current_line._set_wrap_point();
};
Output.prototype.set_indent = function(indent, alignment) {

@@ -402,2 +494,5 @@ indent = indent || 0;

// Next line stores alignment values
this.next_line.set_indent(indent, alignment);
// Never indent your first output indent at the start of the file

@@ -408,2 +503,3 @@ if (this.__lines.length > 1) {

}
this.current_line.set_indent();

@@ -417,17 +513,25 @@ return false;

}
this.current_line.set_indent(-1);
this.current_line.push(token.whitespace_before);
this.current_line.push_raw(token.text);
this.current_line.push(token.text);
this.space_before_token = false;
this.non_breaking_space = false;
this.previous_token_wrapped = false;
};
Output.prototype.add_token = function(printable_token) {
this.add_space_before_token();
this.__add_space_before_token();
this.current_line.push(printable_token);
this.space_before_token = false;
this.non_breaking_space = false;
this.previous_token_wrapped = this.current_line._allow_wrap();
};
Output.prototype.add_space_before_token = function() {
Output.prototype.__add_space_before_token = function() {
if (this.space_before_token && !this.just_added_newline()) {
if (!this.non_breaking_space) {
this.set_wrap_point();
}
this.current_line.push(' ');
}
this.space_before_token = false;
};

@@ -438,5 +542,6 @@

while (index < output_length) {
this.__lines[index].remove_indent();
this.__lines[index]._remove_indent();
index++;
}
this.current_line._remove_wrap_indent();
};

@@ -447,3 +552,3 @@

this.current_line.trim(this.indent_string, this.baseIndentString);
this.current_line.trim();

@@ -488,2 +593,3 @@ while (eat_newlines && this.__lines.length > 1 &&

/***/ }),

@@ -528,4 +634,3 @@ /* 3 */,

function Options(options, merge_child_field) {
options = _mergeOpts(options, merge_child_field);
this.raw_options = _normalizeOpts(options);
this.raw_options = _mergeOpts(options, merge_child_field);

@@ -547,6 +652,16 @@ // Support passing the source text back with no change

this.indent_with_tabs = this._get_boolean('indent_with_tabs');
this.indent_with_tabs = this._get_boolean('indent_with_tabs', this.indent_char === '\t');
if (this.indent_with_tabs) {
this.indent_char = '\t';
this.indent_size = 1;
// indent_size behavior changed after 1.8.6
// It used to be that indent_size would be
// set to 1 for indent_with_tabs. That is no longer needed and
// actually doesn't make sense - why not use spaces? Further,
// that might produce unexpected behavior - tabs being used
// for single-column alignment. So, when indent_with_tabs is true
// and indent_size is 1, reset indent_size to 4.
if (this.indent_size === 1) {
this.indent_size = 4;
}
}

@@ -642,6 +757,6 @@

//
// Returns: {a: 2, b: {a: 2}}
// Returns: {a: 2}
function _mergeOpts(allOptions, childFieldName) {
var finalOpts = {};
allOptions = allOptions || {};
allOptions = _normalizeOpts(allOptions);
var name;

@@ -679,2 +794,3 @@

/***/ }),

@@ -716,2 +832,4 @@ /* 7 */,

var regexp_has_sticky = RegExp.prototype.hasOwnProperty('sticky');
function InputScanner(input_string) {

@@ -756,10 +874,28 @@ this.__input = input_string || '';

// This is a JavaScript only helper function (not in python)
// Javascript doesn't have a match method
// and not all implementation support "sticky" flag.
// If they do not support sticky then both this.match() and this.test() method
// must get the match and check the index of the match.
// If sticky is supported and set, this method will use it.
// Otherwise it will check that global is set, and fall back to the slower method.
InputScanner.prototype.__match = function(pattern, index) {
pattern.lastIndex = index;
var pattern_match = pattern.exec(this.__input);
if (pattern_match && !(regexp_has_sticky && pattern.sticky)) {
if (pattern_match.index !== index) {
pattern_match = null;
}
}
return pattern_match;
};
InputScanner.prototype.test = function(pattern, index) {
index = index || 0;
index += this.__position;
pattern.lastIndex = index;
if (index >= 0 && index < this.__input_length) {
var pattern_match = pattern.exec(this.__input);
return pattern_match && pattern_match.index === index;
return !!this.__match(pattern, index);
} else {

@@ -773,2 +909,3 @@ return false;

var val = this.peek(index);
pattern.lastIndex = 0;
return val !== null && pattern.test(val);

@@ -778,5 +915,4 @@ };

InputScanner.prototype.match = function(pattern) {
pattern.lastIndex = this.__position;
var pattern_match = pattern.exec(this.__input);
if (pattern_match && pattern_match.index === this.__position) {
var pattern_match = this.__match(pattern, this.__position);
if (pattern_match) {
this.__position += pattern_match[0].length;

@@ -789,12 +925,18 @@ } else {

InputScanner.prototype.read = function(pattern) {
InputScanner.prototype.read = function(starting_pattern, until_pattern, until_after) {
var val = '';
var match = this.match(pattern);
if (match) {
val = match[0];
var match;
if (starting_pattern) {
match = this.match(starting_pattern);
if (match) {
val += match[0];
}
}
if (until_pattern && (match || !starting_pattern)) {
val += this.readUntil(until_pattern, until_after);
}
return val;
};
InputScanner.prototype.readUntil = function(pattern, include_match) {
InputScanner.prototype.readUntil = function(pattern, until_after) {
var val = '';

@@ -805,6 +947,5 @@ var match_index = this.__position;

if (pattern_match) {
if (include_match) {
match_index = pattern_match.index + pattern_match[0].length;
} else {
match_index = pattern_match.index;
match_index = pattern_match.index;
if (until_after) {
match_index += pattern_match[0].length;
}

@@ -824,2 +965,22 @@ } else {

InputScanner.prototype.get_regexp = function(pattern, match_from) {
var result = null;
var flags = 'g';
if (match_from && regexp_has_sticky) {
flags = 'y';
}
// strings are converted to regexp
if (typeof pattern === "string" && pattern !== '') {
// result = new RegExp(pattern.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&'), flags);
result = new RegExp(pattern, flags);
} else if (pattern) {
result = new RegExp(pattern.source, flags);
}
return result;
};
InputScanner.prototype.get_literal_regexp = function(literal_string) {
return RegExp(literal_string.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&'));
};
/* css beautifier legacy helpers */

@@ -839,5 +1000,5 @@ InputScanner.prototype.peekUntilAfter = function(pattern) {

module.exports.InputScanner = InputScanner;
/***/ }),

@@ -847,3 +1008,4 @@ /* 9 */,

/* 11 */,
/* 12 */
/* 12 */,
/* 13 */
/***/ (function(module, exports, __webpack_require__) {

@@ -882,4 +1044,75 @@

var Beautifier = __webpack_require__(13).Beautifier;
function Directives(start_block_pattern, end_block_pattern) {
start_block_pattern = typeof start_block_pattern === 'string' ? start_block_pattern : start_block_pattern.source;
end_block_pattern = typeof end_block_pattern === 'string' ? end_block_pattern : end_block_pattern.source;
this.__directives_block_pattern = new RegExp(start_block_pattern + / beautify( \w+[:]\w+)+ /.source + end_block_pattern, 'g');
this.__directive_pattern = / (\w+)[:](\w+)/g;
this.__directives_end_ignore_pattern = new RegExp(start_block_pattern + /\sbeautify\signore:end\s/.source + end_block_pattern, 'g');
}
Directives.prototype.get_directives = function(text) {
if (!text.match(this.__directives_block_pattern)) {
return null;
}
var directives = {};
this.__directive_pattern.lastIndex = 0;
var directive_match = this.__directive_pattern.exec(text);
while (directive_match) {
directives[directive_match[1]] = directive_match[2];
directive_match = this.__directive_pattern.exec(text);
}
return directives;
};
Directives.prototype.readIgnored = function(input) {
return input.readUntilAfter(this.__directives_end_ignore_pattern);
};
module.exports.Directives = Directives;
/***/ }),
/* 14 */,
/* 15 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/*jshint node:true */
/*
The MIT License (MIT)
Copyright (c) 2007-2018 Einar Lielmanis, Liam Newman, and contributors.
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation files
(the "Software"), to deal in the Software without restriction,
including without limitation the rights to use, copy, modify, merge,
publish, distribute, sublicense, and/or sell copies of the Software,
and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
var Beautifier = __webpack_require__(16).Beautifier,
Options = __webpack_require__(17).Options;
function css_beautify(source_text, options) {

@@ -891,5 +1124,9 @@ var beautifier = new Beautifier(source_text, options);

module.exports = css_beautify;
module.exports.defaultOptions = function() {
return new Options();
};
/***/ }),
/* 13 */
/* 16 */
/***/ (function(module, exports, __webpack_require__) {

@@ -928,6 +1165,9 @@

var Options = __webpack_require__(14).Options;
var Options = __webpack_require__(17).Options;
var Output = __webpack_require__(2).Output;
var InputScanner = __webpack_require__(8).InputScanner;
var Directives = __webpack_require__(13).Directives;
var directives_core = new Directives(/\/\*/, /\*\//);
var lineBreak = /\r\n|[\r\n]/;

@@ -1031,5 +1271,4 @@ var allLineBreaks = /\r\n|[\r\n]/g;

Beautifier.prototype.print_string = function(output_string) {
if (this._output.just_added_newline()) {
this._output.set_indent(this._indentLevel);
}
this._output.set_indent(this._indentLevel);
this._output.non_breaking_space = true;
this._output.add_token(output_string);

@@ -1093,7 +1332,10 @@ };

var topCharacter = this._ch;
var whitespace;
var isAfterSpace;
var previous_ch;
while (true) {
var whitespace = this._input.read(whitespacePattern);
var isAfterSpace = whitespace !== '';
var previous_ch = topCharacter;
whitespace = this._input.read(whitespacePattern);
isAfterSpace = whitespace !== '';
previous_ch = topCharacter;
this._ch = this._input.next();

@@ -1112,4 +1354,13 @@ topCharacter = this._ch;

this._input.back();
this.print_string(this._input.read(block_comment_pattern));
var comment = this._input.read(block_comment_pattern);
// Handle ignore directive
var directives = directives_core.get_directives(comment);
if (directives && directives.ignore === 'start') {
comment += directives_core.readIgnored(this._input);
}
this.print_string(comment);
// Ensures any new lines following the comment are preserved

@@ -1341,4 +1592,5 @@ this.eatWhitespace(true);

/***/ }),
/* 14 */
/* 17 */
/***/ (function(module, exports, __webpack_require__) {

@@ -1394,2 +1646,3 @@

/***/ })

@@ -1396,0 +1649,0 @@ /******/ ]);

@@ -40,6 +40,6 @@ /*---------------------------------------------------------------------------------------------

range = Range.create(document.positionAt(startOffset), document.positionAt(endOffset));
//Do not modify if substring in inside an element
// Do not modify if substring starts in inside an element
// Ending inside an element is fine as it doesn't cause formatting errors
var firstHalf = value.substring(0, startOffset);
var secondHalf = value.substring(endOffset, value.length);
if (new RegExp(/.*[<][^>]*$/).test(firstHalf) && new RegExp(/^[^<]*[>].*/).test(secondHalf)) {
if (new RegExp(/.*[<][^>]*$/).test(firstHalf)) {
//return without modification

@@ -63,3 +63,3 @@ value = value.substring(startOffset, endOffset);

var htmlOptions = {
indent_size: options.insertSpaces ? tabSize : 1,
indent_size: tabSize,
indent_char: options.insertSpaces ? ' ' : '\t',

@@ -79,3 +79,3 @@ wrap_line_length: getFormatOption(options, 'wrapLineLength', 120),

};
var result = html_beautify(value, htmlOptions);
var result = html_beautify(trimLeft(value), htmlOptions);
if (initialIndentLevel > 0) {

@@ -93,2 +93,5 @@ var indent = options.insertSpaces ? repeat(' ', tabSize * initialIndentLevel) : repeat('\t', initialIndentLevel);

}
function trimLeft(str) {
return str.replace(/^\s+/, '');
}
function getFormatOption(options, key, dflt) {

@@ -95,0 +98,0 @@ if (options && options.hasOwnProperty(key)) {

// copied from js-beautify/js/lib/beautify-css.js
// version: 1.8.6
// version: 1.9.0-beta4
/* AUTO-GENERATED. DO NOT MODIFY. */

@@ -154,3 +154,3 @@ /*

/******/ // Load entry module and return exports
/******/ return __webpack_require__(__webpack_require__.s = 12);
/******/ return __webpack_require__(__webpack_require__.s = 15);
/******/ })

@@ -167,3 +167,2 @@ /************************************************************************/

/*
The MIT License (MIT)

@@ -202,2 +201,6 @@

this.__alignment_count = 0;
this.__wrap_point_index = 0;
this.__wrap_point_character_count = 0;
this.__wrap_point_indent_count = -1;
this.__wrap_point_alignment_count = 0;

@@ -207,2 +210,8 @@ this.__items = [];

OutputLine.prototype.clone_empty = function() {
var line = new OutputLine(this.__parent);
line.set_indent(this.__indent_count, this.__alignment_count);
return line;
};
OutputLine.prototype.item = function(index) {

@@ -226,11 +235,44 @@ if (index < 0) {

OutputLine.prototype.set_indent = function(indent, alignment) {
this.__indent_count = indent || 0;
this.__alignment_count = alignment || 0;
this.__character_count = this.__parent.baseIndentLength + this.__alignment_count + this.__indent_count * this.__parent.indent_length;
if (this.is_empty()) {
this.__indent_count = indent || 0;
this.__alignment_count = alignment || 0;
this.__character_count = this.__parent.get_indent_size(this.__indent_count, this.__alignment_count);
}
};
OutputLine.prototype.get_character_count = function() {
return this.__character_count;
OutputLine.prototype._set_wrap_point = function() {
if (this.__parent.wrap_line_length) {
this.__wrap_point_index = this.__items.length;
this.__wrap_point_character_count = this.__character_count;
this.__wrap_point_indent_count = this.__parent.next_line.__indent_count;
this.__wrap_point_alignment_count = this.__parent.next_line.__alignment_count;
}
};
OutputLine.prototype._should_wrap = function() {
return this.__wrap_point_index &&
this.__character_count > this.__parent.wrap_line_length &&
this.__wrap_point_character_count > this.__parent.next_line.__character_count;
};
OutputLine.prototype._allow_wrap = function() {
if (this._should_wrap()) {
this.__parent.add_new_line();
var next = this.__parent.current_line;
next.set_indent(this.__wrap_point_indent_count, this.__wrap_point_alignment_count);
next.__items = this.__items.slice(this.__wrap_point_index);
this.__items = this.__items.slice(0, this.__wrap_point_index);
next.__character_count += this.__character_count - this.__wrap_point_character_count;
this.__character_count = this.__wrap_point_character_count;
if (next.__items[0] === " ") {
next.__items.splice(0, 1);
next.__character_count -= 1;
}
return true;
}
return false;
};
OutputLine.prototype.is_empty = function() {

@@ -250,10 +292,7 @@ return this.__items.length === 0;

this.__items.push(item);
this.__character_count += item.length;
};
OutputLine.prototype.push_raw = function(item) {
this.push(item);
var last_newline_index = item.lastIndexOf('\n');
if (last_newline_index !== -1) {
this.__character_count = item.length - last_newline_index;
} else {
this.__character_count += item.length;
}

@@ -271,9 +310,15 @@ };

OutputLine.prototype.remove_indent = function() {
OutputLine.prototype._remove_indent = function() {
if (this.__indent_count > 0) {
this.__indent_count -= 1;
this.__character_count -= this.__parent.indent_length;
this.__character_count -= this.__parent.indent_size;
}
};
OutputLine.prototype._remove_wrap_indent = function() {
if (this.__wrap_point_indent_count > 0) {
this.__wrap_point_indent_count -= 1;
}
};
OutputLine.prototype.trim = function() {

@@ -289,8 +334,3 @@ while (this.last() === ' ') {

if (!this.is_empty()) {
if (this.__indent_count >= 0) {
result = this.__parent.get_indent_string(this.__indent_count);
}
if (this.__alignment_count >= 0) {
result += this.__parent.get_alignment_string(this.__alignment_count);
}
result = this.__parent.get_indent_string(this.__indent_count, this.__alignment_count);
result += this.__items.join('');

@@ -301,42 +341,79 @@ }

function IndentCache(base_string, level_string) {
this.__cache = [base_string];
this.__level_string = level_string;
function IndentStringCache(options, baseIndentString) {
this.__cache = [''];
this.__indent_size = options.indent_size;
this.__indent_string = options.indent_char;
if (!options.indent_with_tabs) {
this.__indent_string = new Array(options.indent_size + 1).join(options.indent_char);
}
// Set to null to continue support for auto detection of base indent
baseIndentString = baseIndentString || '';
if (options.indent_level > 0) {
baseIndentString = new Array(options.indent_level + 1).join(this.__indent_string);
}
this.__base_string = baseIndentString;
this.__base_string_length = baseIndentString.length;
}
IndentCache.prototype.__ensure_cache = function(level) {
while (level >= this.__cache.length) {
this.__cache.push(this.__cache[this.__cache.length - 1] + this.__level_string);
IndentStringCache.prototype.get_indent_size = function(indent, column) {
var result = this.__base_string_length;
column = column || 0;
if (indent < 0) {
result = 0;
}
result += indent * this.__indent_size;
result += column;
return result;
};
IndentCache.prototype.get_level_string = function(level) {
this.__ensure_cache(level);
return this.__cache[level];
IndentStringCache.prototype.get_indent_string = function(indent_level, column) {
var result = this.__base_string;
column = column || 0;
if (indent_level < 0) {
indent_level = 0;
result = '';
}
column += indent_level * this.__indent_size;
this.__ensure_cache(column);
result += this.__cache[column];
return result;
};
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);
IndentStringCache.prototype.__ensure_cache = function(column) {
while (column >= this.__cache.length) {
this.__add_column();
}
};
// 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);
IndentStringCache.prototype.__add_column = function() {
var column = this.__cache.length;
var indent = 0;
var result = '';
if (this.__indent_size && column >= this.__indent_size) {
indent = Math.floor(column / this.__indent_size);
column -= indent * this.__indent_size;
result = new Array(indent + 1).join(this.__indent_string);
}
if (column) {
result += new Array(column + 1).join(' ');
}
this.__indent_cache = new IndentCache(baseIndentString, indent_string);
this.__alignment_cache = new IndentCache('', ' ');
this.baseIndentLength = baseIndentString.length;
this.indent_length = indent_string.length;
this.__cache.push(result);
};
function Output(options, baseIndentString) {
this.__indent_cache = new IndentStringCache(options, baseIndentString);
this.raw = false;
this._end_with_newline = options.end_with_newline;
this.indent_size = options.indent_size;
this.wrap_line_length = options.wrap_line_length;
this.__lines = [];
this.previous_line = null;
this.current_line = null;
this.next_line = new OutputLine(this);
this.space_before_token = false;
this.non_breaking_space = false;
this.previous_token_wrapped = false;
// initialize

@@ -348,3 +425,3 @@ this.__add_outputline();

this.previous_line = this.current_line;
this.current_line = new OutputLine(this);
this.current_line = this.next_line.clone_empty();
this.__lines.push(this.current_line);

@@ -357,8 +434,8 @@ };

Output.prototype.get_indent_string = function(level) {
return this.__indent_cache.get_level_string(level);
Output.prototype.get_indent_string = function(indent, column) {
return this.__indent_cache.get_indent_string(indent, column);
};
Output.prototype.get_alignment_string = function(level) {
return this.__alignment_cache.get_level_string(level);
Output.prototype.get_indent_size = function(indent, column) {
return this.__indent_cache.get_indent_size(indent, column);
};

@@ -387,15 +464,30 @@

Output.prototype.get_code = function(eol) {
var sweet_code = this.__lines.join('\n').replace(/[\r\n\t ]+$/, '');
this.trim(true);
// handle some edge cases where the last tokens
// has text that ends with newline(s)
var last_item = this.current_line.pop();
if (last_item) {
if (last_item[last_item.length - 1] === '\n') {
last_item = last_item.replace(/\n+$/g, '');
}
this.current_line.push(last_item);
}
if (this._end_with_newline) {
sweet_code += '\n';
this.__add_outputline();
}
var sweet_code = this.__lines.join('\n');
if (eol !== '\n') {
sweet_code = sweet_code.replace(/[\n]/g, eol);
}
return sweet_code;
};
Output.prototype.set_wrap_point = function() {
this.current_line._set_wrap_point();
};
Output.prototype.set_indent = function(indent, alignment) {

@@ -405,2 +497,5 @@ indent = indent || 0;

// Next line stores alignment values
this.next_line.set_indent(indent, alignment);
// Never indent your first output indent at the start of the file

@@ -411,2 +506,3 @@ if (this.__lines.length > 1) {

}
this.current_line.set_indent();

@@ -420,17 +516,25 @@ return false;

}
this.current_line.set_indent(-1);
this.current_line.push(token.whitespace_before);
this.current_line.push_raw(token.text);
this.current_line.push(token.text);
this.space_before_token = false;
this.non_breaking_space = false;
this.previous_token_wrapped = false;
};
Output.prototype.add_token = function(printable_token) {
this.add_space_before_token();
this.__add_space_before_token();
this.current_line.push(printable_token);
this.space_before_token = false;
this.non_breaking_space = false;
this.previous_token_wrapped = this.current_line._allow_wrap();
};
Output.prototype.add_space_before_token = function() {
Output.prototype.__add_space_before_token = function() {
if (this.space_before_token && !this.just_added_newline()) {
if (!this.non_breaking_space) {
this.set_wrap_point();
}
this.current_line.push(' ');
}
this.space_before_token = false;
};

@@ -441,5 +545,6 @@

while (index < output_length) {
this.__lines[index].remove_indent();
this.__lines[index]._remove_indent();
index++;
}
this.current_line._remove_wrap_indent();
};

@@ -450,3 +555,3 @@

this.current_line.trim(this.indent_string, this.baseIndentString);
this.current_line.trim();

@@ -491,2 +596,3 @@ while (eat_newlines && this.__lines.length > 1 &&

/***/ }),

@@ -531,4 +637,3 @@ /* 3 */,

function Options(options, merge_child_field) {
options = _mergeOpts(options, merge_child_field);
this.raw_options = _normalizeOpts(options);
this.raw_options = _mergeOpts(options, merge_child_field);

@@ -550,6 +655,16 @@ // Support passing the source text back with no change

this.indent_with_tabs = this._get_boolean('indent_with_tabs');
this.indent_with_tabs = this._get_boolean('indent_with_tabs', this.indent_char === '\t');
if (this.indent_with_tabs) {
this.indent_char = '\t';
this.indent_size = 1;
// indent_size behavior changed after 1.8.6
// It used to be that indent_size would be
// set to 1 for indent_with_tabs. That is no longer needed and
// actually doesn't make sense - why not use spaces? Further,
// that might produce unexpected behavior - tabs being used
// for single-column alignment. So, when indent_with_tabs is true
// and indent_size is 1, reset indent_size to 4.
if (this.indent_size === 1) {
this.indent_size = 4;
}
}

@@ -645,6 +760,6 @@

//
// Returns: {a: 2, b: {a: 2}}
// Returns: {a: 2}
function _mergeOpts(allOptions, childFieldName) {
var finalOpts = {};
allOptions = allOptions || {};
allOptions = _normalizeOpts(allOptions);
var name;

@@ -682,2 +797,3 @@

/***/ }),

@@ -719,2 +835,4 @@ /* 7 */,

var regexp_has_sticky = RegExp.prototype.hasOwnProperty('sticky');
function InputScanner(input_string) {

@@ -759,10 +877,28 @@ this.__input = input_string || '';

// This is a JavaScript only helper function (not in python)
// Javascript doesn't have a match method
// and not all implementation support "sticky" flag.
// If they do not support sticky then both this.match() and this.test() method
// must get the match and check the index of the match.
// If sticky is supported and set, this method will use it.
// Otherwise it will check that global is set, and fall back to the slower method.
InputScanner.prototype.__match = function(pattern, index) {
pattern.lastIndex = index;
var pattern_match = pattern.exec(this.__input);
if (pattern_match && !(regexp_has_sticky && pattern.sticky)) {
if (pattern_match.index !== index) {
pattern_match = null;
}
}
return pattern_match;
};
InputScanner.prototype.test = function(pattern, index) {
index = index || 0;
index += this.__position;
pattern.lastIndex = index;
if (index >= 0 && index < this.__input_length) {
var pattern_match = pattern.exec(this.__input);
return pattern_match && pattern_match.index === index;
return !!this.__match(pattern, index);
} else {

@@ -776,2 +912,3 @@ return false;

var val = this.peek(index);
pattern.lastIndex = 0;
return val !== null && pattern.test(val);

@@ -781,5 +918,4 @@ };

InputScanner.prototype.match = function(pattern) {
pattern.lastIndex = this.__position;
var pattern_match = pattern.exec(this.__input);
if (pattern_match && pattern_match.index === this.__position) {
var pattern_match = this.__match(pattern, this.__position);
if (pattern_match) {
this.__position += pattern_match[0].length;

@@ -792,12 +928,18 @@ } else {

InputScanner.prototype.read = function(pattern) {
InputScanner.prototype.read = function(starting_pattern, until_pattern, until_after) {
var val = '';
var match = this.match(pattern);
if (match) {
val = match[0];
var match;
if (starting_pattern) {
match = this.match(starting_pattern);
if (match) {
val += match[0];
}
}
if (until_pattern && (match || !starting_pattern)) {
val += this.readUntil(until_pattern, until_after);
}
return val;
};
InputScanner.prototype.readUntil = function(pattern, include_match) {
InputScanner.prototype.readUntil = function(pattern, until_after) {
var val = '';

@@ -808,6 +950,5 @@ var match_index = this.__position;

if (pattern_match) {
if (include_match) {
match_index = pattern_match.index + pattern_match[0].length;
} else {
match_index = pattern_match.index;
match_index = pattern_match.index;
if (until_after) {
match_index += pattern_match[0].length;
}

@@ -827,2 +968,22 @@ } else {

InputScanner.prototype.get_regexp = function(pattern, match_from) {
var result = null;
var flags = 'g';
if (match_from && regexp_has_sticky) {
flags = 'y';
}
// strings are converted to regexp
if (typeof pattern === "string" && pattern !== '') {
// result = new RegExp(pattern.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&'), flags);
result = new RegExp(pattern, flags);
} else if (pattern) {
result = new RegExp(pattern.source, flags);
}
return result;
};
InputScanner.prototype.get_literal_regexp = function(literal_string) {
return RegExp(literal_string.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&'));
};
/* css beautifier legacy helpers */

@@ -842,5 +1003,5 @@ InputScanner.prototype.peekUntilAfter = function(pattern) {

module.exports.InputScanner = InputScanner;
/***/ }),

@@ -850,3 +1011,4 @@ /* 9 */,

/* 11 */,
/* 12 */
/* 12 */,
/* 13 */
/***/ (function(module, exports, __webpack_require__) {

@@ -885,4 +1047,75 @@

var Beautifier = __webpack_require__(13).Beautifier;
function Directives(start_block_pattern, end_block_pattern) {
start_block_pattern = typeof start_block_pattern === 'string' ? start_block_pattern : start_block_pattern.source;
end_block_pattern = typeof end_block_pattern === 'string' ? end_block_pattern : end_block_pattern.source;
this.__directives_block_pattern = new RegExp(start_block_pattern + / beautify( \w+[:]\w+)+ /.source + end_block_pattern, 'g');
this.__directive_pattern = / (\w+)[:](\w+)/g;
this.__directives_end_ignore_pattern = new RegExp(start_block_pattern + /\sbeautify\signore:end\s/.source + end_block_pattern, 'g');
}
Directives.prototype.get_directives = function(text) {
if (!text.match(this.__directives_block_pattern)) {
return null;
}
var directives = {};
this.__directive_pattern.lastIndex = 0;
var directive_match = this.__directive_pattern.exec(text);
while (directive_match) {
directives[directive_match[1]] = directive_match[2];
directive_match = this.__directive_pattern.exec(text);
}
return directives;
};
Directives.prototype.readIgnored = function(input) {
return input.readUntilAfter(this.__directives_end_ignore_pattern);
};
module.exports.Directives = Directives;
/***/ }),
/* 14 */,
/* 15 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/*jshint node:true */
/*
The MIT License (MIT)
Copyright (c) 2007-2018 Einar Lielmanis, Liam Newman, and contributors.
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation files
(the "Software"), to deal in the Software without restriction,
including without limitation the rights to use, copy, modify, merge,
publish, distribute, sublicense, and/or sell copies of the Software,
and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
var Beautifier = __webpack_require__(16).Beautifier,
Options = __webpack_require__(17).Options;
function css_beautify(source_text, options) {

@@ -894,5 +1127,9 @@ var beautifier = new Beautifier(source_text, options);

module.exports = css_beautify;
module.exports.defaultOptions = function() {
return new Options();
};
/***/ }),
/* 13 */
/* 16 */
/***/ (function(module, exports, __webpack_require__) {

@@ -931,6 +1168,9 @@

var Options = __webpack_require__(14).Options;
var Options = __webpack_require__(17).Options;
var Output = __webpack_require__(2).Output;
var InputScanner = __webpack_require__(8).InputScanner;
var Directives = __webpack_require__(13).Directives;
var directives_core = new Directives(/\/\*/, /\*\//);
var lineBreak = /\r\n|[\r\n]/;

@@ -1034,5 +1274,4 @@ var allLineBreaks = /\r\n|[\r\n]/g;

Beautifier.prototype.print_string = function(output_string) {
if (this._output.just_added_newline()) {
this._output.set_indent(this._indentLevel);
}
this._output.set_indent(this._indentLevel);
this._output.non_breaking_space = true;
this._output.add_token(output_string);

@@ -1096,7 +1335,10 @@ };

var topCharacter = this._ch;
var whitespace;
var isAfterSpace;
var previous_ch;
while (true) {
var whitespace = this._input.read(whitespacePattern);
var isAfterSpace = whitespace !== '';
var previous_ch = topCharacter;
whitespace = this._input.read(whitespacePattern);
isAfterSpace = whitespace !== '';
previous_ch = topCharacter;
this._ch = this._input.next();

@@ -1115,4 +1357,13 @@ topCharacter = this._ch;

this._input.back();
this.print_string(this._input.read(block_comment_pattern));
var comment = this._input.read(block_comment_pattern);
// Handle ignore directive
var directives = directives_core.get_directives(comment);
if (directives && directives.ignore === 'start') {
comment += directives_core.readIgnored(this._input);
}
this.print_string(comment);
// Ensures any new lines following the comment are preserved

@@ -1344,4 +1595,5 @@ this.eatWhitespace(true);

/***/ }),
/* 14 */
/* 17 */
/***/ (function(module, exports, __webpack_require__) {

@@ -1397,2 +1649,3 @@

/***/ })

@@ -1399,0 +1652,0 @@ /******/ ]);

@@ -50,6 +50,6 @@ (function (factory) {

range = vscode_languageserver_types_1.Range.create(document.positionAt(startOffset), document.positionAt(endOffset));
//Do not modify if substring in inside an element
// Do not modify if substring starts in inside an element
// Ending inside an element is fine as it doesn't cause formatting errors
var firstHalf = value.substring(0, startOffset);
var secondHalf = value.substring(endOffset, value.length);
if (new RegExp(/.*[<][^>]*$/).test(firstHalf) && new RegExp(/^[^<]*[>].*/).test(secondHalf)) {
if (new RegExp(/.*[<][^>]*$/).test(firstHalf)) {
//return without modification

@@ -73,3 +73,3 @@ value = value.substring(startOffset, endOffset);

var htmlOptions = {
indent_size: options.insertSpaces ? tabSize : 1,
indent_size: tabSize,
indent_char: options.insertSpaces ? ' ' : '\t',

@@ -89,3 +89,3 @@ wrap_line_length: getFormatOption(options, 'wrapLineLength', 120),

};
var result = beautify_html_1.html_beautify(value, htmlOptions);
var result = beautify_html_1.html_beautify(trimLeft(value), htmlOptions);
if (initialIndentLevel > 0) {

@@ -104,2 +104,5 @@ var indent = options.insertSpaces ? strings_1.repeat(' ', tabSize * initialIndentLevel) : strings_1.repeat('\t', initialIndentLevel);

exports.format = format;
function trimLeft(str) {
return str.replace(/^\s+/, '');
}
function getFormatOption(options, key, dflt) {

@@ -106,0 +109,0 @@ if (options && options.hasOwnProperty(key)) {

{
"name": "vscode-html-languageservice",
"version": "2.1.11-next.7",
"version": "2.1.11-next.8",
"description": "Language service for HTML",

@@ -21,3 +21,3 @@ "main": "./lib/umd/htmlLanguageService.js",

"cpy-cli": "^2.0.0",
"js-beautify": "^1.8.6",
"js-beautify": "^1.9.0-beta4",
"mocha": "^5.2.0",

@@ -24,0 +24,0 @@ "rimraf": "^2.6.2",

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc