var a = b,
/* some comment */
c, ... // <-- this line was indented incorrectly after a comment.
This also introduces a small mostly irrelevant bug: when the var-lines
are not ended with a semicolon, parser may miss its end, and the next
line can retain the old var-indentation.
var_line_reindented flag was not removed, when the var-statement finished, resulting in an erroneous indent, e.g:
(function () {
var Y = YAHOO,
yue = yut.Event;
Y.T = function (a) {
this.init(a); // <<<<<
}; // <<<<<
// some things...
})();
- single-line comments stay on the same line:
var a = 1; /* set a to 1 :) */
- javadoc is detected as starting with /**
gets indented to current level,
/**
* this function does nothing
*/
function foo()
- multi-line comments don't get indented or manipulated
at all,
var a = 1;
/* some
multiline
comment */
Javadoc newline handling changes introduced a bug where a multiline
javadoc-ish comment could be transformed with empty lines inbetween
them, i.e
/*
* XXX
*/
to
/*
* XXX
*/
Operators were somewhat messy when interacting between themselves
and other operators, e.g.
a++ > b
^
This patch makes everything smooth again. Also, --> was treated more like
"end of html-comment section", not "unary_minus, greater_than"
Also, fix lint-space after catch,
was: catch(e)
is: catch (e)
jQuery plugins commonly use $.extend({}, defaults, options) and this change
keeps that as a one-liner instead of breaking the line up (without even
indenting it).
Adds a basic test case to cover the scenario.
Under Windows, terminus.ttf doesn't include the prettiest low-res version of
Terminus (what the fuck are you doing people? It's ugly in the huge sizes! 10px
is where it's at!) so if a windows user has this font installed, it will look
ugly. So stick with the Consolas as a reasonable default instead.
browsers render the newline as a space in the link, and as a result
<a href='http://someurl.com'>Face</a> gets changed to
<a href='http://someurl.com'>
Face
</a>
For now, just don't format the <a>..</a> altogether.
Added automatic detection of escaped bookmarklets — they can be freely pasted now; also slightly cleaned and organized
the filter (Edward's packer, Javascriptobfuscator, and bookmarklet unpacking) code.
Now the following code:
var a = [
'<html>',
'<head><title>x</title></head>',
'<body>',
'<p>test</p>',
'</body>',
'</html>'];
will get neatly beautified (with keep_array_indentation) to:
var a = [
'<html>',
'<head><title>x</title></head>',
'<body>',
'<p>test</p>',
'</body>',
'</html>'];'
Also some fixes with pre-"function" blank lines have been sucked in.
This feature allows retaining the indentation in cases like this:
var markup = [
'<div>',
'<span>Hello World</span>',
some_variable,
'</div>
].join('');
when merging it together would be very undesirable.
The option is defined as "keep_array_indentation" flag in parameters for js_beautify().