Commit Graph

187 Commits

Author SHA1 Message Date
Gian Marco Gherardi
c4d6165dc2 Nicer formatting for array of objects literal 2010-06-04 10:54:55 +03:00
Rafal Chlodnicki
111c443ea1 Updated paths in script and changed name of generated user script 2010-06-04 15:47:26 +08:00
Rafal Chlodnicki
caa14548da Opera user script is no longer unmaintained so moving to root directory 2010-06-04 15:47:25 +08:00
Rafal Chlodnicki
9fc614dac9 Updated Opera user script and script for generating it 2010-06-04 15:47:25 +08:00
Einar Lielmanis
e91f36a89b Fix for braces_on_own_line: "return {"
return { something }

was getting translated to

return
{ something }

if braces_on_own_line setting was enabled, and as such, broke the
logic.
2010-05-29 01:12:10 +03:00
Einar Lielmanis
0f738f7336 Make jslint happy about beautify.js 2010-05-15 22:07:58 +03:00
Einar Lielmanis
65b6eab52f Allow weird assignment syntax
Was: foo.(bar) -> foo. (bar)
Now the space is not added.
2010-05-15 22:02:54 +03:00
Einar Lielmanis
ae4372ca90 Fix var line indenting-after-a-comment issue
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.
2010-05-14 21:55:41 +03:00
Einar Lielmanis
4cb412bc09 Restore correct indentation after multiline var.
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...
})();
2010-05-06 18:31:19 +03:00
Einar Lielmanis
60956ca302 Improve /* comment */ behaviour
- 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 */
2010-04-24 04:55:14 +03:00
Einar Lielmanis
d1c6023273 Add bt_braces() for testing brace-on-own-line mode 2010-03-29 22:59:55 +03:00
Einar Lielmanis
639c9fcf70 Add brace-flag to test suite. No actual tests yet. 2010-03-29 22:31:10 +03:00
Einar Lielmanis
cf5e52eb40 Fix for wringly indented blocks in var-lines
The following:

    var a=1,b={foo:2,bar:3},c=4;

was beautifying to:

    var a = 1,
        b = {
        foo: 2,
        bar: 3
    },
        c = 4;
2010-03-29 22:27:25 +03:00
Einar Lielmanis
9ad678cf79 Remove a leftover function 2010-03-26 13:56:07 +02:00
Einar Lielmanis
7f0afc49cb Treat single-line comments as inline comments
As a result, allow inline declarations, e.g

function foo( /*int*/ a, /*string*/ b)
2010-03-26 13:53:09 +02:00
Einar Lielmanis
340928039e Fix advancing closing bracket
When keep_array_indentation = true, the closing bracked could advance forward on each iteration:

from, e.g
var x = [{}
]

to
var x = [{}
    ]
2010-03-26 13:32:09 +02:00
Einar Lielmanis
743da2a338 Mention braces_on_own_line option 2010-03-21 02:54:37 +02:00
Einar Lielmanis
7426ff6c51 Add experimental brace-on-own-line support. Yes. 2010-03-19 18:20:46 +02:00
Dave Smith
6ed98f8c85 Works for interperters that have strange behavior for || 2010-03-18 12:21:51 -04:00
Einar Lielmanis
26b050be13 Fix renamed beautify-html.js link for beautify-cl 2010-03-17 23:14:35 +02:00
Einar Lielmanis
7c90212ec7 Add missing surname to Vital Batmanov as well 2010-03-16 01:32:28 +02:00
Einar Lielmanis
813dec4062 Add missing surname to Nochum in credits. 2010-03-16 01:26:59 +02:00
Einar Lielmanis
1248ba3073 Add readme.txt, make GitHub happy. 2010-03-16 01:25:04 +02:00
Einar Lielmanis
0a76c9d73c Maintenance, moving the code around. 2010-03-16 01:24:38 +02:00
Einar Lielmanis
d6046941b0 Fix newline handling regression in comments
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

 */
