New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

js-beautify

Package Overview
Dependencies
Maintainers
2
Versions
131
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

js-beautify - npm Package Compare versions

Comparing version 1.15.1 to 1.15.2

4

js/src/core/templatablepattern.js

@@ -138,2 +138,6 @@ /*jshint node:true */

}
if (!this._disabled.angular) {
// Handlebars ('{{' and '}}') are also special tokens in Angular)
items.push(this.__patterns.handlebars._starting_pattern.source);
}
if (!this._disabled.erb) {

@@ -140,0 +144,0 @@ items.push(this.__patterns.erb._starting_pattern.source);

9

js/src/html/beautifier.js

@@ -294,3 +294,3 @@ /*jshint node:true */

var last_tag_token = new TagOpenParserToken();
var last_tag_token = new TagOpenParserToken(this._options);

@@ -618,3 +618,3 @@ var printer = new Printer(this._options, baseIndentString);

var TagOpenParserToken = function(parent, raw_token) {
var TagOpenParserToken = function(options, parent, raw_token) {
this.parent = parent || null;

@@ -686,4 +686,5 @@ this.text = '';

// handlebars tags that don't start with # or ^ are single_tags, and so also start and end.
// if they start with # or ^, they are still considered single tags if indenting of handlebars is set to false
this.is_end_tag = this.is_end_tag ||
(this.tag_start_char === '{' && (this.text.length < 3 || (/[^#\^]/.test(this.text.charAt(handlebar_starts)))));
(this.tag_start_char === '{' && (!options.indent_handlebars || this.text.length < 3 || (/[^#\^]/.test(this.text.charAt(handlebar_starts)))));
}

@@ -693,3 +694,3 @@ };

Beautifier.prototype._get_tag_open_token = function(raw_token) { //function to get a full tag and parse its type
var parser_token = new TagOpenParserToken(this._tag_stack.get_parser_token(), raw_token);
var parser_token = new TagOpenParserToken(this._options, this._tag_stack.get_parser_token(), raw_token);

@@ -696,0 +697,0 @@ parser_token.alignment_size = this._options.wrap_attributes_indent_size;

@@ -133,2 +133,3 @@ /*jshint node:true */

token = token || this._read_close(c, open_token);
token = token || this._read_script_and_style(c, previous_token);
token = token || this._read_control_flows(c, open_token);

@@ -219,4 +220,4 @@ token = token || this._read_raw_content(c, previous_token, open_token);

if (!open_token || open_token.type === TOKEN.CONTROL_FLOW_OPEN) {
if (this._options.indent_handlebars && c === '{' && this._input.peek(1) === '{') {
if (this._input.peek(2) === '!') {
if ((this._options.templating.includes('angular') || this._options.indent_handlebars) && c === '{' && this._input.peek(1) === '{') {
if (this._options.indent_handlebars && this._input.peek(2) === '!') {
resulting_string = this.__patterns.handlebars_comment.read();

@@ -237,4 +238,4 @@ resulting_string = resulting_string || this.__patterns.handlebars.read();

var token = null;
// Only check for control flows if angular templating is set AND indenting is set
if (!this._options.templating.includes('angular') || !this._options.indent_handlebars) {
// Only check for control flows if angular templating is set
if (!this._options.templating.includes('angular')) {
return token;

@@ -332,3 +333,2 @@ }

Tokenizer.prototype._read_raw_content = function(c, previous_token, open_token) { // jshint unused:false

@@ -342,2 +342,18 @@ var resulting_string = '';

var tag_name = previous_token.opened.text.substr(1).toLowerCase();
if (this._is_content_unformatted(tag_name)) {
resulting_string = this._input.readUntil(new RegExp('</' + tag_name + '[\\n\\r\\t ]*?>', 'ig'));
}
}
if (resulting_string) {
return this._create_token(TOKEN.TEXT, resulting_string);
}
return null;
};
Tokenizer.prototype._read_script_and_style = function(c, previous_token) { // jshint unused:false
if (previous_token.type === TOKEN.TAG_CLOSE && previous_token.opened.text[0] === '<' && previous_token.text[0] !== '/') {
var tag_name = previous_token.opened.text.substr(1).toLowerCase();
if (tag_name === 'script' || tag_name === 'style') {

@@ -351,13 +367,8 @@ // Script and style tags are allowed to have comments wrapping their content

}
resulting_string = this._input.readUntil(new RegExp('</' + tag_name + '[\\n\\r\\t ]*?>', 'ig'));
} else if (this._is_content_unformatted(tag_name)) {
resulting_string = this._input.readUntil(new RegExp('</' + tag_name + '[\\n\\r\\t ]*?>', 'ig'));
var resulting_string = this._input.readUntil(new RegExp('</' + tag_name + '[\\n\\r\\t ]*?>', 'ig'));
if (resulting_string) {
return this._create_token(TOKEN.TEXT, resulting_string);
}
}
}
if (resulting_string) {
return this._create_token(TOKEN.TEXT, resulting_string);
}
return null;

@@ -380,2 +391,3 @@ };

}
return null;
};

@@ -382,0 +394,0 @@

{
"name": "js-beautify",
"version": "1.15.1",
"version": "1.15.2",
"description": "beautifier.io for node",

@@ -54,5 +54,5 @@ "main": "js/index.js",

"editorconfig": "^1.0.4",
"glob": "^10.3.3",
"glob": "^11.0.0",
"js-cookie": "^3.0.5",
"nopt": "^7.2.0"
"nopt": "^8.0.0"
},

@@ -66,3 +66,3 @@ "devDependencies": {

"minimist": "^1.2.8",
"mocha": "^10.2.0",
"mocha": "^11.0.1",
"mustache": "^4.2.0",

@@ -73,4 +73,4 @@ "requirejs": "^2.3.6",

"webpack": "^5.81.0",
"webpack-cli": "^5.1.4"
"webpack-cli": "^6.0.1"
}
}

@@ -61,9 +61,9 @@ <p align="center"><img src="https://raw.githubusercontent.com/beautifier/js-beautify/7db71fc/web/wordmark-light.svg" height="200px" align="center" alt="JS Beautifier"/></p>

```html
<script src="https://cdnjs.cloudflare.com/ajax/libs/js-beautify/1.15.1/beautify.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/js-beautify/1.15.1/beautify-css.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/js-beautify/1.15.1/beautify-html.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/js-beautify/1.15.2/beautify.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/js-beautify/1.15.2/beautify-css.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/js-beautify/1.15.2/beautify-html.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/js-beautify/1.15.1/beautify.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/js-beautify/1.15.1/beautify-css.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/js-beautify/1.15.1/beautify-html.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/js-beautify/1.15.2/beautify.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/js-beautify/1.15.2/beautify-css.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/js-beautify/1.15.2/beautify-html.min.js"></script>
```

@@ -80,3 +80,3 @@

<script src="https://cdnjs.cloudflare.com/ajax/libs/js-beautify/1.15.1/beautify.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/js-beautify/1.15.2/beautify.min.js"></script>
<script src="script.js"></script>

@@ -157,2 +157,13 @@ </body>

If you are using ESM Imports, you can import `js-beautify` like this:
```js
// 'beautify' can be any name here.
import beautify from 'js-beautify';
beautify.js(data, options);
beautify.html(data, options);
beautify.css(data, options);
```
## Python

@@ -440,2 +451,2 @@ After installing, to beautify using Python:

(README.md: js-beautify@1.15.1)
(README.md: js-beautify@1.15.2)

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

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

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