facebook/react — pull request #970 by syranide (2014-01-24 22:48:11+00:00)
Title: Normalize whitespace for transformed JSX code

It currently generates "pretty output" as we agreed upon, it respects original indenting all that, newlines are kept as-is. It also puts `{}` at just after/before the outer `()`.

There is only one case that I know of currently that produces incorrect output and that is when the attribute name and value are on different lines (see below), I could fix it, but I don't think it's worth the code complexity for something you really shouldn't do, but I could fix it.

I back-tracked on removing trailing spaces after commas, it's not super hard to do, but it's a bit of messy to sort out and I don't find it worthwhile right now. I'll leave it for another PR for now.

PS. There's a also a bunch of source code lines that got trimmed now that I'm using a better editor (I unintentionally added them with my previous whitespace PR). So that's why there's a bunch of weird "empty" changes below.

```

< div>{0} A B {1} {2}

A

A

{0}A{1}B{2}C { D
}E

A

B

{1}

{2}

awdawdawd
awdawdawd

```

Produces:

```
React.DOM.div(null,
React.DOM.div(null, " "), React.DOM.div(null),
React.DOM.div(null, 0, " A B ", 1, " ", 2),
React.DOM.div(null, " A "),
React.DOM.div(null,
"A"
),
React.DOM.div({

a:

"a",

b:
"b",

c:
"c"
}),
React.DOM.div({a: "A", b: "B"}),
React.DOM.div({a: "A"}),
React.DOM.div({a: "b", c: "d"}),
React.DOM.div({
a: "A",
b: "B",

c: "C"

}),
React.DOM.div({id: "test"
},

0, "A", 1, "B", 2, "C ", D,
"E" + ' ' +

"A" + ' ' +

"B",

1,

2,

"awdawdawd" + ' ' +
"awdawdawd"

)
)
```