diff --git a/src/markup/engine/__tests__/remarkup/simple-table-with-empty-row.txt b/src/markup/engine/__tests__/remarkup/simple-table-with-empty-row.txt
new file mode 100644
index 0000000..40c27ca
--- /dev/null
+++ b/src/markup/engine/__tests__/remarkup/simple-table-with-empty-row.txt
@@ -0,0 +1,13 @@
+| Alpaca |
+| |
+| Zebra |
+~~~~~~~~~~
+
+~~~~~~~~~~
+| Alpaca |
+| |
+| Zebra |
diff --git a/src/markup/engine/remarkup/blockrule/PhutilRemarkupSimpleTableBlockRule.php b/src/markup/engine/remarkup/blockrule/PhutilRemarkupSimpleTableBlockRule.php
index 474a18a..58ad3d5 100644
--- a/src/markup/engine/remarkup/blockrule/PhutilRemarkupSimpleTableBlockRule.php
+++ b/src/markup/engine/remarkup/blockrule/PhutilRemarkupSimpleTableBlockRule.php
@@ -1,73 +1,89 @@
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));
}
- if (!$headings) {
+ $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']) {
$rows[last_key($rows)]['content'][$i]['type'] = 'th';
}
}
}
}
if (!$rows) {
return $this->applyRules($text);
}
return $this->renderRemarkupTable($rows);
}
}
|