WTS: Fixes to wikitext escaping for wt tag pairs (headings & links)

* Previous code was accummulating all text that might get output
  as part of a single line and using that to determine if
  "=" and [" chars needing to be escaped.  However, that
  code felt a little convoluted, especially after the rewrite of
  WTS to be entirely DOM-based.

* Fixed the escaping to accummulate text on a line after it is output
  and use that to decide escaping strategies for "=", "[", "]" chars.

* This now changes serialized wikitext output.
  HTML: <h1>=foo''a''=</h1> ==> WT: ==foo''a''<nowiki>=</nowiki>=

  Earlier, this used to be
  HTML: <h1>=foo''a''=</h1> ==> WT: =<nowiki>=foo</nowiki>''a''==

  Similarly, escaping of "]" and "[" chars has changed.

* Based on the change, parserTests.txt need updating, but updated
  our local copy of wt_escape.tests.txt that I often use when testing
  wikitext escaping. The fixes exposed some bugs in older code.

  1. <h1>=</h1> was being serialized to "===" earlier which is buggy.

  2. <a href="Foo" rel="mw:WikiLink">x [Foobar] x</a> was being
     serialized to [[Foo|<nowiki> x [Foobar] x</nowiki>]] but the
     nowiki-escaping was unnecessary.

  3. <p>]]bar <span>[[foo]]</span></p> serialization led to "]]bar"
     being nowiki-escaped which was unnecessary.

  4. [[Foo|x [http://google.com] x]] is parsed incorrectly compared to
     the PHP parser that doesn't convert [http://google.com] to a link.
     Currently, the wikitext escaping code does not escape the link-like
     text in the middle, which can lead to failures since Parsoid
     converts the text in the middle to a link.  What is the right fix
     here?

* Fixed in a bug in 'wikilinkHandler' that was not escaping text in
  this (and similar) examples: <a rel="mw:WikiLink" href="Foo">]]bar</a>

  Updated wt_escaping tests with these new tests.

* Parser tests results:
  - 2 more wt2wt tests passing
  - 1 more html2html test passing
  - 20 more selser tests passing

  - 6 *fewer* html2wt tests passing, but this is because of the
    change in expect serialized output as explained above. Once
    parserTests.txt is fixed, this number will go back up.

* Blacklist file updated accordingly.

Change-Id: Ib784416f00c1fd23d41ce0c7c7d21b675d981e86
Merge "WTS: Fixes to wikitext escaping for wt tag pairs (headings & links)"