Parsoid
A bidirectional parser between wikitext and HTML5
Loading...
Searching...
No Matches
Wikimedia\Parsoid\Wt2Html\DOM\Handlers\TableFixups Class Reference

Provides DOMTraverser visitors that fix template-induced interrupted table cell parsing by recombining table cells and/or reparsing table cell content as attributes. More...

Static Public Member Functions

static reparseTemplatedAttributes (DTState $dtState, Element $cell, ?Element $templateWrapper)
 T46498, second part of T52603.
 

Detailed Description

Provides DOMTraverser visitors that fix template-induced interrupted table cell parsing by recombining table cells and/or reparsing table cell content as attributes.

  • handleTableCellTemplates

Member Function Documentation

◆ reparseTemplatedAttributes()

static Wikimedia\Parsoid\Wt2Html\DOM\Handlers\TableFixups::reparseTemplatedAttributes ( DTState $dtState,
Element $cell,
?Element $templateWrapper )
static

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 <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.

$cell known to be

/

FIXME: These checks are insufficient. Previous rounds of table fixups might have created this cell without any templated content (the while loop in handleTableCellTemplates). Till we figure out a reliable test for this, we'll reparse attributes always.

// This DOM pass is trying to bridge broken parses across // template boundaries. So, if templates aren't involved, // no reason to reparse. if ( count( $attributishContent['transclusions'] ) === 0 && !WTUtils::fromEncapsulatedContent( $cell ) ) { return; }


The documentation for this class was generated from the following file: