einars/js-beautify — pull request #217 by eleith (2013-03-29 11:39:11+00:00)
Title: only format if a tag comes back when peeking

this patch addresses the following problem where

```html
[beautify js and more]
```

gets formatted as

```html
[
beautify itjs and more]
```

you'll notice that before the <a> there is a newline and after the <a> a space is removed.

this happens because get_tag() when peeking (in order to support HTML5 A block mode) returns beautify it<a> and sets that value to next_tag.

thus, this.Utils.in_array(next_tag, unformatted) will now return false, causing the entire <a> code block to be treated as a formatted tag (even though by default <a> is an unformatted tag).

this patch now inspects next_tag properly. if it comes back as a valid HTML tag, then it respects the unformatted rules, otherwise if a non HTML tag (ex: text content) comes back, then it gets treated as as unformatted block.

with this change, it preserves spacing and the above example will properly return

```html
[beautify js and more]
```

after being parsed. since the test framework does not seem to support HTML beautification, i did not submit tests with this PR.