Class: TableFixups

wt2html/pp/handlers/tableFixups~TableFixups()

new TableFixups()

TableFixups class.

TableFixups class.

Provides two DOMTraverser visitors that implement the two parts of https://phabricator.wikimedia.org/T52603 T52603} :

  • stripDoubleTDs
  • reparseTemplatedAttributes.
Source:

Members

tokenizer

Actually the regular tokenizer, but we'll use tokenizeTableCellAttributes only.

Actually the regular tokenizer, but we'll use tokenizeTableCellAttributes only.

Source:

Methods

collectAttributishContent()

Collect potential attribute content.

Collect potential attribute content.

We expect this to be text nodes without a pipe character followed by one or more nowiki spans, followed by a template encapsulation with pure-text and nowiki content. Collection stops when encountering other nodes or a pipe character.

Source:

reparseTemplatedAttributes()

T46498, second part of T52603

Handle wikitext like

{|
|{{nom|Bar}}
|}

where nom expands to style="foo" class="bar"|Bar.

T46498, second part of T52603

Handle wikitext like

{|
|{{nom|Bar}}
|}

where nom expands to style="foo" class="bar"|Bar. The attributes are tokenized and stripped from the table contents.

This method works well for the templates documented in https://en.wikipedia.org/wiki/Template:Table_cell_templates/doc

Nevertheless, there are some limitations:

  • We assume that attributes don't contain wiki markup (apart from ) 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.
Source:

stripDoubleTDs()

DOM visitor that strips the double td for this test case:

|{{echo|{{!}} Foo}}
.

DOM visitor that strips the double td for this test case:

|{{echo|{{!}} Foo}}
Source:
See: