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

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.9.0-beta1 to 1.9.0-beta2

js/src/html/templatablereader.js

17

js/lib/beautify-css.js

@@ -454,8 +454,20 @@ /* AUTO-GENERATED. DO NOT MODIFY. */

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') {

@@ -858,2 +870,3 @@ sweet_code = sweet_code.replace(/[\n]/g, eol);

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

@@ -860,0 +873,0 @@ };

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

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

@@ -88,0 +89,0 @@ };

@@ -293,8 +293,20 @@ /*jshint node:true */

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') {

@@ -301,0 +313,0 @@ sweet_code = sweet_code.replace(/[\n]/g, eol);

@@ -135,2 +135,5 @@ /*jshint node:true */

Tokenizer.prototype._readWhitespace = function() {
if (!this._input.testChar(this._whitespace_pattern)) {
return;
}
var resulting_string = this._input.read(this._whitespace_pattern);

@@ -137,0 +140,0 @@ if (resulting_string === ' ') {

16

js/src/html/options.js

@@ -46,4 +46,7 @@ /*jshint node:true */

// Block vs inline elements
// https://developer.mozilla.org/en-US/docs/Web/HTML/Block-level_elements
// https://developer.mozilla.org/en-US/docs/Web/HTML/Inline_elements
// https://www.w3.org/TR/html5/dom.html#phrasing-content
this.inline = this._get_array('inline', [
// https://www.w3.org/TR/html5/dom.html#phrasing-content
'a', 'abbr', 'area', 'audio', 'b', 'bdi', 'bdo', 'br', 'button', 'canvas', 'cite',

@@ -55,4 +58,4 @@ 'code', 'data', 'datalist', 'del', 'dfn', 'em', 'embed', 'i', 'iframe', 'img',

'video', 'wbr', 'text',
// prexisting - not sure of full effect of removing, leaving in
'acronym', 'address', 'big', 'dt', 'ins', 'strike', 'tt'
// obsolete inline tags
'acronym', 'big', 'strike', 'tt'
]);

@@ -69,5 +72,6 @@ this.void_elements = this._get_array('void_elements', [

'!doctype', '?xml',
// ?php and ?= tags
'?php', '?=',
// other tags that were in this list, keeping just in case
// obsolete tags
// basefont: https://www.computerhope.com/jargon/h/html-basefont-tag.htm
// isndex: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/isindex
'basefont', 'isindex'

@@ -74,0 +78,0 @@ ]);

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

var Directives = require('../core/directives').Directives;
var TemplatableReader = require('./templatablereader').TemplatableReader;

@@ -58,3 +59,8 @@ var TOKEN = {

// if we are indenting handlebars, they are considered tags
this._word_pattern = this._options.indent_handlebars ? /[\n\r\t <]|{{/g : /[\n\r\t <]/g;
this._word = new TemplatableReader(this._input).until(/[\n\r\t <]/g).with_templates();
this._word.handlebars = false; // Detect only
this._single_quote = new TemplatableReader(this._input).until_after(/'/g).with_templates();
this._double_quote = new TemplatableReader(this._input).until_after(/"/g).with_templates();
this._attribute = new TemplatableReader(this._input).until(/[\n\r\t =\/>]/g).with_templates();
this._element_name = new TemplatableReader(this._input).until(/[\n\r\t >\/]/g).with_templates();
this._unformatted_content_delimiter = null;

@@ -98,8 +104,9 @@

token = token || this._read_open_handlebars(c, open_token);
token = token || this._read_attribute(c, previous_token, open_token);
token = token || this._read_raw_content(previous_token, open_token);
token = token || this._read_close(c, open_token);
token = token || this._read_content_word(c);
token = token || this._read_comment(c);
token = token || this._read_open(c, open_token);
token = token || this._read_close(c, open_token);
token = token || this._read_content_word();
token = token || this._create_token(TOKEN.UNKNOWN, this._input.next());

@@ -115,9 +122,8 @@

if (c === '<' || c === '{') {
if (c === '<') {
var peek1 = this._input.peek(1);
var peek2 = this._input.peek(2);
//if we're in a comment, do something special
// We treat all comments as literals, even more than preformatted tags
// we just look for the appropriate close tag
if (c === '<' && (peek1 === '!' || peek1 === '?' || peek1 === '%')) {
if (c === '<' && (peek1 === '!' || peek1 === '?')) {
resulting_string = this._input.read(/<!--/g, /-->/g);

@@ -135,10 +141,3 @@

resulting_string = resulting_string || this._input.read(/<\?/g, /\?>/g);
resulting_string = resulting_string || this._input.read(/<%/g, /%>/g);
// if none of the other patterns match, read the element as a comment anyway
resulting_string = resulting_string || this._input.read(/</g, />/g);
}
} else if (this._options.indent_handlebars && c === '{' && peek1 === '{' && peek2 === '!') {
resulting_string = this._input.read(/{{!--/g, /--}/g);
resulting_string = resulting_string || this._input.read(/{{!/g, /}}/g);
}

@@ -160,7 +159,9 @@

if (c === '<') {
resulting_string = this._input.read(/<(?:[^\n\r\t >{][^\n\r\t >{/]*)?/g);
resulting_string = this._input.next();
if (this._input.peek() === '/') {
resulting_string += this._input.next();
}
resulting_string += this._element_name.read();
token = this._create_token(TOKEN.TAG_OPEN, resulting_string);
} else if (this._options.indent_handlebars && c === '{' && this._input.peek(1) === '{') {
resulting_string = this._input.readUntil(/[\n\r\t }]/g);
token = this._create_token(TOKEN.TAG_OPEN, resulting_string);
}

@@ -171,2 +172,21 @@ }

Tokenizer.prototype._read_open_handlebars = function(c, open_token) {
var resulting_string = null;
var token = null;
if (!open_token) {
if (this._options.indent_handlebars && c === '{' && this._input.peek(1) === '{') {
if (this._input.peek(2) === '!') {
resulting_string = this._input.read(/{{!--/g, /--}}/g);
resulting_string = resulting_string || this._input.read(/{{/g, /}}/g);
token = this._create_token(TOKEN.COMMENT, resulting_string);
} else {
resulting_string = this._input.readUntil(/[\n\r\t }]/g);
token = this._create_token(TOKEN.TAG_OPEN, resulting_string);
}
}
}
return token;
};
Tokenizer.prototype._read_close = function(c, open_token) {

@@ -201,21 +221,10 @@ var resulting_string = null;

var content = this._input.next();
var input_string = '';
var string_pattern = new RegExp(c + '|{{', 'g');
while (this._input.hasNext()) {
input_string = this._input.readUntilAfter(string_pattern);
content += input_string;
if (input_string[input_string.length - 1] === '"' || input_string[input_string.length - 1] === "'") {
break;
} else if (this._input.hasNext()) {
content += this._input.readUntilAfter(/}}/g);
}
if (c === '"') {
content += this._double_quote.read();
} else {
content += this._single_quote.read();
}
token = this._create_token(TOKEN.VALUE, content);
} else {
if (c === '{' && this._input.peek(1) === '{') {
resulting_string = this._input.readUntilAfter(/}}/g);
} else {
resulting_string = this._input.readUntil(/[\n\r\t =\/>]/g);
}
resulting_string = this._attribute.read();

@@ -263,12 +272,17 @@ if (resulting_string) {

Tokenizer.prototype._read_content_word = function() {
var resulting_string;
Tokenizer.prototype._read_content_word = function(c) {
var resulting_string = '';
if (this._unformatted_content_delimiter) {
resulting_string = this._input.read(this._unformatted_content_delimiter);
if (c === this._options.unformatted_content_delimiter[0]) {
resulting_string = this._input.read(this._unformatted_content_delimiter);
}
}
if (resulting_string) {
resulting_string += this._input.readUntilAfter(this._unformatted_content_delimiter);
} else {
// if we get here and we see handlebars treat them as plain text
resulting_string = this._input.readUntil(this._word_pattern);
if (c === '{' && !this._options.indent_handlebars) {
resulting_string += this._input.next();
}
resulting_string += this._word.read();
}

@@ -275,0 +289,0 @@ if (resulting_string) {

{
"name": "js-beautify",
"version": "1.9.0-beta1",
"version": "1.9.0-beta2",
"description": "beautifier.io for node",

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

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

```html
<script src="https://cdnjs.cloudflare.com/ajax/libs/js-beautify/1.9.0-beta1/beautify.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/js-beautify/1.9.0-beta1/beautify-css.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/js-beautify/1.9.0-beta1/beautify-html.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/js-beautify/1.9.0-beta2/beautify.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/js-beautify/1.9.0-beta2/beautify-css.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/js-beautify/1.9.0-beta2/beautify-html.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/js-beautify/1.9.0-beta1/beautify.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/js-beautify/1.9.0-beta1/beautify-css.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/js-beautify/1.9.0-beta1/beautify-html.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/js-beautify/1.9.0-beta2/beautify.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/js-beautify/1.9.0-beta2/beautify-css.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/js-beautify/1.9.0-beta2/beautify-html.min.js"></script>
<script src="https://cdn.rawgit.com/beautify-web/js-beautify/v1.9.0-beta1/js/lib/beautify.js"></script>
<script src="https://cdn.rawgit.com/beautify-web/js-beautify/v1.9.0-beta1/js/lib/beautify-css.js"></script>
<script src="https://cdn.rawgit.com/beautify-web/js-beautify/v1.9.0-beta1/js/lib/beautify-html.js"></script>
<script src="https://cdn.rawgit.com/beautify-web/js-beautify/v1.9.0-beta2/js/lib/beautify.js"></script>
<script src="https://cdn.rawgit.com/beautify-web/js-beautify/v1.9.0-beta2/js/lib/beautify-css.js"></script>
<script src="https://cdn.rawgit.com/beautify-web/js-beautify/v1.9.0-beta2/js/lib/beautify-html.js"></script>
```

@@ -382,2 +382,2 @@

(README.md: js-beautify@1.9.0-beta1)
(README.md: js-beautify@1.9.0-beta2)

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