diff --git a/Parsedown.php b/Parsedown.php index 2a02376..adcd84e 100755 --- a/Parsedown.php +++ b/Parsedown.php @@ -905,11 +905,12 @@ class Parsedown $row = trim($row); $row = trim($row, '|'); - $cells = explode('|', $row); + preg_match_all('/(?:(\\\\[|])|[^|`]|`[^`]+`|`)+/', $row, $matches); - foreach ($cells as $index => $cell) + foreach ($matches[0] as $index => $cell) { $cell = trim($cell); + $cell = str_replace('\|', '|', $cell); $Element = array( 'name' => 'td', diff --git a/test/data/table_inline_markdown.html b/test/data/table_inline_markdown.html index 53d0eb8..4fa2e2b 100644 --- a/test/data/table_inline_markdown.html +++ b/test/data/table_inline_markdown.html @@ -11,8 +11,8 @@ cell 1.2 -cell 2.1 -cell 2.2 +| 2.1 +| 2.2 \ No newline at end of file diff --git a/test/data/table_inline_markdown.md b/test/data/table_inline_markdown.md index c2fe108..ef04ce1 100644 --- a/test/data/table_inline_markdown.md +++ b/test/data/table_inline_markdown.md @@ -1,4 +1,4 @@ | _header_ 1 | header 2 | | ------------ | ------------ | | _cell_ 1.1 | ~~cell~~ 1.2 | -| `cell` 2.1 | cell 2.2 | \ No newline at end of file +| `|` 2.1 | \| 2.2 | \ No newline at end of file