- new styling option expand-strict which always puts braces into new
lines. It can break the scripts badly, though, so it is not exposed in
index.html;
- option to add - or not add - a space after operator,
- much improved comment handling.
Now the beautfier adjusts the base level of the code by the first line.
This means that you can now very easily use the beautifier together with
your the editor, and the indentation level will stay as is:
...
case 'foo':
if (bar == baz) { blarp(); }
break;
case 'oof':
...
if you pass only the "if" line, with e.g ":!jsbeautify -" in vim, it
won't mess up the depth, and the code will be:
...
case 'foo':
if (bar == baz) {
blarp();
}
break;
case 'oof':
...
Always detect this style comments, and reindent
them as required.
/*
* ......
* .......
*
*/
Until now, this was done only for javadoc-ish comments
starting with /**
var a = function(){
func1()
}
var b = function(){
func2()
}
got indented to
var a = function(){
func1()
}
var b = function(){
func2()
}
now it is
var a = function(){
func1()
}
var b = function(){
func2()
}
I'm not sure I'm thrilled with this indentation style, but it looks
MUCH prettier for multiple functions:
var a = function() {
func1()
},
b = function() {
func2()
}
As reported by Kambfhase:
Input/result:
var a = function () {
return null;
},
b = false;
Expected:
var a = function () {
return null;
},
b = false;
If the function is not the first value though, the indentation is
correct.
Minor beautifying error creeped in, resulting in python version
function foo() { bar(); } xxxx
transforming to
function foo() {
bar();
} xxxx
(Only python version was affected)
else break / else return got split to two separate lines.
Also, make javascript use same tests as python: I did a minor cleanup
while writing the python version.
For semicolon-less javascript, the next line after "else" statement
could get glued to the one before due to ignored newline.
Fix that by resetting flags.if_line to false after "else" word has been
found and processed, so that it could pick up the original newlines.
Input:
if (foo) bar()
else baz()
do_something()
Was:
if (foo) bar()
else baz() do_something()
Now:
if (foo) bar()
else baz()
do_something()
Fixes issue #30 that else/catch/finally doesn't get pulled to the previous line:
if (foo)
{
bar();
}
else
{
baz();
}
got reformatted to:
if (foo) {
bar();
}
else { // sic!
baz
}
As reported by PING, the parser broke on:
variable = //comment
/regex/
Not entirely sure if the commit won't break on some weird division
cases. But, then I'll fix that, tee-hee.