js-beautify 1.9.0 → 1.10.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +46 -0
- package/README.md +45 -24
- package/js/lib/beautifier.js +198 -72
- package/js/lib/beautifier.min.js +1 -1
- package/js/lib/beautify-css.js +52 -23
- package/js/lib/beautify-html.js +129 -34
- package/js/lib/beautify.js +50 -17
- package/js/lib/cli.js +6 -0
- package/js/src/cli.js +6 -0
- package/js/src/core/options.js +6 -0
- package/js/src/core/output.js +6 -1
- package/js/src/core/templatablepattern.js +9 -0
- package/js/src/css/beautifier.js +40 -22
- package/js/src/html/beautifier.js +63 -19
- package/js/src/html/options.js +4 -0
- package/js/src/html/tokenizer.js +41 -14
- package/js/src/javascript/beautifier.js +26 -11
- package/js/src/javascript/tokenizer.js +3 -5
- package/package.json +7 -7
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,50 @@
|
|
|
1
1
|
# Changelog
|
|
2
|
+
## v1.10.1
|
|
3
|
+
|
|
4
|
+
### Description
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
### Closed Issues
|
|
8
|
+
* javascript fails to format when <?php > is first text inside <script> tag ([#1687](https://github.com/beautify-web/js-beautify/issues/1687))
|
|
9
|
+
* 414 Request-URI Too Large ([#1640](https://github.com/beautify-web/js-beautify/issues/1640))
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
## v1.10.0
|
|
13
|
+
|
|
14
|
+
### Description
|
|
15
|
+
# Description
|
|
16
|
+
* Added `templating` setting to control when template languages are recognized. All languages are off by default in Javascript and on by default in HTML.
|
|
17
|
+
* Thanks to @HanabishiRecca, @averydev, @kalbasit, @asteinha for contributions
|
|
18
|
+
|
|
19
|
+
https://github.com/beautify-web/js-beautify/compare/v1.9.1...v1.10.0
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
### Closed Issues
|
|
24
|
+
* beautifying scss selector with colon in it adds space ([#1667](https://github.com/beautify-web/js-beautify/issues/1667))
|
|
25
|
+
* Javascript multiline comments duplicates ([#1663](https://github.com/beautify-web/js-beautify/issues/1663))
|
|
26
|
+
* Tokenizer crashes if the input terminates with a dot character. ([#1658](https://github.com/beautify-web/js-beautify/issues/1658))
|
|
27
|
+
* stop reformatting valid css \\! into invalid \\ ! ([#1656](https://github.com/beautify-web/js-beautify/pull/1656))
|
|
28
|
+
* wrong indent for unclosed <? - need to support disabling templating ([#1647](https://github.com/beautify-web/js-beautify/issues/1647))
|
|
29
|
+
* Beautify inserts space before exclamation mark in comment <!-- in css <style> ([#1641](https://github.com/beautify-web/js-beautify/issues/1641))
|
|
30
|
+
* 'less' mixins parameter formatting problem ([#1582](https://github.com/beautify-web/js-beautify/issues/1582))
|
|
31
|
+
* Change css tests to use 4 space indenting instead of tabs ([#1527](https://github.com/beautify-web/js-beautify/issues/1527))
|
|
32
|
+
* Braces after case get pushed onto new line ([#1357](https://github.com/beautify-web/js-beautify/issues/1357))
|
|
33
|
+
* Extra space in pseudo-elements and pseudo-classes selectors ([#1233](https://github.com/beautify-web/js-beautify/issues/1233))
|
|
34
|
+
* LESS formatting - mixins with multiple variables ([#1018](https://github.com/beautify-web/js-beautify/issues/1018))
|
|
35
|
+
* Bug in less format ([#842](https://github.com/beautify-web/js-beautify/issues/842))
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
## v1.9.1
|
|
39
|
+
|
|
40
|
+
### Description
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
### Closed Issues
|
|
44
|
+
* nested table not beautified correctly ([#1649](https://github.com/beautify-web/js-beautify/issues/1649))
|
|
45
|
+
* Add an option to preserve indentation on empty lines ([#1322](https://github.com/beautify-web/js-beautify/issues/1322))
|
|
46
|
+
|
|
47
|
+
|
|
2
48
|
## v1.9.0
|
|
3
49
|
|
|
4
50
|
### Description
|
package/README.md
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
[](https://gitter.im/beautify-web/js-beautify?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
|
10
10
|
[](https://twitter.com/intent/user?screen_name=js_beautifier)
|
|
11
11
|
|
|
12
|
-
[](https://www.npmjs.org/package/js-beautify)
|
|
12
|
+
[](https://www.npmjs.org/package/js-beautify) [](https://greenkeeper.io/)
|
|
13
13
|
|
|
14
14
|
|
|
15
15
|
This little beautifier will reformat and re-indent bookmarklets, ugly
|
|
@@ -61,17 +61,17 @@ JS Beautifier is hosted on two CDN services: [cdnjs](https://cdnjs.com/libraries
|
|
|
61
61
|
|
|
62
62
|
To pull the latest version from one of these services include one set of the script tags below in your document:
|
|
63
63
|
```html
|
|
64
|
-
<script src="https://cdnjs.cloudflare.com/ajax/libs/js-beautify/1.
|
|
65
|
-
<script src="https://cdnjs.cloudflare.com/ajax/libs/js-beautify/1.
|
|
66
|
-
<script src="https://cdnjs.cloudflare.com/ajax/libs/js-beautify/1.
|
|
64
|
+
<script src="https://cdnjs.cloudflare.com/ajax/libs/js-beautify/1.10.1/beautify.js"></script>
|
|
65
|
+
<script src="https://cdnjs.cloudflare.com/ajax/libs/js-beautify/1.10.1/beautify-css.js"></script>
|
|
66
|
+
<script src="https://cdnjs.cloudflare.com/ajax/libs/js-beautify/1.10.1/beautify-html.js"></script>
|
|
67
67
|
|
|
68
|
-
<script src="https://cdnjs.cloudflare.com/ajax/libs/js-beautify/1.
|
|
69
|
-
<script src="https://cdnjs.cloudflare.com/ajax/libs/js-beautify/1.
|
|
70
|
-
<script src="https://cdnjs.cloudflare.com/ajax/libs/js-beautify/1.
|
|
68
|
+
<script src="https://cdnjs.cloudflare.com/ajax/libs/js-beautify/1.10.1/beautify.min.js"></script>
|
|
69
|
+
<script src="https://cdnjs.cloudflare.com/ajax/libs/js-beautify/1.10.1/beautify-css.min.js"></script>
|
|
70
|
+
<script src="https://cdnjs.cloudflare.com/ajax/libs/js-beautify/1.10.1/beautify-html.min.js"></script>
|
|
71
71
|
|
|
72
|
-
<script src="https://cdn.rawgit.com/beautify-web/js-beautify/v1.
|
|
73
|
-
<script src="https://cdn.rawgit.com/beautify-web/js-beautify/v1.
|
|
74
|
-
<script src="https://cdn.rawgit.com/beautify-web/js-beautify/v1.
|
|
72
|
+
<script src="https://cdn.rawgit.com/beautify-web/js-beautify/v1.10.1/js/lib/beautify.js"></script>
|
|
73
|
+
<script src="https://cdn.rawgit.com/beautify-web/js-beautify/v1.10.1/js/lib/beautify-css.js"></script>
|
|
74
|
+
<script src="https://cdn.rawgit.com/beautify-web/js-beautify/v1.10.1/js/lib/beautify-html.js"></script>
|
|
75
75
|
```
|
|
76
76
|
|
|
77
77
|
Older versions are available by changing the version number.
|
|
@@ -93,7 +93,7 @@ You can beautify javascript using JS Beautifier in your web browser, or on the c
|
|
|
93
93
|
## Web Browser
|
|
94
94
|
Open [beautifier.io](https://beautifier.io/). Options are available via the UI.
|
|
95
95
|
|
|
96
|
-
## Web
|
|
96
|
+
## Web Library
|
|
97
97
|
The script tags above expose three functions: `js_beautify`, `css_beautify`, and `html_beautify`.
|
|
98
98
|
|
|
99
99
|
## Node.js JavaScript
|
|
@@ -190,6 +190,8 @@ Beautifier Options:
|
|
|
190
190
|
--good-stuff Warm the cockles of Crockford's heart
|
|
191
191
|
-C, --comma-first Put commas at the beginning of new line instead of end
|
|
192
192
|
-O, --operator-position Set operator position (before-newline|after-newline|preserve-newline) [before-newline]
|
|
193
|
+
--indent-empty-lines Keep indentation on empty lines
|
|
194
|
+
--templating List of templating languages (auto,django,erb,handlebars,php) ["auto"] auto = none in JavaScript, all in html
|
|
193
195
|
```
|
|
194
196
|
|
|
195
197
|
Which correspond to the underscored option keys for both library interfaces
|
|
@@ -219,7 +221,9 @@ Which correspond to the underscored option keys for both library interfaces
|
|
|
219
221
|
"wrap_line_length": 0,
|
|
220
222
|
"e4x": false,
|
|
221
223
|
"comma_first": false,
|
|
222
|
-
"operator_position": "before-newline"
|
|
224
|
+
"operator_position": "before-newline",
|
|
225
|
+
"indent_empty_lines": false,
|
|
226
|
+
"templating": ["auto"]
|
|
223
227
|
}
|
|
224
228
|
```
|
|
225
229
|
|
|
@@ -316,6 +320,7 @@ CSS Beautifier Options:
|
|
|
316
320
|
-n, --end-with-newline End output with newline
|
|
317
321
|
-L, --selector-separator-newline Add a newline between multiple selectors
|
|
318
322
|
-N, --newline-between-rules Add a newline between CSS rules
|
|
323
|
+
--indent-empty-lines Keep indentation on empty lines
|
|
319
324
|
|
|
320
325
|
HTML Beautifier Options:
|
|
321
326
|
-s, --indent-size Indentation size [4]
|
|
@@ -338,16 +343,38 @@ HTML Beautifier Options:
|
|
|
338
343
|
--editorconfig Use EditorConfig to set up the options
|
|
339
344
|
--indent_scripts Sets indent level inside script tags ("normal", "keep", "separate")
|
|
340
345
|
--unformatted_content_delimiter Keep text content together between this string [""]
|
|
346
|
+
--indent-empty-lines Keep indentation on empty lines
|
|
347
|
+
--templating List of templating languages (auto,none,django,erb,handlebars,php) ["auto"] auto = none in JavaScript, all in html
|
|
341
348
|
```
|
|
342
349
|
|
|
343
|
-
## Directives
|
|
350
|
+
## Directives
|
|
351
|
+
|
|
352
|
+
Directives let you control the behavior of the Beautifier from within your source files. Directives are placed in comments inside the file. Directives are in the format `/* beautify {name}:{value} */` in CSS and JavaScript. In HTML they are formatted as `<!-- beautify {name}:{value} -->`.
|
|
353
|
+
|
|
354
|
+
### Ignore directive
|
|
344
355
|
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
The example input below will remain changed after beautification
|
|
356
|
+
The `ignore` directive makes the beautifier completely ignore part of a file, treating it as literal text that is not parsed.
|
|
357
|
+
The input below will remain unchanged after beautification:
|
|
348
358
|
|
|
349
359
|
```js
|
|
350
|
-
// Use
|
|
360
|
+
// Use ignore when the content is not parsable in the current language, JavaScript in this case.
|
|
361
|
+
var a = 1;
|
|
362
|
+
/* beautify ignore:start */
|
|
363
|
+
{This is some strange{template language{using open-braces?
|
|
364
|
+
/* beautify ignore:end */
|
|
365
|
+
```
|
|
366
|
+
|
|
367
|
+
### Preserve directive
|
|
368
|
+
|
|
369
|
+
NOTE: this directive only works in HTML and JavaScript, not CSS.
|
|
370
|
+
|
|
371
|
+
The `preserve` directive makes the Beautifier parse and then keep the existing formatting of a section of code.
|
|
372
|
+
|
|
373
|
+
The input below will remain unchanged after beautification:
|
|
374
|
+
|
|
375
|
+
```js
|
|
376
|
+
// Use preserve when the content is valid syntax in the current language, JavaScript in this case.
|
|
377
|
+
// This will parse the code and preserve the existing formatting.
|
|
351
378
|
/* beautify preserve:start */
|
|
352
379
|
{
|
|
353
380
|
browserName: 'internet explorer',
|
|
@@ -355,12 +382,6 @@ The example input below will remain changed after beautification
|
|
|
355
382
|
version: '8'
|
|
356
383
|
}
|
|
357
384
|
/* beautify preserve:end */
|
|
358
|
-
|
|
359
|
-
// Use ignore when the content is not parsable as javascript.
|
|
360
|
-
var a = 1;
|
|
361
|
-
/* beautify ignore:start */
|
|
362
|
-
{This is some strange{template language{using open-braces?
|
|
363
|
-
/* beautify ignore:end */
|
|
364
385
|
```
|
|
365
386
|
|
|
366
387
|
# License
|
|
@@ -378,4 +399,4 @@ Thanks also to Jason Diamond, Patrick Hof, Nochum Sossonko, Andreas Schneider, D
|
|
|
378
399
|
Vasilevsky, Vital Batmanov, Ron Baldwin, Gabriel Harrison, Chris J. Shull,
|
|
379
400
|
Mathias Bynens, Vittorio Gambaletta and others.
|
|
380
401
|
|
|
381
|
-
(README.md: js-beautify@1.
|
|
402
|
+
(README.md: js-beautify@1.10.1)
|