diff --git a/src/render/MarkdownRenderer.php b/src/render/MarkdownRenderer.php index eca253b..15d5f27 100644 --- a/src/render/MarkdownRenderer.php +++ b/src/render/MarkdownRenderer.php @@ -13,7 +13,7 @@ use type Facebook\Markdown\Blocks\TableExtensionColumnAlignment; use namespace HH\Lib\{C, Math, Str, Vec}; -/** Re-create Markdwon from the AST */ +/** Re-create Markdown from the AST */ class MarkdownRenderer extends Renderer { private ?string $outContext = null; diff --git a/src/unparsed-blocks/TableExtension.php b/src/unparsed-blocks/TableExtension.php index f4ab1cf..0b4fea7 100644 --- a/src/unparsed-blocks/TableExtension.php +++ b/src/unparsed-blocks/TableExtension.php @@ -146,7 +146,8 @@ private static function consumeRow( $parts[] = Str\slice($first, $start); break; } - if ($end >> 1 && $first[$end - 1] === '\\') { + + while ($end !== null && $end > 1 && $first[(int) $end - 1] === '\\') { $end = Str\search($first, '|', $end + 1); } diff --git a/tests/EdgeCaseTest.php b/tests/EdgeCaseTest.php index dbd4e04..5396b90 100644 --- a/tests/EdgeCaseTest.php +++ b/tests/EdgeCaseTest.php @@ -19,6 +19,14 @@ public function getManualExamples( return [ tuple("- foo\n\n", "\n"), tuple("- foo\n\n\n", "\n"), + tuple( + "foo|bar\n---|---\n`\|\|`|herp\n", + "\n\n". + "\n\n\n\n". + "\n\n". + "\n\n\n". + "
foobar
||herp
\n" + ), // Already covered in the spec, but emphasizing here as they // illustrate correct binding for the next problme tuple('**foo*', "

*foo

\n"), @@ -59,7 +67,7 @@ public function testManualExample( 'unnamed', $in, $expected_html, - null, + /* extension = */ 'table', ); }