From 2da10d277b086372f17b96df6cdc903829e1dde0 Mon Sep 17 00:00:00 2001 From: Emanuil Rusev Date: Wed, 14 May 2014 13:14:49 +0300 Subject: [PATCH] resolve #105 --- Parsedown.php | 39 ++++++++++++++++++++++++++++++++++++- test/data/HTML_Comment.html | 5 +++++ test/data/HTML_Comment.md | 8 ++++++++ 3 files changed, 51 insertions(+), 1 deletion(-) create mode 100644 test/data/HTML_Comment.html create mode 100644 test/data/HTML_Comment.md diff --git a/Parsedown.php b/Parsedown.php index 05069af..92f3dd8 100755 --- a/Parsedown.php +++ b/Parsedown.php @@ -87,7 +87,7 @@ class Parsedown '8' => array('List'), '9' => array('List'), ':' => array('Table'), - '<' => array('Markup'), + '<' => array('Comment', 'Markup'), '=' => array('Setext'), '>' => array('Quote'), '_' => array('Rule'), @@ -346,6 +346,43 @@ class Parsedown return $Block; } + # + # Comment + + protected function identifyComment($Line) + { + if (isset($Line['text'][3]) and $Line['text'][3] === '-' and $Line['text'][2] === '-' and $Line['text'][1] === '!') + { + $Block = array( + 'element' => $Line['body'], + ); + + if (preg_match('/-->$/', $Line['text'])) + { + $Block['closed'] = true; + } + + return $Block; + } + } + + protected function addToComment($Line, array $Block) + { + if (isset($Block['closed'])) + { + return; + } + + $Block['element'] .= "\n" . $Line['body']; + + if (preg_match('/-->$/', $Line['text'])) + { + $Block['closed'] = true; + } + + return $Block; + } + # # Fenced Code diff --git a/test/data/HTML_Comment.html b/test/data/HTML_Comment.html new file mode 100644 index 0000000..566dc3a --- /dev/null +++ b/test/data/HTML_Comment.html @@ -0,0 +1,5 @@ + +

paragraph

+ +

paragraph

\ No newline at end of file diff --git a/test/data/HTML_Comment.md b/test/data/HTML_Comment.md new file mode 100644 index 0000000..6ddfdb4 --- /dev/null +++ b/test/data/HTML_Comment.md @@ -0,0 +1,8 @@ + + +paragraph + + + +paragraph \ No newline at end of file