# JS Beautifier
[![Build Status](https://img.shields.io/travis/beautify-web/js-beautify/master.svg)](http://travis-ci.org/beautify-web/js-beautify)
[![NPM version](https://img.shields.io/npm/v/js-beautify.svg)](https://www.npmjs.com/package/js-beautify)
[![Download stats](https://img.shields.io/npm/dm/js-beautify.svg)](https://www.npmjs.com/package/js-beautify)
[![Join the chat at https://gitter.im/beautify-web/js-beautify](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/beautify-web/js-beautify?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
[![NPM stats](https://nodei.co/npm/js-beautify.svg?downloadRank=true&downloads=true)](https://www.npmjs.org/package/js-beautify)
This little beautifier will reformat and reindent bookmarklets, ugly
JavaScript, unpack scripts packed by Dean Edward’s popular packer,
as well as deobfuscate scripts processed by
[javascriptobfuscator.com](http://javascriptobfuscator.com/).
# Usage
You can beautify javascript using JS Beautifier in your web browser, or on the command-line using node.js or python.
## Web Browser
Open [jsbeautifier.org](http://jsbeautifier.org/). Options are available via the UI.
## Python
To beautify using python:
```bash
$ pip install jsbeautifier
$ js-beautify file.js
```
Beautified output goes to `stdout`.
To use `jsbeautifier` as a library is simple:
``` python
import jsbeautifier
res = jsbeautifier.beautify('your javascript string')
res = jsbeautifier.beautify_file('some_file.js')
```
...or, to specify some options:
``` python
opts = jsbeautifier.default_options()
opts.indent_size = 2
res = jsbeautifier.beautify('some javascript', opts)
```
## JavaScript
As an alternative to the Python script, you may install the NPM package `js-beautify`. When installed globally, it provides an executable `js-beautify` script. As with the Python script, the beautified result is sent to `stdout` unless otherwise configured.
```bash
$ npm -g install js-beautify
$ js-beautify foo.js
```
You can also use `js-beautify` as a `node` library (install locally, the `npm` default):
```bash
$ npm install js-beautify
```
```js
var beautify = require('js-beautify').js_beautify,
fs = require('fs');
fs.readFile('foo.js', 'utf8', function (err, data) {
if (err) {
throw err;
}
console.log(beautify(data, { indent_size: 2 }));
});
```
## Options
These are the command-line flags for both Python and JS scripts:
```text
CLI Options:
-f, --file Input file(s) (Pass '-' for stdin)
-r, --replace Write output in-place, replacing input
-o, --outfile Write output to file (default stdout)
--config Path to config file
--type [js|css|html] ["js"]
-q, --quiet Suppress logging to stdout
-h, --help Show this help
-v, --version Show the version
Beautifier Options:
-s, --indent-size Indentation size [4]
-c, --indent-char Indentation character [" "]
-e, --eol character(s) to use as line terminators. (default newline - "\\n")');
-l, --indent-level Initial indentation level [0]
-t, --indent-with-tabs Indent with tabs, overrides -s and -c
-p, --preserve-newlines Preserve line-breaks (--no-preserve-newlines disables)
-m, --max-preserve-newlines Number of line-breaks to be preserved in one chunk [10]
-P, --space-in-paren Add padding spaces within paren, ie. f( a, b )
-j, --jslint-happy Enable jslint-stricter mode
-a, --space-after-anon-function Add a space before an anonymous function's parens, ie. function ()
-b, --brace-style [collapse|expand|end-expand|none] ["collapse"]
-B, --break-chained-methods Break chained method calls across subsequent lines
-k, --keep-array-indentation Preserve array indentation
-x, --unescape-strings Decode printable characters encoded in xNN notation
-w, --wrap-line-length Wrap lines at next opportunity after N characters [0]
-X, --e4x Pass E4X xml literals through untouched
-n, --end-with-newline End output with newline
-C, --comma-first Put commas at the beginning of new line instead of end
--good-stuff Warm the cockles of Crockford's heart
```
These largely correspond to the underscored option keys for both library interfaces, which have these defaults:
```json
{
"indent_size": 4,
"indent_char": " ",
"eol": "\n",
"indent_level": 0,
"indent_with_tabs": false,
"preserve_newlines": true,
"max_preserve_newlines": 10,
"jslint_happy": false,
"space_after_anon_function": false,
"brace_style": "collapse",
"keep_array_indentation": false,
"keep_function_indentation": false,
"space_before_conditional": true,
"break_chained_methods": false,
"eval_code": false,
"unescape_strings": false,
"wrap_line_length": 0,
"wrap_attributes": "auto",
"wrap_attributes_indent_size": 4,
"end_with_newline": false
}
```
In addition to CLI arguments, you may pass config to the JS executable via:
* any `jsbeautify_`-prefixed environment variables
* a `JSON`-formatted file indicated by the `--config` parameter
* 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.
You might notice that the CLI options and defaults hash aren't 100% correlated. Historically, the Python and JS APIs have not been 100% identical. For example, `space_before_conditional` is currently JS-only, and not addressable from the CLI script. There are a few other additional cases keeping us from 100% API-compatibility. Patches welcome!
## Directives to Ignore or Preserve sections (Javascript only)
Beautifier for supports directives in comments inside the file.
This allows you to tell the beautifier to preserve the formtatting of or completely ignore part of a file.
The example input below will remain changed after beautification
```js
// Use preserve when the content is not javascript, but you don't want it reformatted.
/* beautify preserve:start */
{
browserName: 'internet explorer',
platform: 'Windows 7',
version: '8'
}
/* beautify preserve:end */
// Use ignore when the content is not parsable as javascript.
var a = 1;
/* beautify ignore:start */
{This is some strange{template language{using open-braces?
/* beautify ignore:end */
```
### CSS & HTML
In addition to the `js-beautify` executable, `css-beautify` and `html-beautify` are also provided as an easy interface into those scripts. Alternatively, `js-beautify --css` or `js-beautify --html` will accomplish the same thing, respectively.
```js
// Programmatic access
var beautify_js = require('js-beautify'); // also available under "js" export
var beautify_css = require('js-beautify').css;
var beautify_html = require('js-beautify').html;
// All methods accept two arguments, the string to be beautified, and an options object.
```
The CSS & HTML beautifiers are much simpler in scope, and possess far fewer options.
```text
CSS Beautifier Options:
-s, --indent-size Indentation size [4]
-c, --indent-char Indentation character [" "]
-t, --indent-with-tabs Indent with tabs, overrides -s and -c
-e, --eol Character(s) to use as line terminators. (default newline - "\\n")
-n, --end-with-newline End output with newline
-L, --selector-separator-newline Add a newline between multiple selectors
-N, --newline-between-rules Add a newline between CSS rules
HTML Beautifier Options:
-s, --
没有合适的资源?快使用搜索试试~ 我知道了~
Brackets常用插件打包下载
共499个文件
js:202个
css:26个
png:25个
4星 · 超过85%的资源 需积分: 45 52 下载量 57 浏览量
2017-07-11
11:19:45
上传
评论
收藏 4.14MB RAR 举报
温馨提示
解压文件放到 Brackets\www\extensions\default 目录下即可使用
资源推荐
资源详情
资源评论
收起资源包目录
Brackets常用插件打包下载 (499个子文件)
v1.0.0 41B
05e9e4c749bf2856cb303ac282d33bb60483eb 271B
0c9d92c4ee8f27671b439b1484d6347b770cb1 281B
0db4b8cb334d838c113e79bbf1608b0fea1063 256B
v1.0.1 41B
12b0fb3e57868fb7cc05b07004e280bbf2d046 178B
138e95142a81399b85981a97315008574c3ca3 203B
197bf3233bcd08bff3b9881865571e029893cf 218B
v1.0.2 41B
21fe418ae5121dbd77ec4c107fc22a2741e6d0 218B
283869fe11e6e819e31d1da92cc218f22eb108 229B
2956f97c9940335fc10a80020d4bf53a632d88 138B
2e69f44ab87f465b0be715470ac62bab66d5ce 282B
2f4c11df453c3e002b0215b2288da77fdf4039 109B
v1.0.3 41B
31f6d87a92c0cdd904bf654f564c6f3be526b1 135B
31fb7aa05a2601bb8b176cca286cde60248e43 267B
3362960f1fbe8a458e3658fda46d5e3b326633 296B
3877e2adb7925d2570480563d94dfffd4c3ed2 219B
3e813d440b4ad3adb5215d07aa60275df0a930 2KB
3e818e2be9d2d9cf35f443fde4af3b2bb96f65 531B
v1.0.4 41B
417d81682fa5a3f8fef4dd117764d9942c096c 194B
4d7bd984cf6cf855ba89bb6a3ee81e6808c4ee 432B
4e06c91fbfeef0903d934f56650194716d2ae3 125B
4e57faf8b087e46b9edef1f3a39a890b89881f 2KB
v1.0.5 41B
5008a1b1f56e83502af9cf7ed4f25f7988f861 218B
515ce8ae5785e5c48ee1d5fc3e2336b75c370d 295B
569efb5de266e2ee5d8c2b61dea82c8048cd32 218B
577485a6d2c23359d8e3e914544e26936ff5af 233B
5aa32cc96a8e3d1aa31cbdc10cb2c3709ca588 119B
662cac7848508a14c455bf049fed2acfa4b6c3 215B
69d73c01d50917959b6f6af782d8c4fd7d2968 93B
6a40b991a491d7bb6bdee4c24ded1a8e7e3275 87B
6b69208ebaec08b18414ab4ce02568791b17f8 269B
7206367f982ce39210cc5da5bb3d71259b30ad 162B
744fc89b1b80dab4bca7f1b02d333dc9b2fb01 217B
75340e123fa27f03a4c06525b2d7b43f7cb39f 269B
825dc642cb6eb9a060e54bf8d69288fbee4904 15B
838407c0229fa892ce3cf1bdaeff038194238b 265B
89ce33f1413600fb067d2df3bb2ec7ab27c9f8 363B
8a53a97cbf2ac75450cf09f81171bcd507e3c1 281B
8aa65a47d43e17241643ea25c73dd75c53afe6 182B
8cab641c2aa867b17e1d3d3f54eaa1f88cf28f 186B
902dd2a662c2960a40ed99847e183833a2631a 263B
91b36b698968a8bdf12e787f0e4babeaf6ceee 1KB
937e324c1f5e4adebcebe88c5fe535a8fc14f3 218B
93f18c67ea77d978a53e42398a994ff34f2b19 258B
9592c17daaf427bc98d8da328e0e0dbbb2af76 186B
974d860d159246b71a548d3205be3fdcda0249 1KB
a087704ff02078ad3f93fc8d36d69a94200177 1KB
aa8d95742f4ee028afba8b8e2cc2a4a235b3b7 218B
b09c2e47f07d3a4117e358b28b6bf87d25ad70 224B
b6859e42f855cee7f62cf494aa3155eda5812e 186B
b74d44a8a65ded56b87d79b1f000d746714e7a 174B
b80c95314b349426f3be6005f2393e4484b46c 217B
bd3a913cc85dfb1c3472fea484467ebeffa511 316B
be18ae1e5b8fb91e06ab7c4a9749531a422fa7 186B
c3b6f7f2a0598692a783dd29728c80c39223ea 276B
c545f786f540b6e865db8a2b1c365ad4c133d2 214B
CHANGELOG 1KB
COMMIT_EDITMSG 13B
config 681B
ayyo.css 550KB
ionicons.min.css 50KB
stone-age.css 44KB
solarized-dark.css 31KB
ambiance.css 29KB
font-awesome.min.css 23KB
font-awesome.min.css 23KB
devicons.min.css 8KB
dark-soda.css 7KB
dracula.css 7KB
codemirror.css 6KB
obsidian.css 6KB
carbon-blue.css 6KB
idle-fingers.css 6KB
zenburn.css 5KB
wombat.css 5KB
sunburst.css 5KB
rubyblue.css 5KB
brunante.css 4KB
night-sky.css 4KB
peacock.css 4KB
mbo.css 4KB
light-table.css 4KB
style.css 842B
stuff.css 718B
style.css 462B
.csslintrc 218B
d087e7aeb9e8c2e04fc5f2a9fe444879c1d236 179B
d136acd180215cf31244dbe7d927f2d0ddb37a 213B
dda158b79670e4c361950ced40bdfc8fac76ca 234B
description 73B
develop 528B
develop 302B
develop 41B
develop 41B
df6bbe7fc7dfd4d805eae32dc24d6f3a24957c 218B
共 499 条
- 1
- 2
- 3
- 4
- 5
资源评论
- llx10032017-09-13刚下载Brackets的,试试常用插件。
ipitn
- 粉丝: 9
- 资源: 4
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- Python大作业:音乐播放软件(爬虫+可视化+数据分析+数据库)
- 课程设计-python爬虫-爬取日报,爬取日报文章后存储到本地,附带源代码+课程设计报告
- 软件和信息技术服务行业投资与前景预测.pptx
- 课程设计-基于SpringBoot + Mybatis+python爬虫NBA球员数据爬取可视化+源代码+文档+sql+效果图
- 软件品质管理系列二项目策划规范.doc
- 基于TensorFlow+PyQt+GUI的酒店评论情感分析,支持分析本地数据文件和网络爬取数据分析+源代码+文档说明+安装教程
- 软件定义无线电中的模拟电路测试技术.pptx
- 软件开发协议(作为技术开发合同附件).doc
- 软件开发和咨询行业技术趋势分析.pptx
- 软件测试题详解及答案.doc
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功