Improve whitespace normalization for parser tests.

Output like: `<p>a\nb\nc</p>` should be normalized to `<p>a b c</p>` not
`<p>abc</p>`.  Used a DOM-based routine to normalize whitespace around
tags, instead of the ad-hoc regexp method.  The rest of the regexps
in the normalizeHTML and normalizeOut functions should probably be
switched over to DOM-based methods eventually as well.

Had to fix a number of test cases which contained bogus whitespace which
was hidden by the old over-agressive normalization.

Exposed the following new legit bugs:

* The wt2html test case "<pre> with <nowiki> inside (compatibility
with 1.6 and earlier)" begins `<pre><nowiki>\nX` which the PHP parser
translates to `<pre>\nX` and then the HTML parser spec says this is
equivalent to `<pre>X` (the leading newline is removed).  Parsoid
generates `<pre><span typeof="mw:Nowiki">\nX` which protects the
newline inside the span.  Parsoid thus outputs an extra newline in
this case.  We should probably suppress the leading newline here.

* The html2html test case "5a. White-space in indent-pre" appears to
add an extra newline inside the `<pre>` during the round-trip.

* The wt2html test case "Bug 2702: Mismatched <i>, <b> and <a> tags
are invalid" begins with `''[http://example.com text'']`.  PHP emits
`<p><a><i>` for this while Parsoid emits `<p><i><a>`.  This is bug
63143 and it's been around for a while; I don't know why it is showing
up as a new regression.

* The html2html test case "Includes and comments at SOL" fails.  WTS
appears to move a `</p>` tag inside of the `<noinclude>` block.

* The html2html test case "Parsoid: Link prefix/suffixes aren't
applied to category links" fails.  WTS adds extraneous newlines
around the category tag.  For example:
```
$ echo '<p>x<link rel="mw:PageProp/Category" href="Category:Foo">y</p>' | tests/parse.js --html2wt
x
[[Category:Foo]]
y
```

Bug: 55588
Change-Id: Ibf511baf91fdb2d8c612e3adbbe1c61c08247eef