2010-03-15 18:01:51 +02:00
Einar Lielmanis
548d548626 Fix unary +/- regression
For "x != -1" minus was not detected as unary, resulting in " - 1"
2010-03-11 12:16:00 +02:00
Einar Lielmanis
55b5fd00f9 Fix javadoc handling, cache input.length
Fixes by Allex Wang:
- cache input.length as input_length
- javadoc_comment supports both \n and \r as newline
- minor javadoc detection fix
2010-03-11 12:08:05 +02:00
Einar Lielmanis
28b38981cc Simplify indentation system
... and squish a bunch of indentation bugs among the way
2010-03-02 01:06:28 +02:00
Einar Lielmanis
daa5e3e183 Fix minor array indenting issue 2010-03-02 00:24:05 +02:00
Einar Lielmanis
1d912103a5 Improve unary operators, add space after catch
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)
2010-03-02 00:08:13 +02:00
Einar Lielmanis
8949b7800e Add flag to run tests automatically
I was tired of the frequent clicking on "run tests" while developing, so:

jsbeautifier.org/?test=yes and the tests will run.
2010-03-01 23:51:33 +02:00
Jess Thrysoee
642bc4c8cc Add -a (Indent array) option to beautify-cl.js
This exposes the beautify.js keep_array_indentation option.
2010-02-21 08:16:23 +08:00
Ryan Graham
a9845df8e1 Don't break up foo({}, bar);
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.
2010-02-16 17:09:19 +08:00
Einar Lielmanis
5ddf19e5f6 Do not err on weird non-packers 2010-02-14 10:48:14 +02:00
Einar Lielmanis
c527398928 Unpack other eval-based packers. 2010-02-14 10:37:07 +02:00
Einar Lielmanis
1faf70255d Changed textarea font default to Consolas
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.
2010-02-06 02:33:45 +02:00
Einar Lielmanis
1c35278afc Minor boring rewording 2010-02-04 01:47:19 +02:00
Einar Lielmanis
e56868dbcf You want Paypal, you get Paypal. 2010-02-03 02:25:26 +02:00
Einar Lielmanis
feae719b36 Skip processing <a> tags for html
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.
2010-02-03 02:23:55 +02:00
Einar Lielmanis
8c6ef8c28d JavascriptObfuscator fixes
The quoting/dequoting was messed up, resulting in a quite bad output.
2010-01-18 20:55:18 +02:00
Einar Lielmanis
c3b5a573b8 JSLint happiness: }()
before:

function () {
    return x;
} ()

now:

function () {
    return x;
}()
2010-01-08 03:05:47 +02:00
Einar Lielmanis
516a5f84cc JSlint-friendlier array closing tag indentation
[[1,2], [3,4]]

before:

[
    [1, 2],
    [3, 4]]

now:
[
    [1, 2],
    [3, 4]
]
2010-01-08 02:39:23 +02:00
Einar Lielmanis
d40624768a Link to Fabio's gEdit page 2009-12-18 05:24:29 +02:00
Einar Lielmanis
3fe884d3a2 Added a test for stack underflow
}}} for the input crashed with error, actually.

Also, slightly refactored the testing stuff.
2009-12-16 04:02:59 +02:00
Einar Lielmanis
17e74eb6a1 Bookmarklets! Mention the bookmarklets! 2009-12-16 03:43:53 +02:00
Einar Lielmanis
e2265477ef Unpacking cleanup, bookmarklet unescape
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.
2009-12-16 03:36:50 +02:00
Einar Lielmanis
c86606a496 I just wanted a nicer commit message here. 2009-12-12 12:49:34 +02:00
Einar Lielmanis
45136db008 keep_array_indentation improvements
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.
2009-12-07 12:55:23 +02:00
Einar Lielmanis
2eafed74d3 Array indentation option in frontpage. 2009-12-02 03:40:38 +02:00
Einar Lielmanis
8deddc851b Experimental "keep array indentation" feature
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().
2009-12-02 03:40:10 +02:00