Differential D18751 Diff 45011 src/markup/engine/remarkup/blockrule/PhutilRemarkupSimpleTableBlockRule.php
Changeset View
Changeset View
Standalone View
Standalone View
src/markup/engine/remarkup/blockrule/PhutilRemarkupSimpleTableBlockRule.php
Show First 20 Lines • Show All 67 Lines • ▼ Show 20 Lines | foreach (explode("\n", $text) as $line) { | ||||
$is_header = ($any_header && !$any_content); | $is_header = ($any_header && !$any_content); | ||||
if (!$is_header) { | if (!$is_header) { | ||||
$rows[] = array('type' => 'tr', 'content' => $cells); | $rows[] = array('type' => 'tr', 'content' => $cells); | ||||
} else if ($rows) { | } else if ($rows) { | ||||
// Mark previous row with headings. | // Mark previous row with headings. | ||||
foreach ($cells as $i => $cell) { | foreach ($cells as $i => $cell) { | ||||
if ($cell['content']) { | if ($cell['content']) { | ||||
$rows[last_key($rows)]['content'][$i]['type'] = 'th'; | $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 <th />. | |||||
continue; | |||||
} | |||||
$rows[$last_key]['content'][$i]['type'] = 'th'; | |||||
} | } | ||||
} | } | ||||
} | } | ||||
} | } | ||||
if (!$rows) { | if (!$rows) { | ||||
return $this->applyRules($text); | return $this->applyRules($text); | ||||
} | } | ||||
return $this->renderRemarkupTable($rows); | return $this->renderRemarkupTable($rows); | ||||
} | } | ||||
} | } |