cells
// instead of
cells.
// If it has other types of cells, it's always a content row.
// If it has only empty cells, it's an empty row.
if (strlen($cell)) {
if (preg_match('/^--+\z/', $cell)) {
$any_header = true;
} else {
$any_content = true;
}
}
$cells[] = array('type' => 'td', 'content' => $this->applyRules($cell));
}
$is_header = ($any_header && !$any_content);
if (!$is_header) {
$rows[] = array('type' => 'tr', 'content' => $cells);
} else if ($rows) {
// Mark previous row with headings.
foreach ($cells as $i => $cell) {
if ($cell['content']) {
$last_key = last_key($rows);
if (!isset($rows[$last_key]['content'][$i])) {
// If this row has more cells than the previous row, there may
// not be a cell above this one to turn into a | | .
continue;
}
$rows[$last_key]['content'][$i]['type'] = 'th';
}
}
}
}
if (!$rows) {
return $this->applyRules($text);
}
return $this->renderRemarkupTable($rows);
}
}