From 56a81257a1f9feacef72ff10e23956d76d8b17ff Mon Sep 17 00:00:00 2001 From: Edward Zhang Date: Thu, 18 Aug 2016 22:31:05 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=8C=B9=E9=85=8D=E8=A1=A8?= =?UTF-8?q?=E6=A0=BC=E6=A0=BC=E5=BC=8F=E7=9A=84=E6=AD=A3=E5=88=99=E8=A1=A8?= =?UTF-8?q?=E8=BE=BE=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修改前的正则匹配不了 |-|-| 这种表格样式, 修改后的正则更通用一点,可以匹配以下样式: |-|-|,-|-|-,|-|-,-|-|等全部都可以正确识别 包含对齐操作的表格标记也全部正常~~ --- Parser.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Parser.php b/Parser.php index 5c4d632..c4752c8 100644 --- a/Parser.php +++ b/Parser.php @@ -608,7 +608,7 @@ private function parseBlock($text, &$lines) break; // table - case preg_match("/^((?:(?:(?:[ :]*\-[ :]*)+(?:\||\+))|(?:(?:\||\+)(?:[ :]*\-[ :]*)+)|(?:(?:[ :]*\-[ :]*)+(?:\||\+)(?:[ :]*\-[ :]*)+))+)$/", $line, $matches): + case preg_match("/^[\|\+]?((?::?\-+:?[\|\+])+(?:\s*:?\-+:?\s*)?)$/", $line, $matches): if ($this->isBlock('table')) { $block[3][0][] = $block[3][2]; $block[3][2] ++;