"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "README.md" between
js-beautify-1.14.4.tar.gz and js-beautify-1.14.5.tar.gz

About: JS Beautifier is a JavaScript (and bookmarket) beautifier.

README.md  (js-beautify-1.14.4):README.md  (js-beautify-1.14.5)
skipping to change at line 27 skipping to change at line 27
# Contributors Needed # Contributors Needed
I'm putting this front and center above because existing owners have very limite d time to work on this project currently. I'm putting this front and center above because existing owners have very limite d time to work on this project currently.
This is a popular project and widely used but it desperately needs contributors who have time to commit to fixing both This is a popular project and widely used but it desperately needs contributors who have time to commit to fixing both
customer facing bugs and underlying problems with the internal design and implem entation. customer facing bugs and underlying problems with the internal design and implem entation.
If you are interested, please take a look at the [CONTRIBUTING.md](https://githu b.com/beautify-web/js-beautify/blob/main/CONTRIBUTING.md) then fix an issue mark ed with the ["Good first issue"](https://github.com/beautify-web/js-beautify/iss ues?q=is%3Aissue+is%3Aopen+label%3A%22good+first+issue%22) label and submit a PR . Repeat as often as possible. Thanks! If you are interested, please take a look at the [CONTRIBUTING.md](https://githu b.com/beautify-web/js-beautify/blob/main/CONTRIBUTING.md) then fix an issue mark ed with the ["Good first issue"](https://github.com/beautify-web/js-beautify/iss ues?q=is%3Aissue+is%3Aopen+label%3A%22good+first+issue%22) label and submit a PR . Repeat as often as possible. Thanks!
# Installation # Installation
You can install the beautifier for node.js or python. You can install the beautifier for Node.js or Python.
## Node.js JavaScript ## Node.js JavaScript
You may install the NPM package `js-beautify`. When installed globally, it provi des an executable `js-beautify` script. As with the Python script, the beautifie d result is sent to `stdout` unless otherwise configured. You may install the NPM package `js-beautify`. When installed globally, it provi des an executable `js-beautify` script. As with the Python script, the beautifie d result is sent to `stdout` unless otherwise configured.
```bash ```bash
$ npm -g install js-beautify $ npm -g install js-beautify
$ js-beautify foo.js $ js-beautify foo.js
``` ```
skipping to change at line 59 skipping to change at line 59
$ npm install js-beautify@next $ npm install js-beautify@next
``` ```
## Web Library ## Web Library
The beautifier can be added on your page as web library. The beautifier can be added on your page as web library.
JS Beautifier is hosted on two CDN services: [cdnjs](https://cdnjs.com/libraries /js-beautify) and rawgit. JS Beautifier is hosted on two CDN services: [cdnjs](https://cdnjs.com/libraries /js-beautify) and rawgit.
To pull the latest version from one of these services include one set of the scr ipt tags below in your document: To pull the latest version from one of these services include one set of the scr ipt tags below in your document:
```html ```html
<script src="https://cdnjs.cloudflare.com/ajax/libs/js-beautify/1.14.4/beautify. <script src="https://cdnjs.cloudflare.com/ajax/libs/js-beautify/1.14.5/beautify.
js"></script> js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/js-beautify/1.14.4/beautify- <script src="https://cdnjs.cloudflare.com/ajax/libs/js-beautify/1.14.5/beautify-
css.js"></script> css.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/js-beautify/1.14.4/beautify- <script src="https://cdnjs.cloudflare.com/ajax/libs/js-beautify/1.14.5/beautify-
html.js"></script> html.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/js-beautify/1.14.4/beautify. <script src="https://cdnjs.cloudflare.com/ajax/libs/js-beautify/1.14.5/beautify.
min.js"></script> min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/js-beautify/1.14.4/beautify- <script src="https://cdnjs.cloudflare.com/ajax/libs/js-beautify/1.14.5/beautify-
css.min.js"></script> css.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/js-beautify/1.14.4/beautify- <script src="https://cdnjs.cloudflare.com/ajax/libs/js-beautify/1.14.5/beautify-
html.min.js"></script> html.min.js"></script>
``` ```
Older versions are available by changing the version number. Older versions are available by changing the version number.
Disclaimer: These are free services, so there are [no uptime or support guarante es](https://github.com/rgrove/rawgit/wiki/Frequently-Asked-Questions#i-need-guar anteed-100-uptime-should-i-use-cdnrawgitcom). Disclaimer: These are free services, so there are [no uptime or support guarante es](https://github.com/rgrove/rawgit/wiki/Frequently-Asked-Questions#i-need-guar anteed-100-uptime-should-i-use-cdnrawgitcom).
## Python ## Python
To install the Python version of the beautifier: To install the Python version of the beautifier:
```bash ```bash
$ pip install jsbeautifier $ pip install jsbeautifier
``` ```
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_ f or CSS: 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_ f or CSS:
```bash ```bash
$ pip install cssbeautifier $ pip install cssbeautifier
``` ```
# Usage # Usage
You can beautify javascript using JS Beautifier in your web browser, or on the c ommand-line using node.js or python. You can beautify JavaScript using JS Beautifier in your web browser, or on the c ommand-line using Node.js or Python.
## Web Browser ## Web Browser
Open [beautifier.io](https://beautifier.io/). Options are available via the UI. Open [beautifier.io](https://beautifier.io/). Options are available via the UI.
## Web Library ## Web Library
The script tags above expose three functions: `js_beautify`, `css_beautify`, and `html_beautify`. The script tags above expose three functions: `js_beautify`, `css_beautify`, and `html_beautify`.
## Node.js JavaScript ## Node.js JavaScript
When installed globally, the beautifier provides an executable `js-beautify` scr ipt. The beautified result is sent to `stdout` unless otherwise configured. When installed globally, the beautifier provides an executable `js-beautify` scr ipt. The beautified result is sent to `stdout` unless otherwise configured.
```bash ```bash
$ js-beautify foo.js $ js-beautify foo.js
``` ```
To use `js-beautify` as a `node` library (after install locally), import and cal l the appropriate beautifier method for javascript (js), css, or html. All thre e method signatures are `beautify(code, options)`. `code` is the string of code to be beautified. options is an object with the settings you would like used to beautify the code. To use `js-beautify` as a `node` library (after install locally), import and cal l the appropriate beautifier method for JavaScript (JS), CSS, or HTML. All thre e method signatures are `beautify(code, options)`. `code` is the string of code to be beautified. options is an object with the settings you would like used to beautify the code.
The configuration option names are the same as the CLI names but with underscore s instead of dashes. For example, `--indent-size 2 --space-in-empty-paren` woul d be `{ indent_size: 2, space_in_empty_paren: true }`. The configuration option names are the same as the CLI names but with underscore s instead of dashes. For example, `--indent-size 2 --space-in-empty-paren` woul d be `{ indent_size: 2, space_in_empty_paren: true }`.
```js ```js
var beautify = require('js-beautify').js, var beautify = require('js-beautify').js,
fs = require('fs'); fs = require('fs');
fs.readFile('foo.js', 'utf8', function (err, data) { fs.readFile('foo.js', 'utf8', function (err, data) {
if (err) { if (err) {
throw err; throw err;
skipping to change at line 130 skipping to change at line 130
```bash ```bash
$ js-beautify file.js $ js-beautify file.js
``` ```
Beautified output goes to `stdout` by default. Beautified output goes to `stdout` by default.
To use `jsbeautifier` as a library is simple: To use `jsbeautifier` as a library is simple:
```python ```python
import jsbeautifier import jsbeautifier
res = jsbeautifier.beautify('your javascript string') res = jsbeautifier.beautify('your JavaScript string')
res = jsbeautifier.beautify_file('some_file.js') res = jsbeautifier.beautify_file('some_file.js')
``` ```
...or, to specify some options: ...or, to specify some options:
```python ```python
opts = jsbeautifier.default_options() opts = jsbeautifier.default_options()
opts.indent_size = 2 opts.indent_size = 2
opts.space_in_empty_paren = True opts.space_in_empty_paren = True
res = jsbeautifier.beautify('some javascript', opts) res = jsbeautifier.beautify('some JavaScript', opts)
``` ```
The configuration option names are the same as the CLI names but with underscore s instead of dashes. The example above would be set on the command-line as `--i ndent-size 2 --space-in-empty-paren`. The configuration option names are the same as the CLI names but with underscore s instead of dashes. The example above would be set on the command-line as `--i ndent-size 2 --space-in-empty-paren`.
# Options # Options
These are the command-line flags for both Python and JS scripts: These are the command-line flags for both Python and JS scripts:
```text ```text
CLI Options: CLI Options:
skipping to change at line 187 skipping to change at line 187
-u, --unindent-chained-methods Don't indent chained method calls -u, --unindent-chained-methods Don't indent chained method calls
-B, --break-chained-methods Break chained method calls across subsequent lines -B, --break-chained-methods Break chained method calls across subsequent lines
-k, --keep-array-indentation Preserve array indentation -k, --keep-array-indentation Preserve array indentation
-x, --unescape-strings Decode printable characters encoded in xNN n otation -x, --unescape-strings Decode printable characters encoded in xNN n otation
-w, --wrap-line-length Wrap lines that exceed N characters [0] -w, --wrap-line-length Wrap lines that exceed N characters [0]
-X, --e4x Pass E4X xml literals through untouched -X, --e4x Pass E4X xml literals through untouched
--good-stuff Warm the cockles of Crockford's heart --good-stuff Warm the cockles of Crockford's heart
-C, --comma-first Put commas at the beginning of new line inst ead of end -C, --comma-first Put commas at the beginning of new line inst ead of end
-O, --operator-position Set operator position (before-newline|after- newline|preserve-newline) [before-newline] -O, --operator-position Set operator position (before-newline|after- newline|preserve-newline) [before-newline]
--indent-empty-lines Keep indentation on empty lines --indent-empty-lines Keep indentation on empty lines
--templating List of templating languages (auto,django,er b,handlebars,php,smarty) ["auto"] auto = none in JavaScript, all in html --templating List of templating languages (auto,django,er b,handlebars,php,smarty) ["auto"] auto = none in JavaScript, all in HTML
``` ```
Which correspond to the underscored option keys for both library interfaces Which correspond to the underscored option keys for both library interfaces
**defaults per CLI options** **defaults per CLI options**
```json ```json
{ {
"indent_size": 4, "indent_size": 4,
"indent_char": " ", "indent_char": " ",
"indent_with_tabs": false, "indent_with_tabs": false,
skipping to change at line 249 skipping to change at line 249
* any `jsbeautify_`-prefixed environment variables * any `jsbeautify_`-prefixed environment variables
* a `JSON`-formatted file indicated by the `--config` parameter * a `JSON`-formatted file indicated by the `--config` parameter
* a `.jsbeautifyrc` file containing `JSON` data at any level of the filesystem above `$PWD` * a `.jsbeautifyrc` file containing `JSON` data at any level of the filesystem above `$PWD`
Configuration sources provided earlier in this stack will override later ones. Configuration sources provided earlier in this stack will override later ones.
## Setting inheritance and Language-specific overrides ## Setting inheritance and Language-specific overrides
The settings are a shallow tree whose values are inherited for all languages, bu t The settings are a shallow tree whose values are inherited for all languages, bu t
can be overridden. This works for settings passed directly to the API in either implementation. can be overridden. This works for settings passed directly to the API in either implementation.
In the Javascript implementation, settings loaded from a config file, such as .j sbeautifyrc, can also use inheritance/overriding. In the JavaScript implementation, settings loaded from a config file, such as .j sbeautifyrc, can also use inheritance/overriding.
Below is an example configuration tree showing all the supported locations Below is an example configuration tree showing all the supported locations
for language override nodes. We'll use `indent_size` to discuss how this config uration would behave, but any number of settings can be inherited or overridden: for language override nodes. We'll use `indent_size` to discuss how this config uration would behave, but any number of settings can be inherited or overridden:
```json ```json
{ {
"indent_size": 4, "indent_size": 4,
"html": { "html": {
"end_with_newline": true, "end_with_newline": true,
"js": { "js": {
skipping to change at line 395 skipping to change at line 395
* Created by Einar Lielmanis, <einar@beautifier.io> * Created by Einar Lielmanis, <einar@beautifier.io>
* Python version flourished by Stefano Sanfilippo <a.little.coder@gmail.com> * Python version flourished by Stefano Sanfilippo <a.little.coder@gmail.com>
* Command-line for node.js by Daniel Stockman <daniel.stockman@gmail.com> * Command-line for node.js by Daniel Stockman <daniel.stockman@gmail.com>
* Maintained and expanded by Liam Newman <bitwiseman@beautifier.io> * Maintained and expanded by Liam Newman <bitwiseman@beautifier.io>
Thanks also to Jason Diamond, Patrick Hof, Nochum Sossonko, Andreas Schneider, D ave Thanks also to Jason Diamond, Patrick Hof, Nochum Sossonko, Andreas Schneider, D ave
Vasilevsky, Vital Batmanov, Ron Baldwin, Gabriel Harrison, Chris J. Shull, Vasilevsky, Vital Batmanov, Ron Baldwin, Gabriel Harrison, Chris J. Shull,
Mathias Bynens, Vittorio Gambaletta and others. Mathias Bynens, Vittorio Gambaletta and others.
(README.md: js-beautify@1.14.4) (README.md: js-beautify@1.14.5)
 End of changes. 9 change blocks. 
20 lines changed or deleted 20 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)