From 6bee326c9201bfe87423a44d0bd9ebc4b7b64638 Mon Sep 17 00:00:00 2001 From: Emanuil Rusev Date: Thu, 15 Jan 2015 21:09:52 +0200 Subject: [PATCH] resolve #184 --- Parsedown.php | 5 +++-- test/data/table_inline_markdown.html | 4 ++-- test/data/table_inline_markdown.md | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) 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