包详细信息

js-beautify

beautifier21.8mMIT1.15.4

beautifier.io for node

beautify, beautifier, code-quality

自述文件

JS Beautifier

CI Greenkeeper badge

PyPI version CDNJS version NPM @latest NPM @next

Join the chat at https://gitter.im/beautifier/js-beautify Twitter Follow

<img alt="NPM stats" src=https://nodei.co/npm/js-beautify.svg?downloadRank=true&downloads=true"/>

This little beautifier will reformat and re-indent bookmarklets, ugly JavaScript, unpack scripts packed by Dean Edward’s popular packer, as well as partly deobfuscate scripts processed by the npm package javascript-obfuscator.

Open beautifier.io to try it out. Options are available via the UI.

Contributors Needed

I'm putting this front and center above because existing owners have very limited 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 customer facing bugs and underlying problems with the internal design and implementation.

If you are interested, please take a look at the CONTRIBUTING.md then fix an issue marked with the "Good first issue" label and submit a PR. Repeat as often as possible. Thanks!

Installation

You can install the beautifier for Node.js or Python.

Node.js JavaScript

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.

$ npm -g install js-beautify
$ js-beautify foo.js

You can also use js-beautify as a node library (install locally, the npm default):

$ npm install js-beautify

Node.js JavaScript (vNext)

The above install the latest stable release. To install beta or RC versions:

$ npm install js-beautify@next

Web Library

The beautifier can be added on your page as web library.

JS Beautifier is hosted on two CDN services: cdnjs and rawgit.

To pull the latest version from one of these services include one set of the script tags below in your document:

<script src="https://cdnjs.cloudflare.com/ajax/libs/js-beautify/1.15.4/beautify.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/js-beautify/1.15.4/beautify-css.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/js-beautify/1.15.4/beautify-html.js"></script>

<script src="https://cdnjs.cloudflare.com/ajax/libs/js-beautify/1.15.4/beautify.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/js-beautify/1.15.4/beautify-css.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/js-beautify/1.15.4/beautify-html.min.js"></script>

Example usage of a JS tag in html:

<!DOCTYPE html>
<html lang="en">
  <body>

. . .

    <script src="https://cdnjs.cloudflare.com/ajax/libs/js-beautify/1.15.4/beautify.min.js"></script>
    <script src="script.js"></script>
  </body>
</html>

Older versions are available by changing the version number.

Disclaimer: These are free services, so there are no uptime or support guarantees.

Python

To install the Python version of the beautifier:

$ 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 for CSS:

$ pip install cssbeautifier

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 beautifier.io. Options are available via the UI.

Web Library

After you embed the <script> tags in your html file, they expose three functions: js_beautify, css_beautify, and html_beautify

Example usage of beautifying a json string:

const options = { indent_size: 2, space_in_empty_paren: true }

const dataObj = {completed: false,id: 1,title: "delectus aut autem",userId: 1,}

const dataJson = JSON.stringify(dataObj)

js_beautify(dataJson, options)

/* OUTPUT
{
  "completed": false,
  "id": 1,
  "title": "delectus aut autem",
  "userId": 1,
}
*/

Node.js JavaScript

When installed globally, the beautifier provides an executable js-beautify script. The beautified result is sent to stdout unless otherwise configured.

$ js-beautify foo.js

To use js-beautify as a node library (after install locally), import and call the appropriate beautifier method for JavaScript (JS), CSS, or HTML. All three 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 underscores instead of dashes. For example, --indent-size 2 --space-in-empty-paren would be { indent_size: 2, space_in_empty_paren: true }.

var beautify = require('js-beautify/js').js,
    fs = require('fs');

fs.readFile('foo.js', 'utf8', function (err, data) {
    if (err) {
        throw err;
    }
    console.log(beautify(data, { indent_size: 2, space_in_empty_paren: true }));
});

If you are using ESM Imports, you can import js-beautify like this:

// 'beautify' can be any name here.
import beautify from 'js-beautify';

beautify.js(data, options);
beautify.html(data, options);
beautify.css(data, options);

Python

After installing, to beautify using Python:

$ js-beautify file.js

Beautified output goes to stdout by default.

To use jsbeautifier as a library is simple:

import jsbeautifier
res = jsbeautifier.beautify('your JavaScript string')
res = jsbeautifier.beautify_file('some_file.js')

...or, to specify some options:

opts = jsbeautifier.default_options()
opts.indent_size = 2
opts.space_in_empty_paren = True
res = jsbeautifier.beautify('some JavaScript', opts)

The configuration option names are the same as the CLI names but with underscores instead of dashes. The example above would be set on the command-line as --indent-size 2 --space-in-empty-paren.

