Socket
Socket
Sign inDemoInstall

js-beautify

Package Overview
Dependencies
Maintainers
2
Versions
128
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.10.3 to 1.11.0

13

CHANGELOG.md
# Changelog
## v1.11.0
### Description
### Closed Issues
* Please bump mkdirp to fix mkdirp@0.5.1 vulnerability ([#1768](https://github.com/beautify-web/js-beautify/issues/1768))
* Support optional-chaining ([#1727](https://github.com/beautify-web/js-beautify/issues/1727))
* Please support es module ([#1706](https://github.com/beautify-web/js-beautify/issues/1706))
* Support new js proposals: optional-chaining & pipeline-operator ([#1530](https://github.com/beautify-web/js-beautify/issues/1530))
* Optional <p> closing not implemented ([#1503](https://github.com/beautify-web/js-beautify/issues/1503))
## v1.10.3

@@ -3,0 +16,0 @@

30

js/src/html/beautifier.js

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

result = 'css';
} else if (typeAttribute.search(/(text|application|dojo)\/(x-)?(javascript|ecmascript|jscript|livescript|(ld\+)?json|method|aspect)/) > -1) {
} else if (typeAttribute.search(/module|((text|application|dojo)\/(x-)?(javascript|ecmascript|jscript|livescript|(ld\+)?json|method|aspect))/) > -1) {
result = 'javascript';

@@ -554,2 +554,3 @@ } else if (typeAttribute.search(/(text|application|dojo)\/(x-)?(html)/) > -1) {

printer.add_raw_token(raw_token);
parser_token.start_tag_token = this._tag_stack.try_pop(parser_token.tag_name);
} else {

@@ -610,4 +611,9 @@ printer.traverse_whitespace(raw_token);

} else {
tag_check_match = raw_token.text.match(/^{{[#\^]?([^\s}]+)/);
tag_check_match = raw_token.text.match(/^{{(?:[\^]|#\*?)?([^\s}]+)/);
this.tag_check = tag_check_match ? tag_check_match[1] : '';
// handle "{{#> myPartial}}
if (raw_token.text === '{{#>' && this.tag_check === '>' && raw_token.next !== null) {
this.tag_check = raw_token.next.text;
}
}

@@ -741,3 +747,4 @@ this.tag_check = this.tag_check.toLowerCase();

//To be used for <p> tag special case:
//var p_closers = ['address', 'article', 'aside', 'blockquote', 'details', 'div', 'dl', 'fieldset', 'figcaption', 'figure', 'footer', 'form', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'header', 'hr', 'main', 'nav', 'ol', 'p', 'pre', 'section', 'table', 'ul'];
var p_closers = ['address', 'article', 'aside', 'blockquote', 'details', 'div', 'dl', 'fieldset', 'figcaption', 'figure', 'footer', 'form', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'header', 'hr', 'main', 'nav', 'ol', 'p', 'pre', 'section', 'table', 'ul'];
var p_parent_excludes = ['a', 'audio', 'del', 'ins', 'map', 'noscript', 'video'];

@@ -753,3 +760,5 @@ Beautifier.prototype._do_optional_end_element = function(parser_token) {

} else if (parser_token.tag_name === 'body') {
}
if (parser_token.tag_name === 'body') {
// A head element’s end tag may be omitted if the head element is not immediately followed by a space character or a comment.

@@ -771,7 +780,12 @@ result = result || this._tag_stack.try_pop('head');

//} else if (p_closers.indexOf(parser_token.tag_name) !== -1) {
//TODO: THIS IS A BUG FARM. We are not putting this into 1.8.0 as it is likely to blow up.
//A p element’s end tag may be omitted if the p element is immediately followed by an address, article, aside, blockquote, details, div, dl, fieldset, figcaption, figure, footer, form, h1, h2, h3, h4, h5, h6, header, hr, main, nav, ol, p, pre, section, table, or ul element, or if there is no more content in the parent element and the parent element is an HTML element that is not an a, audio, del, ins, map, noscript, or video element, or an autonomous custom element.
//result = result || this._tag_stack.try_pop('p', ['body']);
} else if (parser_token.parent.tag_name === 'p' && p_closers.indexOf(parser_token.tag_name) !== -1) {
// IMPORTANT: this else-if works because p_closers has no overlap with any other element we look for in this method
// check for the parent element is an HTML element that is not an <a>, <audio>, <del>, <ins>, <map>, <noscript>, or <video> element, or an autonomous custom element.
// To do this right, this needs to be coded as an inclusion of the inverse of the exclusion above.
// But to start with (if we ignore "autonomous custom elements") the exclusion would be fine.
var p_parent = parser_token.parent.parent;
if (!p_parent || p_parent_excludes.indexOf(p_parent.tag_name) === -1) {
result = result || this._tag_stack.try_pop('p');
}
} else if (parser_token.tag_name === 'rp' || parser_token.tag_name === 'rt') {

@@ -778,0 +792,0 @@ // An rt element’s end tag may be omitted if the rt element is immediately followed by an rt or rp element, or if there is no more content in the parent element.

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

">>> === !== " +
"<< && >= ** != == <= >> || " +
"<< && >= ** != == <= >> || |> " +
"< / - + > : & % ? ^ | *").split(' ');

@@ -87,6 +87,8 @@

"... >>= <<= === >>> !== **= " +
"=> ^= :: /= << <= == && -= >= >> != -- += ** || ++ %= &= *= |= " +
"=> ^= :: /= << <= == && -= >= >> != -- += ** || ++ %= &= *= |= |> " +
"= ! ? > < : / ^ - + * & % ~ |";
punct = punct.replace(/[-[\]{}()*+?.,\\^$|#]/g, "\\$&");
// ?. but not if followed by a number
punct = '\\?\\.(?!\\d) ' + punct;
punct = punct.replace(/ /g, '|');

@@ -233,2 +235,4 @@

return this._create_token(TOKEN.EQUALS, resulting_string);
} else if (resulting_string === '?.') {
return this._create_token(TOKEN.DOT, resulting_string);
} else {

@@ -235,0 +239,0 @@ return this._create_token(TOKEN.OPERATOR, resulting_string);

{
"name": "js-beautify",
"version": "1.10.3",
"version": "1.11.0",
"description": "beautifier.io for node",

@@ -51,17 +51,18 @@ "main": "js/index.js",

"glob": "^7.1.3",
"mkdirp": "~0.5.1",
"nopt": "~4.0.1"
"mkdirp": "~1.0.3",
"nopt": "^4.0.3"
},
"devDependencies": {
"benchmark": "^2.1.4",
"codemirror": "^5.50.2",
"codemirror": "^5.52.0",
"jquery": "^3.4.1",
"jshint": "^2.11.0",
"mocha": "^6.2.2",
"mustache": "^3.2.1",
"minimist": ">=1.2.5",
"mocha": "^7.1.1",
"mustache": "^4.0.1",
"node-static": "^0.7.11",
"requirejs": "^2.3.6",
"webpack": "^4.41.5",
"webpack-cli": "^3.3.10"
"webpack": "^4.42.0",
"webpack-cli": "^3.3.11"
}
}

@@ -64,13 +64,13 @@ # JS Beautifier

```html
<script src="https://cdnjs.cloudflare.com/ajax/libs/js-beautify/1.10.3/beautify.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/js-beautify/1.10.3/beautify-css.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/js-beautify/1.10.3/beautify-html.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/js-beautify/1.11.0/beautify.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/js-beautify/1.11.0/beautify-css.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/js-beautify/1.11.0/beautify-html.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/js-beautify/1.10.3/beautify.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/js-beautify/1.10.3/beautify-css.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/js-beautify/1.10.3/beautify-html.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/js-beautify/1.11.0/beautify.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/js-beautify/1.11.0/beautify-css.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/js-beautify/1.11.0/beautify-html.min.js"></script>
<script src="https://cdn.rawgit.com/beautify-web/js-beautify/v1.10.3/js/lib/beautify.js"></script>
<script src="https://cdn.rawgit.com/beautify-web/js-beautify/v1.10.3/js/lib/beautify-css.js"></script>
<script src="https://cdn.rawgit.com/beautify-web/js-beautify/v1.10.3/js/lib/beautify-html.js"></script>
<script src="https://cdn.rawgit.com/beautify-web/js-beautify/v1.11.0/js/lib/beautify.js"></script>
<script src="https://cdn.rawgit.com/beautify-web/js-beautify/v1.11.0/js/lib/beautify-css.js"></script>
<script src="https://cdn.rawgit.com/beautify-web/js-beautify/v1.11.0/js/lib/beautify-html.js"></script>
```

@@ -89,4 +89,8 @@

```
Unlike the JavaScript version, the Python version can only reformat JavaScript. It does not work against HTML or CSS files.
Unlike the JavaScript version, the Python version can only reformat JavaScript. It does not work against HTML or CSS files, but you can install _css-beautify_ for CSS (_jsbeautifier_ needs to be installed already)
```bash
$ pip install cssbeautifier
```
# Usage

@@ -404,2 +408,2 @@ You can beautify javascript using JS Beautifier in your web browser, or on the command-line using node.js or python.

(README.md: js-beautify@1.10.3)
(README.md: js-beautify@1.11.0)

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