- # Closing open td, tr && table
- while ( count( $td_history ) > 0 ) {
- if ( array_pop( $td_history ) ) {
- $out .= "</td>\n";
+ /**
+ * Helper function for doTableStuff(). This converts the structured array into html.
+ *
+ * @private
+ */
+ function generateTableHTML ( &$table ) {
+ $return = "";
+ $return .= str_repeat( '<dl><dd>' , $table['indent'] );
+ $return .= '<table';
+ $return .= isset( $table['attributes'] ) ? $table['attributes'] : '';
+ $return .= '>';
+ unset( $table['attributes'] );
+
+ if ( isset( $table['caption'] ) ) {
+ $return .= "\n<caption";
+ $return .= isset( $table['caption']['attributes'] ) ? $table['caption']['attributes'] : '';
+ $return .= '>';
+ $return .= $table['caption']['content'];
+ $return .= "\n</caption>";
+ }
+ $lastSection = '';
+ $empty = true;
+ $simple = true;
+
+ // If we only have tbodies, mark table as simple
+ for ( $i = 0; isset( $table[$i] ); $i++ ) {
+ if ( !count( $table[$i] ) ) continue;
+ if ( !isset( $table[$i]['type'] ) ) $table[$i]['type'] = 'tbody';
+ if ( !$lastSection ) {
+ $lastSection = $table[$i]['type'];
+ } else if ( $lastSection != $table[$i]['type'] ) {
+ $simple = false;
+ break;