Bug 50603, 44498: Handle templates straddling cell attributes & content

This patch adds a DOM visitor to fix up content like

{|
|{{nom|Bar}}
|title="foo" {{nom|Bar}}
|}

where {{nom|Bar}} expands to attributes and a table cell, for example

style="foo" class="bar"|Bar

The attributes are re-tokenized and stripped from the table contents. The
template encapsulation metadata is moved to the table cell and updated.

This implementation renders and round-trips the templates documented in
- https://en.wikipedia.org/wiki/Template:Table_cell_templates/doc
- http://en.wikipedia.org/wiki/User:Nicolas1981/Sandbox (from bug 44498)

Nevertheless, there are some limitations:
- We assume that attributes don't contain wiki markup (apart from <nowiki>)
  and end up in text or nowiki nodes.

- Only a single table cell is produced / opened by the template that
  contains the attributes. This limitation could be lifted with more
  aggressive re-parsing if really needed in practice.

- There is only a single transclusion in the table cell content. This
  limitation can be lifted with more advanced data-mw construction.

Bug: 50603
Bug: 44498

Change-Id: Ibbd16952784be6768622ed6df65d3475d2c37e91
Merge "Bug 50603, 44498: Handle templates straddling cell attributes & content"