From 194c916c6a915e787a9c4e254f921bdae0a74ef6 Mon Sep 17 00:00:00 2001 From: Aidan Woods Date: Sun, 20 Jan 2019 02:26:03 +0000 Subject: [PATCH] Implement Comment --- src/Components/Blocks/Comment.php | 89 +++++++++++++++++++++++++++++++ src/Parsedown.php | 40 -------------- 2 files changed, 89 insertions(+), 40 deletions(-) create mode 100644 src/Components/Blocks/Comment.php diff --git a/src/Components/Blocks/Comment.php b/src/Components/Blocks/Comment.php new file mode 100644 index 0000000..306b763 --- /dev/null +++ b/src/Components/Blocks/Comment.php @@ -0,0 +1,89 @@ +html = $html; + $this->isClosed = $isClosed; + } + + /** + * @param Context $Context + * @param Block|null $Block + * @param State|null $State + * @return static|null + */ + public static function build( + Context $Context, + Block $Block = null, + State $State = null + ) { + if (\strpos($Context->line()->text(), '') !== false + ); + } + + return null; + } + + /** + * @param Context $Context + * @return self|null + */ + public function continue(Context $Context) + { + if ($this->isClosed) { + return null; + } + + return new self( + $this->html . "\n" . $Context->line()->rawLine(), + \strpos($Context->line()->text(), '-->') !== false + ); + } + + /** + * @return Handler + */ + public function stateRenderable(Parsedown $Parsedown) + { + return new Handler( + /** @return Text|RawHtml */ + function (State $State) { + if ($State->getOrDefault(SafeMode::class)->enabled()) { + return new Text($this->html); + } else { + return new RawHtml($this->html); + } + } + ); + } +} diff --git a/src/Parsedown.php b/src/Parsedown.php index 2ff2eae..9bab78d 100644 --- a/src/Parsedown.php +++ b/src/Parsedown.php @@ -334,46 +334,6 @@ class Parsedown return $Block; } - # - # Comment - - protected function blockComment(Context $Context) - { - if ($this->markupEscaped or $this->safeMode) { - return; - } - - if (\strpos($Context->line()->text(), '') !== false) { - $Block['closed'] = true; - } - - return $Block; - } - } - - protected function blockCommentContinue(Context $Context, array $Block) - { - if (isset($Block['closed'])) { - return; - } - - $Block['element']['rawHtml'] .= "\n" . $Context->line()->rawLine(); - - if (\strpos($Context->line()->text(), '-->') !== false) { - $Block['closed'] = true; - } - - return $Block; - } - # # Fenced Code