Commit Graph

218 Commits

Author SHA1 Message Date
Einar Lielmanis
bd93ec3bf2 Possibly fix multiplying newline bug (\r) 2010-12-07 01:12:05 +02:00
Einar Lielmanis
4689a09b0b Fix [{foo}] when keep_array_indentation=true
Input:

    [{'a':0}]

Was:

    [{'a':0}
    ]

Is:

    [{
        'a':0
    }]
2010-12-07 01:06:31 +02:00
Einar Lielmanis
61beeabfed Move to static flattr button 2010-12-06 23:07:55 +02:00
Einar Lielmanis
61e96a2a87 WikiLeaks: Paypal can bite my shiny metal ass.
Ditched paypal, moved to moneybookers. Also, added a flattr: I'm very
curious, how will this work out.

Ah, slightly moved the page around. The HTML is nothing to be too proud
of, though.
2010-12-06 21:03:09 +02:00
Einar Lielmanis
3fc0b1a50a Add preserve_max_newlines option
preserve_max_newlines option by Mikkel Bergmann
2010-11-30 18:43:26 +02:00
Einar Lielmanis
d2f5315e4f Fix multiline comment indentation
function foo () {
    /*
     * foo
     */
}

was getting whacked to

function foo () {
/*
    * foo
    */
}
2010-11-18 00:04:33 +02:00
Einar Lielmanis
1799df2bf1 Fix a html-formatter freeze
<a><a> made the beautifier freeze
2010-11-08 12:31:06 +02:00
Einar Lielmanis
5340a2b501 Merge branch 'tilla-master' 2010-10-31 21:13:39 +02:00
tilman
744033a201 changed default behaviour. to read from stdin add option --stdin 2010-10-31 20:06:07 +01:00
tilman
871d4f050d added ability to read from stdin for use with vim autocmd 2010-10-31 09:04:18 +01:00
Ariya Hidayat
10384df62e Option to overwrite the original source file. 2010-10-18 18:09:43 +08:00
Nicolas Ferrero
31c3c10bca v8 version command line support
64bits compilation doc
2010-10-15 01:32:50 +08:00
Nicolas Ferrero
e35f114bed QtScript indent 2010-10-15 01:32:47 +08:00
Nicolas Ferrero
59d7aee4d3 Add command line arguments support to qtscript version 2010-10-14 11:31:12 +08:00
Ariya Hidayat
a52ac9ab7c V8-based runner for the command-line tool. 2010-10-14 11:30:46 +08:00
Ariya Hidayat
da658e8bcc Fix the path to beautify.js. 2010-10-14 02:25:54 +08:00
Ariya Hidayat
c95179a737 Some info on how to built the Qt Script-based driver. 2010-09-21 00:25:52 +08:00
Einar Lielmanis
12c7e8a068 ...cleanup 2010-09-20 13:40:56 +03:00
Einar Lielmanis
537f3b6ae5 Move qtscript to its folder, add small readme 2010-09-20 13:40:16 +03:00
Ariya Hidayat
f3f7075e5e Command-line, Qt-based beautifier driver.
Using built-in ECMA script interpreter in Qt is faster than Rhino...
2010-09-20 18:35:00 +08:00
Nick Fitzgerald
e90447270c Adding support for common js 2010-09-14 11:42:25 -07:00
Jess Thrysoee
68b9648a4f Add install_dir option (-d).
This makes it easy to create a wrapper script that accepts a relative path to
the input javascript file, e.g.:

\\#!/bin/sh
DIR="/path/to/js-beautify/scripts"
java -cp ${DIR}/js.jar org.mozilla.javascript.tools.shell.Main ${DIR}/beautify-cl.js -d ${DIR} -i 3 -n -p -a "$1"
2010-08-22 15:53:54 +08:00
Einar Lielmanis
78b3bf310f Default keep_array_indentation to false
...as in jsbeautifier.org.
2010-08-13 15:14:03 +03:00
Einar Lielmanis
bebfb370f6 Fix hugely ugly regression
Ternary statements made the whole {block} to be treated like 'OBJECT',
leading to a terrible uglineess.
2010-08-07 02:04:14 +03:00
Einar Lielmanis
7dca71d9e6 Whitespace changes 2010-08-07 01:49:54 +03:00
Einar Lielmanis
868cf0ecea Indent var line variables one under another.
Even if a 2-space indentation enabled, this:

var a = 1, b = 2

gets indented to:

var a = 1,
    b = 2

Was:

var a = 1,
  b = 2
2010-07-31 22:06:55 +03:00
Einar Lielmanis
3c45cd9e5d Objects now look nearly wonderful.
Added a flags.mode = OBJECT, when in a BLOCK (enclosed by {....})
a colon is met, and now object definitions look much prettier, i
hope.
2010-07-07 01:15:59 +03:00
Einar Lielmanis
3c2b960df4 last_mode / flags.previous_mode leftover cleanup 2010-07-06 23:44:19 +03:00
Einar Lielmanis
2366cd7069 Additional array tests as per last commit 2010-07-06 23:41:25 +03:00
Einar Lielmanis
319232b698 Cleaner array formatting
{ "x" : [ { "a" : 1, "b" : 3 }, 7, { "b" : 99 }, { "a" : 11 } ] }

Was getting formatted to:

{
    "x": [{
        "a": 1,
        "b": 3
    }, 7, {
        "b": 99
    }, {
        "a": 11
    }]
}

Now it formats to:

{
    "x": [{
        "a": 1,
        "b": 3
    },
    7,
    {
        "b": 99
    },
    {
        "a": 11
    }]
}
2010-07-06 23:30:29 +03:00
Einar Lielmanis
9999237859 Whitespace cleanup 2010-07-06 23:30:17 +03:00
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