Options

These are the command-line flags for both Python and JS scripts:

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"] Select beautifier type (NOTE: Does *not* filter files, only defines which beautifier type to run)
  -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 [" "]
  -t, --indent-with-tabs            Indent with tabs, overrides -s and -c
  -e, --eol                         Character(s) to use as line terminators.
                                    [first newline in file, otherwise "\n]
  -n, --end-with-newline            End output with newline
  --editorconfig                    Use EditorConfig to set up the options
  -l, --indent-level                Initial indentation level [0]
  -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 )
  -E, --space-in-empty-paren        Add a single space inside empty paren, ie. f( )
  -j, --jslint-happy                Enable jslint-stricter mode
  -a, --space-after-anon-function   Add a space before an anonymous function's parens, ie. function ()
  --space-after-named-function      Add a space before a named function's parens, i.e. function example ()
  -b, --brace-style                 [collapse|expand|end-expand|none][,preserve-inline] [collapse,preserve-inline]
  -u, --unindent-chained-methods    Don't indent chained method calls
  -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 that exceed N characters [0]
  -X, --e4x                         Pass E4X xml literals through untouched
  --good-stuff                      Warm the cockles of Crockford's heart
  -C, --comma-first                 Put commas at the beginning of new line instead of end
  -O, --operator-position           Set operator position (before-newline|after-newline|preserve-newline) [before-newline]
  --indent-empty-lines              Keep indentation on empty lines
  --templating                      List of templating languages (auto,django,erb,handlebars,php,smarty,angular) ["auto"] auto = none in JavaScript, all in HTML

Which correspond to the underscored option keys for both library interfaces

defaults per CLI options

{
    "indent_size": 4,
    "indent_char": " ",
    "indent_with_tabs": false,
    "editorconfig": false,
    "eol": "\n",
    "end_with_newline": false,
    "indent_level": 0,
    "preserve_newlines": true,
    "max_preserve_newlines": 10,
    "space_in_paren": false,
    "space_in_empty_paren": false,
    "jslint_happy": false,
    "space_after_anon_function": false,
    "space_after_named_function": false,
    "brace_style": "collapse",
    "unindent_chained_methods": false,
    "break_chained_methods": false,
    "keep_array_indentation": false,
    "unescape_strings": false,
    "wrap_line_length": 0,
    "e4x": false,
    "comma_first": false,
    "operator_position": "before-newline",
    "indent_empty_lines": false,
    "templating": ["auto"]
}

defaults not exposed in the cli

{
  "eval_code": false,
  "space_before_conditional": true
}

Notice not all defaults are exposed via the CLI. Historically, the Python and JS APIs have not been 100% identical. There are still a few other additional cases keeping us from 100% API-compatibility.

Loading settings from environment or .jsbeautifyrc (JavaScript-Only)

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.

Setting inheritance and Language-specific overrides

The settings are a shallow tree whose values are inherited for all languages, but 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 .jsbeautifyrc, can also use inheritance/overriding.

Below is an example configuration tree showing all the supported locations for language override nodes. We'll use indent_size to discuss how this configuration would behave, but any number of settings can be inherited or overridden:

{
    "indent_size": 4,
    "html": {
        "end_with_newline": true,
        "js": {
            "indent_size": 2
        },
        "css": {
            "indent_size": 2
        }
    },
    "css": {
        "indent_size": 1
    },
    "js": {
       "preserve-newlines": true
    }
}

Using the above example would have the following result:

  • HTML files
    • Inherit indent_size of 4 spaces from the top-level setting.
    • The files would also end with a newline.
    • JavaScript and CSS inside HTML
      • Inherit the HTML end_with_newline setting.
      • Override their indentation to 2 spaces.
  • CSS files
    • Override the top-level setting to an indent_size of 1 space.
  • JavaScript files
    • Inherit indent_size of 4 spaces from the top-level setting.
    • Set preserve-newlines to true.

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.

// 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.

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
  -b, --brace-style                  [collapse|expand] ["collapse"]
  -L, --selector-separator-newline   Add a newline between multiple selectors
  -N, --newline-between-rules        Add a newline between CSS rules
  --indent-empty-lines               Keep indentation on empty lines

