diff --git a/src/markup/engine/__tests__/remarkup/newline-then-block.txt b/src/markup/engine/__tests__/remarkup/newline-then-block.txt
index 3a84aa4..159e7c9 100644
--- a/src/markup/engine/__tests__/remarkup/newline-then-block.txt
+++ b/src/markup/engine/__tests__/remarkup/newline-then-block.txt
@@ -1,30 +1,30 @@
This is a paragraph.
lang=txt
First line of code block.
Second line of code block.
~~~~~~~~~~
This is a paragraph.
-
~~~~~~~~~~
This is a paragraph.
First line of code block.
Second line of code block.
| Cell 1 | Cell 2 |
diff --git a/src/markup/engine/__tests__/remarkup/simple-table-with-link.txt b/src/markup/engine/__tests__/remarkup/simple-table-with-link.txt
index da07098..d4e53b3 100644
--- a/src/markup/engine/__tests__/remarkup/simple-table-with-link.txt
+++ b/src/markup/engine/__tests__/remarkup/simple-table-with-link.txt
@@ -1,7 +1,7 @@
| [[ http://example.com | name ]] | [x] |
~~~~~~~~~~
-
~~~~~~~~~~
| name | [x] |
diff --git a/src/markup/engine/__tests__/remarkup/simple-table.txt b/src/markup/engine/__tests__/remarkup/simple-table.txt
index b8d9e53..d86a818 100644
--- a/src/markup/engine/__tests__/remarkup/simple-table.txt
+++ b/src/markup/engine/__tests__/remarkup/simple-table.txt
@@ -1,24 +1,24 @@
| analyze_resources | original | mobile only | www only | both |
| | -------- | ----------- | -------- | ---- |
| //real// | 31 s | 24 s | 31 s | 31 s
| --------
| //user// | 49 s | 25 s | 31 s | 49 s
| --------
| //sys// | 24 s | 12 s | 13 s | 24 s
| -------
~~~~~~~~~~
-
~~~~~~~~~~
| analyze_resources | original | mobile only | www only | both |
| | -------- | ----------- | -------- | ---- |
| //real// | 31 s | 24 s | 31 s | 31 s |
| ----------------- | | | | |
| //user// | 49 s | 25 s | 31 s | 49 s |
| ----------------- | | | | |
| //sys// | 24 s | 12 s | 13 s | 24 s |
| ----------------- | | | | |
diff --git a/src/markup/engine/__tests__/remarkup/table.txt b/src/markup/engine/__tests__/remarkup/table.txt
index 33a462d..6a3afe5 100644
--- a/src/markup/engine/__tests__/remarkup/table.txt
+++ b/src/markup/engine/__tests__/remarkup/table.txt
@@ -1,16 +1,16 @@
Table | Storage |
`differential_diff` | InnoDB |
`edge` | ? |
~~~~~~~~~~
-
~~~~~~~~~~
| Table | Storage |
| ------------------- | ------- |
| `differential_diff` | InnoDB |
| `edge` | ? |
diff --git a/src/markup/engine/remarkup/blockrule/PhutilRemarkupBlockRule.php b/src/markup/engine/remarkup/blockrule/PhutilRemarkupBlockRule.php
index dc6a495..5210811 100644
--- a/src/markup/engine/remarkup/blockrule/PhutilRemarkupBlockRule.php
+++ b/src/markup/engine/remarkup/blockrule/PhutilRemarkupBlockRule.php
@@ -1,163 +1,164 @@
engine = $engine;
$this->updateRules();
return $this;
}
final protected function getEngine() {
return $this->engine;
}
public function setMarkupRules(array $rules) {
assert_instances_of($rules, 'PhutilRemarkupRule');
$this->rules = $rules;
$this->updateRules();
return $this;
}
private function updateRules() {
$engine = $this->getEngine();
if ($engine) {
$this->rules = msort($this->rules, 'getPriority');
foreach ($this->rules as $rule) {
$rule->setEngine($engine);
}
}
return $this;
}
final public function getMarkupRules() {
return $this->rules;
}
final public function postprocess() {
$this->didMarkupText();
}
final protected function applyRules($text) {
foreach ($this->getMarkupRules() as $rule) {
$text = $rule->apply($text);
}
return $text;
}
public function supportsChildBlocks() {
return false;
}
public function extractChildText($text) {
throw new PhutilMethodNotImplementedException();
}
protected function renderRemarkupTable(array $out_rows) {
assert_instances_of($out_rows, 'array');
if ($this->getEngine()->isTextMode()) {
$lengths = array();
foreach ($out_rows as $r => $row) {
foreach ($row['content'] as $c => $cell) {
$text = $this->getEngine()->restoreText($cell['content']);
$lengths[$c][$r] = phutil_utf8_strlen($text);
}
}
$max_lengths = array_map('max', $lengths);
$out = array();
foreach ($out_rows as $r => $row) {
$headings = false;
foreach ($row['content'] as $c => $cell) {
$length = $max_lengths[$c] - $lengths[$c][$r];
$out[] = '| '.$cell['content'].str_repeat(' ', $length).' ';
if ($cell['type'] == 'th') {
$headings = true;
}
}
$out[] = "|\n";
if ($headings) {
foreach ($row['content'] as $c => $cell) {
$char = ($cell['type'] == 'th' ? '-' : ' ');
$out[] = '| '.str_repeat($char, $max_lengths[$c]).' ';
}
$out[] = "|\n";
}
}
return rtrim(implode('', $out), "\n");
}
if ($this->getEngine()->isHTMLMailMode()) {
$table_attributes = array(
'style' => 'border-collapse: separate;
border-spacing: 1px;
background: #d3d3d3;
margin: 12px 0;',
);
$cell_attributes = array(
'style' => 'background: #ffffff;
padding: 3px 6px;',
);
} else {
$table_attributes = array(
'class' => 'remarkup-table',
);
$cell_attributes = array();
}
$out = array();
$out[] = "\n";
foreach ($out_rows as $row) {
$cells = array();
foreach ($row['content'] as $cell) {
$cells[] = phutil_tag(
$cell['type'],
$cell_attributes,
$cell['content']);
}
$out[] = phutil_tag($row['type'], array(), $cells);
$out[] = "\n";
}
- return phutil_tag('table', $table_attributes, $out);
+ $table = phutil_tag('table', $table_attributes, $out);
+ return phutil_tag_div('remarkup-table-wrap', $table);
}
}