From 20e592359f5fb1c902160a1dc79b48b8155c2f10 Mon Sep 17 00:00:00 2001 From: Aidan Woods Date: Fri, 30 Mar 2018 19:22:13 +0100 Subject: [PATCH 1/2] Add failing test case --- test/data/html_comment.html | 8 +++++++- test/data/html_comment.md | 8 +++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/test/data/html_comment.html b/test/data/html_comment.html index 566dc3a..009c309 100644 --- a/test/data/html_comment.html +++ b/test/data/html_comment.html @@ -2,4 +2,10 @@

paragraph

-

paragraph

\ No newline at end of file +

paragraph

+abc + \ No newline at end of file diff --git a/test/data/html_comment.md b/test/data/html_comment.md index 6ddfdb4..27aeb29 100644 --- a/test/data/html_comment.md +++ b/test/data/html_comment.md @@ -5,4 +5,10 @@ paragraph -paragraph \ No newline at end of file +paragraph + +abc + +* abcd +* bbbb +* cccc \ No newline at end of file From aa90dd481ae5f65e461078fe18e77b1d964caaf1 Mon Sep 17 00:00:00 2001 From: Aidan Woods Date: Fri, 30 Mar 2018 19:22:50 +0100 Subject: [PATCH 2/2] Match CommonMark spec on HTML comments: Start condition: line begins with the string ``. --- Parsedown.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Parsedown.php b/Parsedown.php index 5ca40d8..0313408 100644 --- a/Parsedown.php +++ b/Parsedown.php @@ -383,13 +383,13 @@ class Parsedown return; } - if (isset($Line['text'][3]) and $Line['text'][3] === '-' and $Line['text'][2] === '-' and $Line['text'][1] === '!') + if (strpos($Line['text'], '$/', $Line['text'])) + if (strpos($Line['text'], '-->') !== false) { $Block['closed'] = true; } @@ -407,7 +407,7 @@ class Parsedown $Block['element']['rawHtml'] .= "\n" . $Line['body']; - if (preg_match('/-->$/', $Line['text'])) + if (strpos($Line['text'], '-->') !== false) { $Block['closed'] = true; }