HTML 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
  -p, --preserve-newlines            Preserve existing line-breaks (--no-preserve-newlines disables)
  -m, --max-preserve-newlines        Maximum number of line-breaks to be preserved in one chunk [10]
  -I, --indent-inner-html            Indent <head> and <body> sections. Default is false.
  -b, --brace-style                  [collapse-preserve-inline|collapse|expand|end-expand|none] ["collapse"]
  -S, --indent-scripts               [keep|separate|normal] ["normal"]
  -w, --wrap-line-length             Maximum characters per line (0 disables) [250]
  -A, --wrap-attributes              Wrap attributes to new lines [auto|force|force-aligned|force-expand-multiline|aligned-multiple|preserve|preserve-aligned] ["auto"]
  -M, --wrap-attributes-min-attrs    Minimum number of html tag attributes for force wrap attribute options [2]
  -i, --wrap-attributes-indent-size  Indent wrapped attributes to after N characters [indent-size] (ignored if wrap-attributes is "aligned")
  -d, --inline                       List of tags to be considered inline tags
  --inline_custom_elements           Inline custom elements [true]
  -U, --unformatted                  List of tags (defaults to inline) that should not be reformatted
  -T, --content_unformatted          List of tags (defaults to pre) whose content should not be reformatted
  -E, --extra_liners                 List of tags (defaults to [head,body,/html] that should have an extra newline before them.
  --editorconfig                     Use EditorConfig to set up the options
  --indent_scripts                   Sets indent level inside script tags ("normal", "keep", "separate")
  --unformatted_content_delimiter    Keep text content together between this string [""]
  --indent-empty-lines               Keep indentation on empty lines
  --templating                       List of templating languages (auto,none,django,erb,handlebars,php,smarty,angular) ["auto"] auto = none in JavaScript, all in html

Directives

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} -->.

Ignore directive

The ignore directive makes the beautifier completely ignore part of a file, treating it as literal text that is not parsed. The input below will remain unchanged after beautification:

