163 Commits

Author SHA1 Message Date
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
Einar Lielmanis
135e3a98eb Gab Harisson name on the page, minor CSS tweaks 2009-11-27 04:55:09 +02:00
Einar Lielmanis
22c87e9755 beaufify_js script updates by Gabriel Harrison
Updated the vim/beautify_js script so that you can pass the command
line arguments using vim as well;

added the ability to place the extracted directory anywhere and symlink
the bin/beautify_js file to someplace like /usr/bin and still have it
work.

After installed in your .vimrc, you can do stuff like the following

:BeautifyJavascript -i 4 -n
:BeautifyJavascript -i 1 -p
2009-11-27 04:54:21 +02:00
Einar Lielmanis
c05254230f A little bit more accent to unpacking 2009-11-17 10:41:44 +02:00
Einar Lielmanis
c178b7fe72 Fix for "do /regexp/"
input:
do/regexp/.test....

expected:
do /regexp/.test...

was:
do / regexp / .test...
2009-11-06 08:28:51 +02:00
Einar Lielmanis
6b79420cab Javadoc and var line changes
Added a support for javadoc syntax, which now gets neatly indented.

Varline handling was vastly improved, like:

input:
-----
var a, b, c, d = [], e, f, g = function () {};

was:
---
var a, b, c, d = []. // <- this moment varline got flagged as unclean,
e,                   // so next variables get each its own line
f,
g = function () {};

now it is:
---------
var a, b, c, d = [].
    e, f, g = function () {};

Some internal changes were done to preserve the flags between
block/expression mode changes.
2009-10-29 07:55:22 +02:00
Einar Lielmanis
6661c76c36 Fix for missing space on return<operator>
input:
return ++i

expected:
return ++i

returned:
return++i
2009-10-28 14:23:11 +02:00
Einar Lielmanis
353bed2108 Put a blank line before clean "function ..."
While not perfect, as there are no blank lines before "var x =
function()" and alike, this should slightly help formatting and break up
longer texts.
2009-10-23 09:09:56 +03:00
Einar Lielmanis
223c924f19 Removed wrong comment 2009-10-22 14:18:59 +03:00
Einar Lielmanis
ad9dd90958 Internet explorer fixes
str.charAt(x), not str[x].
2009-10-22 10:06:23 +03:00
Einar Lielmanis
7883b4d823 javascriptobfuscator.com support
...and wrote a tiny testing harness for easier testing.
2009-10-22 09:33:38 +03:00
Einar Lielmanis
796d7647b0 Fixed link to Mozilla Rhino 2009-10-20 15:08:34 +03:00
Einar Lielmanis
bca56b5097 No need to scream the legal shit 2009-09-27 05:57:25 +00:00
Einar Lielmanis
64e9646c18 Allex Wang's fix for else { if handling
if (exp1) {
    // somethings;
} else {
    if (exp2) {
        // somethings else;
    }
}

got borked to:

if (exp1) {
    // somethings;
} else { if (exp2) {
        // somethings else;
    }
}
2009-09-27 05:32:33 +00:00
Einar Lielmanis
aa44676ce9 MIT license. 2009-09-27 04:07:15 +00:00
Einar Lielmanis
65b1df8aed jslint duty 2009-09-18 16:29:16 +03:00
Einar Lielmanis
a933f69787 Newly found bugs fixed 2009-09-18 16:22:41 +03:00
Einar Lielmanis
aa631cea73 Added test wrapper to test for indentation bugs 2009-09-18 16:22:19 +03:00
Einar Lielmanis
80a63b7cfa Fixed array indentation regressions.
Was:

{
    [x()[x]];
indent;
}

Is:

{
    [x()[x]];
    indent;
}
2009-09-18 15:07:46 +03:00
Einar Lielmanis
516d388d4f Fixed indentation bugs caused by array handling 2009-09-17 11:13:09 +03:00
Einar Lielmanis
b2b974fc4a Better multidimensional array handling 2009-09-17 06:54:31 +03:00
Einar Lielmanis
c4ebaa4b6e Typo 2009-09-03 06:08:51 +03:00
Einar Lielmanis
1a7803ec93 jslint happiness 2009-09-03 06:08:46 +03:00
Einar Lielmanis
341283af6b Frontpage tweaks
Minor rewording, addded vim plugin, removed bbedit plugin (it is
somewhat stale).
2009-08-24 12:19:56 +03:00
Einar Lielmanis
ecbd9575bb More array tweaks
[1,2,3,[4,5,6,[7,8,9],10],11,12];

was:

[1, 2, 3,
    [4, 5, 6,
        [7, 8, 9], 10], 11, 12];

is:

[1, 2, 3, [4, 5, 6, [7, 8, 9], 10], 11, 12];
2009-08-21 07:04:26 +03:00