Class HTMLPurifier_ChildDef_Table

InheritanceHTMLPurifier_ChildDef_Table » HTMLPurifier_ChildDef

Definition for tables. The general idea is to extract out all of the essential bits, and then reconstruct it later.

This is a bit confusing, because the DTDs and the W3C validators seem to disagree on the appropriate definition. The DTD claims:


But actually, the HTML4 spec then has this to say:

 The TBODY start tag is always required except when the table
 contains only one table body and no table head or foot sections.
 The TBODY end tag may always be safely omitted.

So the DTD is kind of wrong. The validator is, unfortunately, kind of on crack.

The definition changed again in XHTML1.1; and in my opinion, this formulation makes the most sense.

 caption?, ( col* | colgroup* ), (( thead?, tfoot?, tbody+ ) | ( tr+ ))

Essentially, we have two modes: thead/tfoot/tbody mode, and tr mode. If we encounter a thead, tfoot or tbody, we are placed in the former mode, and we must wrap any stray tr segments with a tbody. But if we don't run into any of them, just have tr tags is OK.

Public Methods

Hide inherited methods

MethodDescriptionDefined By
__construct() HTMLPurifier_ChildDef_Table
getAllowedElements() Get lookup of tag names that should not close this element automatically. HTMLPurifier_ChildDef
validateChildren() HTMLPurifier_ChildDef_Table

Property Details

$allow_empty public property
public $allow_empty false
$elements public property
public $elements = ['tr' => true'tbody' => true'thead' => true'tfoot' => true'caption' => true'colgroup' => true'col' => true]
$type public property
public $type 'table'

Method Details

__construct() public method

public void __construct ( )
validateChildren() public method

public array validateChildren ( $children, $config, $context )
$children array
$config HTMLPurifier_Config
$context HTMLPurifier_Context