Page MenuHomePhabricator

D18140.diff
No OneTemporary

D18140.diff

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
--- /dev/null
+++ b/src/markup/engine/__tests__/remarkup/simple-table-with-empty-row.txt
@@ -0,0 +1,13 @@
+| Alpaca |
+| |
+| Zebra |
+~~~~~~~~~~
+<div class="remarkup-table-wrap"><table class="remarkup-table">
+<tr><td>Alpaca</td></tr>
+<tr><td></td></tr>
+<tr><td>Zebra</td></tr>
+</table></div>
+~~~~~~~~~~
+| Alpaca |
+| |
+| Zebra |
diff --git a/src/markup/engine/remarkup/blockrule/PhutilRemarkupSimpleTableBlockRule.php b/src/markup/engine/remarkup/blockrule/PhutilRemarkupSimpleTableBlockRule.php
--- a/src/markup/engine/remarkup/blockrule/PhutilRemarkupSimpleTableBlockRule.php
+++ b/src/markup/engine/remarkup/blockrule/PhutilRemarkupSimpleTableBlockRule.php
@@ -39,19 +39,35 @@
')*'.
')/', $line, $matches);
- $headings = true;
+ $any_header = false;
+ $any_content = false;
+
$cells = array();
foreach ($matches[1] as $cell) {
$cell = trim($cell);
- // Cell isn't empty and doesn't look like heading.
- if (!preg_match('/^(|--+)$/', $cell)) {
- $headings = false;
+ // If this row only has empty cells and "--" cells, and it has at
+ // least one "--" cell, it's marking the rows above as <th> cells
+ // instead of <td> 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.

File Metadata

Mime Type
text/plain
Expires
Mon, May 13, 9:47 PM (2 w, 4 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6277443
Default Alt Text
D18140.diff (2 KB)

Event Timeline