Skip to content

Commit f5f44f3

Browse files
author
epriestley
committed
Allow Remarkup tables to have leading space so they work correctly with quoting
Summary: Fixes T10570. Test Plan: {F1172098} Reviewers: chad Reviewed By: chad Maniphest Tasks: T10570 Differential Revision: https://secure.phabricator.com/D15466
1 parent 7e2eca1 commit f5f44f3

File tree

4 files changed

+17
-3
lines changed

4 files changed

+17
-3
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
|a|b|
2+
~~~~~~~~~~
3+
<div class="remarkup-table-wrap"><table class="remarkup-table">
4+
<tr><td>a</td><td>b</td></tr>
5+
</table></div>
6+
~~~~~~~~~~
7+
| a | b |
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<table><tr><td>cell</td></tr></table>
2+
~~~~~~~~~~
3+
<div class="remarkup-table-wrap"><table class="remarkup-table">
4+
<tr><td>cell</td></tr>
5+
</table></div>
6+
~~~~~~~~~~
7+
| cell |

src/markup/engine/remarkup/blockrule/PhutilRemarkupSimpleTableBlockRule.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ final class PhutilRemarkupSimpleTableBlockRule extends PhutilRemarkupBlockRule {
55
public function getMatchingLineCount(array $lines, $cursor) {
66
$num_lines = 0;
77
while (isset($lines[$cursor])) {
8-
if (preg_match('/^(\|.*+\n?)+$/', $lines[$cursor])) {
8+
if (preg_match('/^(\s*\|.*+\n?)+$/', $lines[$cursor])) {
99
$num_lines++;
1010
$cursor++;
1111
} else {

src/markup/engine/remarkup/blockrule/PhutilRemarkupTableBlockRule.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ final class PhutilRemarkupTableBlockRule extends PhutilRemarkupBlockRule {
55
public function getMatchingLineCount(array $lines, $cursor) {
66
$num_lines = 0;
77

8-
if (preg_match('/^<table>/i', $lines[$cursor])) {
8+
if (preg_match('/^\s*<table>/i', $lines[$cursor])) {
99
$num_lines++;
1010
$cursor++;
1111

@@ -24,7 +24,7 @@ public function getMatchingLineCount(array $lines, $cursor) {
2424
public function markupText($text, $children) {
2525
$matches = array();
2626

27-
if (!preg_match('@^<table>(.*)</table>$@si', $text, $matches)) {
27+
if (!preg_match('@^\s*<table>(.*)</table>$@si', $text, $matches)) {
2828
return $this->fail(
2929
$text,
3030
pht('Bad table (expected %s)', '<table>...</table>'));

0 commit comments

Comments
 (0)