// Use ignore when the content is not parsable in the current language, JavaScript in this case.
var a =  1;
/* beautify ignore:start */
 {This is some strange{template language{using open-braces?
/* beautify ignore:end */

Preserve directive

NOTE: this directive only works in HTML and JavaScript, not CSS.

The preserve directive makes the Beautifier parse and then keep the existing formatting of a section of code.

The input below will remain unchanged after beautification:

// Use preserve when the content is valid syntax in the current language, JavaScript in this case.
// This will parse the code and preserve the existing formatting.
/* beautify preserve:start */
{
    browserName: 'internet explorer',
    platform:    'Windows 7',
    version:     '8'
}
/* beautify preserve:end */

License

You are free to use this in any way you want, in case you find this useful or working for you but you must keep the copyright notice and license. (MIT)

Credits

Thanks also to Jason Diamond, Patrick Hof, Nochum Sossonko, Andreas Schneider, Dave Vasilevsky, Vital Batmanov, Ron Baldwin, Gabriel Harrison, Chris J. Shull, Mathias Bynens, Vittorio Gambaletta and others.

(README.md: js-beautify@1.15.4)

更新日志

Changelog

v1.15.4

  • Downgrade nopt to v7.x to maintain Node.js v14 compatibility (#2358)

v1.15.3

  • fix node 18 support by downgrading glob to v10 (#2350)

v1.15.2

  • Patch SNYK-JS-CROSSSPAWN-8303230 issue brought it through old glob package (#2328)
  • release wheels on pypi (#2313)
  • ModuleNotFoundError: No module named 'setuptools.command.test' as of latest setuptools package release (#2301)
  • [Python]Compatible with setuptools>=72 (#2300)

v1.15.1

  • Turn new angular templating off by default in html (#2247)
  • Perf regression in latest release (1.15.0) (#2246)

v1.15.0

  • Fixed #2219 - formatting of new Angular control flow syntax (#2221)

v1.14.11

  • Editor not working https://beautifier.io/ (#2201)
  • Set nodejs minimum to v14 (#2169)
  • Invalid prettification of object with unicode escape character as object key (#2159)
  • invalid json being generated with wrap_line_length (#1932)

v1.14.9

  • Bump semver and editorconfig (#2161)
  • Update editorconfig package (#2160)
  • Allow to configure the "custom elements as inline elements" behavior (#2113)

v1.14.8

  • Require nodejs v12 or greater (#2151)
  • CSS insideNonNestedAtRule generic variable (#2147)
  • Update dependencies (#2145)
  • Fix CI build (#2144)
  • Fixed #2133 Theme Toggle on without_codemirror Mode (#2138)
  • use correct variable name (#2135)
  • docs: Fix a few typos (#2127)
  • Add support for new record types (cont.) (#2118)
  • fix - semicolon followed by block statement doesnt have new line (#2117)
  • Fix formatting related to the <menu> element (#2114)
  • issue prettifying (function(){code();{code}})() (#1852)

v1.14.7

  • Doc: Updates web browser implementation examples (#2107)
  • HTML formatter breaks layout by introducing newlines (#1989)

v1.14.6

  • Globs no longer work on Windows in 1.14.5 (#2093)

v1.14.5

  • Dependency updates and UI tweaks (#2088)
  • Bump terser from 5.12.1 to 5.14.2 (#2084)
  • new layout breaks everything on long lines (#2071)
  • Dark mode (#2057)

v1.14.4

  • Extra space before !important added (#2056)
  • css format removes space after quoted value (#2051)
  • Add grid-template-areas to NON_SEMICOLON_NEWLINE_PROPERTY list (#2035)
  • CSS formatter removes useful space (#2024)
  • CHANGELOG.md file was wiped out in v1.14.2 (#2022)
  • Fails to recognize Handlebars block with whitespace control, e.g. {{~#if true ~}} (#1988)
  • Support new sass @use syntax (#1976)
  • Do not remove whitespace after number (#1950)
  • html formatter doesn't support handlebars partial blocks (#>) (#1869)
  • in keyword in class method causes indentation problem (#1846)
  • space_after_named_function not working inside an ES6 class (#1622)
  • Restyle website (#1444)
  • improper line concatenation between 'return' and a prefix expression (#1095)

v1.14.3

  • [LESS] Fixing issues with spacing when an object literal lives inside a mixin (#2017)
  • Overindentation when using "class" as a key in an object (#1838)
  • CSS Grid template formatting is broken when adding track size after line names (#1817)
  • SCSS module system @use problem (#1798)
  • JS "space_in_empty_paren" failing for class methods (#1151)
  • LESS mixins gets formatted strangely (#722)

v1.14.2

  • Why put npm in dependencies? (#2005)
  • [Bug] Logical assignments in JS are incorrectly beautified (#1991)

v1.14.1

  • feature request: cmd+enter hotkey for mac users (#1985)
  • Wrong indentation when the last line in a case is a right brace (#1683)

v1.14.0

  • import.meta appears on newline (#1978)
  • Added buttons to website (#1930)
  • Logical assignment operators; Fix parsing of optional chaining (#1888)
  • Numbers should be allowed to contain underscores (#1836)
  • Use native mkdirSync instead of 'mkdirp' package (#1833)
  • selector_separator_newline adds erroneous newline on @extend SCSS statements (#1799)

v1.13.13

  • IE11 compatibility failure v>1.13.5 (#1918)

v1.13.11

  • Support short PHP tags (#1840)

v1.13.6

  • Fix space-before-conditional: false to work on switch-case statement (#1881)
  • Optional chaining obj?.[expr] (#1801)

v1.13.5

v1.13.1

  • Option 'max_preserve_newlines' not working on beautify_css.js CSS Beautifier (#1863)
  • React Fragment Short Syntax <></> issue (#1854)
  • add viewport meta tag to index.html (#1843)
  • Add basic smarty templating support (#1820)
  • Tagged Template literals (#1244)

v1.13.0

  • (internal) Refactor python cssbeautifier to reuse jsbeautifier CLI methods (#1832)
  • (internal) Switch from node-static to serve (#1831)
  • Fixed pip install cssbeautifier (#1830)

v1.12.0

  • Python jsbeautifier fails for special chars (#1809)
  • pip install cssbeautifier fails (#1808)
  • Add expand brace-style option to css beautifier (#1796)
  • Support nullish-coalescing (#1794)
  • Upgrade ga.js to analytics.js (#1777)
  • Newline rule not working with css-like files (#1776)
  • no new line after self closing tag (#1718)
  • HTML format, no break after <label>? (#1365)
  • Does this extension still supports applying Allman style to CSS? (#1353)
  • Add brace_style option for CSS (#1259)

v1.11.0

  • Please bump mkdirp to fix mkdirp@0.5.1 vulnerability (#1768)
  • Incorrect indentation of Handlebars inline partials (#1756)
  • Support optional-chaining (#1727)
  • Please support es module (#1706)
  • Support new js proposals: optional-chaining & pipeline-operator (#1530)
  • Optional

    closing not implemented (#1503)

v1.10.3

  • Unquoted href causes wrong indentation (#1736)
  • Broken private fields in classes (JS) (#1734)
  • Fix for python 2.7 and cli parameters (#1712)
  • Search (ctrl+f) works only in view field in CodeMirror (#1696)

v1.10.2

  • Please update CodeMirror Addon (#1695)
  • Nested braces indentation (#223)

v1.10.1

  • javascript fails to format when <?php > is first text inside <script> tag (#1687)
  • 414 Request-URI Too Large (#1640)

v1.10.0

  • beautifying scss selector with colon in it adds space (#1667)
  • Javascript multiline comments duplicates (#1663)
  • Tokenizer crashes if the input terminates with a dot character. (#1658)
  • stop reformatting valid css \! into invalid \ ! (#1656)
  • wrong indent for unclosed <? - need to support disabling templating (#1647)
  • Beautify inserts space before exclamation mark in comment <!-- in css <style> (#1641)
  • 'less' mixins parameter formatting problem (#1582)
  • Change css tests to use 4 space indenting instead of tabs (#1527)
  • Braces after case get pushed onto new line (#1357)
  • Extra space in pseudo-elements and pseudo-classes selectors (#1233)
  • LESS formatting - mixins with multiple variables (#1018)
  • Bug in less format (#842)

v1.9.1

  • nested table not beautified correctly (#1649)
  • Add an option to preserve indentation on empty lines (#1322)

v1.9.0

  • Incorrect indentation of ^ inverted section tags in Handlebars/Mustache code (#1623)
  • PHP In HTML Attributes (#1620)
  • DeanEdward python unpacker offset problem (#1616)
  • CLI on Windows doesn't accept -f - for stdin? (#1609)
  • HTML type attribute breaks JavaScript beautification? (#1606)
  • Use of global MODE before declaration caused uglify problem (#1604)
  • When building html tags using Mustache variables, extra whitespace is added after opening arrow (#1602)
  • <script type="text/html">isnot abled to be beautified (#1591)
  • _get_full_indent undefined (#1590)
  • Website "autodetect" setting doesn't distinguish css vs javascript (#1565)
  • Add setting to keep HTML tag text content unformatted or ignore custom delimiters (#1560)
  • HTML auto formatting using spaces instead of tabs (#1551)
  • Unclosed single quote in php tag causes formatting changes which break php code (#1377)
  • Using tabs when wrapping attributes and wrapping if needed (#1294)
  • HTML --wrap-attributes doesn't respect --wrap-line-length (#1238)
  • Bad indent level(HTML) (#1213)
  • js-beautify produces invalid code for variables with Unicode escape sequences (#1211)
  • support vuejs (#1154)
  • Go templates in HTML (#881)
  • Better behavior for javascript --wrap-line-length (#284)

v1.8.9

  • Won't run from CLI - bad option name files (#1583)
  • in the .vue file space\_after\_anon\_function is invalid (#1425)
  • Add function default_options() to beautifier.js (#1364)
  • fix: Missing space before function parentheses ? (#1077)
  • Support globs in CLI (#787)

v1.8.8

  • async function in object wrong indentation (#1573)

v1.8.7

  • Add tests for html indent\_scripts option (#1518)
  • Support dynamic import (#1197)
  • HTML: add an option to preserve manual wrapping of attributes (#1125)
  • js-beautify adds a space between # and include (#1114)
  • space_after_anon_function doesn't work with anon async functions (#1034)
  • Space before function arguments (space-after-function) (space-after-named-function) (#608)

v1.8.6

  • JS beautify break the angular compile (#1544)
  • base64 string is broken with v1.8.4 (#1535)
  • Bookmarklet becomes totally useless (#1408)
  • HTTPS (#1399)
  • Beautify breaks when js starts with space followed by multi-line comment (#789)

v1.8.4

  • Multiple newlines added between empty textarea and "unformatted" inline elements (#1534)
  • unindent_chained_methods broken (#1533)

v1.8.3

  • Missing Bower Assets (#1521)
  • Javascript ternary breaked with await (#1519)
  • Object property indented after await (#1517)
  • Handlebars formatting problems (#870)
  • beautify.js doesn't have indent_level option (#724)

v1.8.1

  • Why npm is a dependency? (#1516)
  • indent_inner_html not working in v1.8.0 (#1514)

v1.8.0

  • list items of nested lists get indented backwards (#1501)
  • Make beautifier auto-convert options with dashes into underscores (#1497)
  • ReferenceError: token is not defined (#1496)
  • Publish v1.8.0 (#1495)
  • still probem #1439 / #1337 (#1491)
  • Duplicating HTML Code Nested In PHP (#1483)
  • Handlebars - if tags are broken when using helper with textarea (#1482)
  • TypeError: Cannot read property '1' of null (#1481)
  • Space in Self Closing Tag Issue (#1478)
  • Weird Formatting in VSCode (#1475)
  • Indent with tab issue on website (#1470)
  • Contents of hbs tags are converted to lowercase (#1464)
  • HTML tags are indented wrongly when attributes are present (#1462)
  • hbs tags are stripped when there is a comment below or inline (#1461)
  • Spaces added to handlebars with '=' (#1460)
  • jsbeautifier.org don't works (#1445)
  • Commenting code and then beautifying removes line breaks (#1440)
  • Less: Where is my space? (#1411)
  • No newline after @import (#1406)
  • "html.format.wrapAttributes": "force-aligned" adds empty line on long attributes (#1403)
  • HTML: wrap_line_length is handled incorrectly (#1401)
  • js-beautify is breaking code by adding space after import (#1393)
  • JS-Beautify should format XML tags inside HTML files (#1383)
  • python unpacker can not handle if radix given as [] and not as a number (#1381)
  • unindent_chained_methods breaks indentation for if statements without brackets (#1378)
  • function parameters merged into single line when starting with ! or [ (#1374)
  • CSS selector issue (header > div[class~="div-all"]) in SCSS file (#1373)
  • Add "Create Issue for Unexpected Output" button to website (#1371)
  • Add combobox to control type of beautification (#1370)
  • Add Options textbox to website for debugging (#1369)

v1.7.5

  • Strict mode: js_source_text is not defined [CSS] (#1286)
  • Made brace_style option more inclusive (#1277)
  • White space before"!important" tag missing in CSS beautify (#1273)

v1.7.4

  • Whitespace after ES7 async keyword for arrow functions (#896)

v1.7.3

  • Version 1.7.0 fail to install through pip (#1250)
  • Installing js-beautify fails (#1247)

v1.7.0

  • undindent-chained-methods option. Resolves #482 (#1240)
  • Add test and tools folder to npmignore (#1239)
  • incorrect new-line insertion after "yield" (#1206)
  • Do not modify built-in objects (#1205)
  • Fix label checking incorrect box when clicked (#1169)
  • Webpack (#1149)
  • daisy-chain indentation leads to over-indentation (#482)

v1.6.12

  • CSS: Preserve Newlines (#537)

v1.6.11

  • On beautify, new line before next CSS selector (#1142)

v1.6.10

v1.6.9

  • Wrong HTML beautification starting with v1.6.5 (#1115)
  • Ignore linebreak when meet handlebar (#1104)
  • Lines are not un-indented correctly when attributes are wrapped (#1103)
  • force-aligned is not aligned when indenting with tabs (#1102)
  • Python package fails to publish (#1101)
  • Explaination of 'operator_position' is absent from README.md (#1047)

v1.6.8

  • Incorrect indentation after loop with comment (#1090)
  • Extra newline is inserted after beautifying code with anonymous function (#1085)
  • end brace with next comment line make bad indent (#1043)
  • Javascript comment in last line doesn't beautify well (#964)
  • indent doesn't work with comment (jsdoc) (#913)
  • Wrong indentation, when new line between chained methods (#892)
  • Comments in a non-semicolon style have extra indent (#815)
  • [bug] Incorrect indentation due to commented line(s) following a function call with a function argument. (#713)
  • Wrong indent formatting (#569)

v1.6.7

  • HTML pre code indentation (#928)
  • Beautify script/style tags but ignore their inner JS/CSS content (#906)

v1.6.6

  • Wrong indentation for comment after nested unbraced control constructs (#1079)
  • Should prefer breaking the line after operator ? instead of before operator < (#1073)
  • New option "force-expand-multiline" for "wrap_attributes" (#1070)
  • Breaks if html file starts with comment (#1068)
  • collapse-preserve-inline restricts users to collapse brace_style (#1057)
  • Parsing failure on numbers with "e" (#1054)
  • Issue with Browser Instructions (#1053)
  • Add preserve inline function for expand style braces (#1052)
  • Update years in LICENSE (#1038)
  • JS. Switch with template literals. Unexpected indentation. (#1030)
  • The object with spread object formatted not correctly (#1023)
  • Bad output generator function in class (#1013)
  • Support editorconfig for stdin (#1012)
  • Publish to cdnjs (#992)
  • breaks if handlebars comments contain handlebars tags (#930)
  • Using jsbeautifyrc is broken (#929)
  • Option to put HTML attributes on their own lines, aligned (#916)
  • Erroneously changes CRLF to LF on Windows in HTML and CSS (#899)
  • Weird space in {get } vs { normal } (#888)
  • Bad for-of formatting with constant Array (#875)
  • Problems with filter property in css and scss (#755)
  • Add "collapse-one-line" option for non-collapse brace styles (#487)

v1.6.4

  • css-beautify sibling combinator space issue (#1001)
  • Bug: Breaks when the source code it found an unclosed multiline comment. (#996)
  • CSS: Preserve white space before pseudo-class and pseudo-element selectors (#985)
  • Spelling error in token definition (#984)
  • collapse-preserve-inline does not preserve simple, single line ("return") statements (#982)
  • Publish the library via cdn (#971)
  • Bug with css calc() function (#957)
  • &:first-of-type:not(:last-child) when prettified insert erroneous white character (#952)
  • Shorthand generator functions are formatting strangely (#941)
  • Add handlebars support on cli for html (#935)
  • Do not put a space within yield* generator functions. (#920)
  • Possible to add an indent_inner_inner_html option? (Prevent indenting second-level tags) (#917)
  • Messing up jsx formatting multi-line attribute (#914)
  • Bug report: Closing 'body' tag isn't formatted correctly (#900)
  • { throw … } not working with collapse-preserve-inline (#898)
  • ES6 concise method not propely indented (#889)
  • CSS beautify changing symantics (#883)
  • Dojo unsupported script types. (#874)
  • Readme version comment (#868)
  • Extra space after pseudo-elements within :not() (#618)
  • space in media queries after colon &: selectors (#565)
  • Integrating editor config (#551)
  • Preserve short expressions/statements on single line (#338)

v1.6.3

  • CLI broken when output path is not set (#933)
  • huge memory leak (#909)
  • don't print unpacking errors on stdout (python) (#884)
  • Fix incomplete list of non-positionable operators (python lib) (#878)
  • Fix Issue #844 (#873)
  • assignment exponentiation operator (#864)
  • Bug in Less mixins (#844)
  • Can't Nest Conditionals (#680)
  • ternary operations (#670)
  • Support newline before logical or ternary operator (#605)
  • Provide config files for format and linting (#336)

v1.6.2

  • Add missing 'collapse-preserve-inline' option to js module (#861)

v1.6.1

  • Inconsistent formatting for arrays of objects (#860)
  • Publish v1.6.1 (#859)
  • Space added to "from++" due to ES6 keyword (#858)
  • Changelog generator doesn't sort versions above 9 right (#778)
  • space-after-anon-function not applied to object properties (#761)
  • Separating 'input' elements adds whitespace (#580)
  • Inline Format (#572)
  • Preserve attributes line break in HTML (#455)
  • Multiline Array (#406)

v1.6.0

  • Individual tests pollute options object (#855)
  • Object attribute assigned fat arrow function with implicit return of a ternary causes next line to indent (#854)
  • Treat php tags as single in html (#850)
  • Read piped input by default (#849)
  • Replace makefile dependency with bash script (#848)
  • list of HTML inline elements incomplete; wraps inappropriately (#840)
  • Beautifying bracket-less if/elses (#838)
  • elements within a are getting indented incorrectly (#836)
  • single attribute breaks jsx beautification (#834)
  • Improve Python packaging (#831)
  • Erroneously changes CRLF to LF on Windows. (#829)
  • Can't deal with XHTML5 (#828)
  • HTML after PHP is indented (#826)
  • exponentiation operator (#825)
  • Add support for script type "application/ld+json" (#821)
  • package.json: Remove "preferGlobal" option (#820)
  • Don't use array.indexOf() to support legacy browsers (#816)
  • ES6 Object Shortand Indenting Weirdly Sometimes (#810)
  • Implicit Return Function on New Line not Preserved (#806)
  • Misformating "0b" Binary Strings (#803)
  • Beautifier breaks ES6 nested template strings (#797)
  • Misformating "0o" Octal Strings (#792)
  • Do not use hardcoded directory for tests (#788)
  • Handlebars {{else}} tag not given a newline (#784)
  • Wrong indentation for XML header (<?xml version="1.0"?>) (#783)
  • is_whitespace for loop incrementing wrong variable (#777)
  • Newline is inserted after comment with comma_first (#775)
  • Cannot copy more than 1000 characters out of CodeMirror buffer (#768)
  • Missing 'var' in beautify-html.js; breaks strict mode (#763)
  • Fix typo in the example javascript code of index.html (#753)

v1.5.10

  • Preserve directive doesn't work as intended (#723)

v1.5.7

  • Support for legacy JavaScript versions (e.g. WSH+JScript & Co) (#720)
  • Is \n hard coded into CSS Beautifier logic? (#715)
  • Spaces and linebreaks after # and around { } messing up interpolation/mixins (SASS/SCSS) (#689)
  • Calls to functions get completely messed up in Sass (*.scss) (#675)
  • No new line after selector in scss files (#666)
  • using html-beautify on handlebars template deletes unclosed tag if on second line (#623)
  • more Extra space after scss pseudo classes (#557)
  • Unnecessary spaces in PHP code (#490)
  • Some underscore.js template tags are broken (#417)
  • Selective ignore using comments (feature request) (#384)

v1.5.6

  • Fix tokenizer's bracket pairs' open stack (#693)
  • Indentation is incorrect for HTML5 void tag <source> (#692)
  • Line wrapping breaks at the wrong place when the line is indented. (#691)
  • Publish v1.5.6 (#687)
  • Replace existing file fails using python beautifier (#686)
  • Pseudo-classes formatted incorrectly and inconsistently with @page (#661)
  • doc: add end_with_newline option (#650)
  • Improve support for xml parts of jsx (React) => spaces, spread attributes and nested objects break the process (#646)
  • html-beautify formats handlebars comments but does not format html comments (#635)
  • Support for ES7 async (#630)
  • css beautify adding an extra newline after a comment line in a css block (#609)
  • No option to "Indent with tabs" for HTML files (#587)
  • Function body is indented when followed by a comment (#583)
  • JSX support (#425)
  • Alternative Newline Characters (#260)

v1.5.5

  • Add GUI support for --indent-inner-html. (#633)
  • Publish v1.5.5 (#629)
  • CSS: Updating the documentation for the 'newline_between_rules' (#615)
  • Equal Sign Removed from Filter Properties Alpha Opacity Assignment (#599)
  • Keep trailing spaces on comments (#598)
  • only print the file names of changed files (#597)
  • CSS: support add newline between rules (#574)
  • elem[array]++ changes to elem[array] ++ inserting unnecessary gap (#570)
  • add support to less functions paramters braces (#568)
  • selector_separator_newline: true for Sass doesn't work (#563)
  • yield statements are being beautified to their own newlines since 1.5.2 (#560)
  • HTML beautifier inserts extra newline into <li>s ending with <code> (#524)
  • Add wrap_attributes option (#476)
  • Add or preserve empty line between CSS rules (#467)
  • Support comma first style of variable declaration (#245)

v1.5.4

  • TypeScript oddly formatted with 1.5.3 (#552)
  • HTML beautifier inserts double spaces between adjacent tags (#525)
  • Keep space in font rule (#491)
  • [Brackets plug in] Space after disappears (#454)
  • Support nested pseudo-classes and parent reference (LESS) (#427)
  • Alternate approach: preserve single spacing and treat img as inline element (#415)

v1.5.3

  • [TypeError: Cannot read property 'type' of undefined] (#548)
  • Bug with RegExp (#547)
  • Odd behaviour on less (#520)
  • css beauitify (#506)
  • Extra space after scss pseudo classes. (#500)
  • Generates invalid scss when formatting ampersand selectors (#498)
  • bad formatting of .less files using @variable or &:hover syntax (#489)
  • Incorrect beautifying of CSS comment including an url. (#466)
  • Handle SASS parent reference &: (#414)
  • Js-beautify breaking selectors in less code. (#410)
  • Problem with "content" (#364)
  • Space gets inserted between function and paren for function in Define (#313)
  • beautify-html returns null on broken html (#301)
  • Indentation of functions inside conditionals not passing jslint (#298)

v1.5.2

  • Allow custom elements to be unformatted (#540)
  • Need option to ignore brace style (#538)
  • Refactor to Output and OutputLine classes (#536)
  • Recognize ObjectLiteral on open brace (#535)
  • Refactor to fully tokenize before formatting (#530)
  • Cleanup checked in six.py file (#527)
  • Changelog.md? (#526)
  • New line added between each css declaration (#523)
  • Kendo Template scripts get messed up! (#516)
  • SyntaxError: Unexpected token ++ (#514)
  • space appears before open square bracket when the object name is "set" (#508)
  • Unclosed string problem (#505)
  • "--n" and "++n" are not indented like "n--" and "n++" are... (#495)
  • Allow <style> and <script> tags to be unformatted (#494)
  • Preserve new line at end of file (#492)
  • Line wraps breaking numbers (causes syntax error) (#488)
  • jsBeautify acts differently when handling different kinds of function expressions (#485)
  • AttributeError: 'NoneType' object has no attribute 'groups' (#479)
  • installation doco for python need update -- pip install six? (#478)
  • Move einars/js-beautify to beautify-web/js-beautify (#475)
  • Bring back space_after_anon_function (#474)
  • fix for #453, Incompatible handlebar syntax (#468)
  • Python: missing explicit dependency on "six" package (#465)
  • function declaration inside array, adds extra line. (#464)
  • [es6] yield a array (#458)
  • Publish v1.5.2 (#452)
  • Port css colon character fix to python (#446)
  • Cannot declare object literal properties with unquoted reserved words (#440)
  • Do not put a space within function* generator functions. (#428)
  • beautification of "nth-child" css fails csslint (#418)