From 14b37616875b1f8ded64f5883e954971024c3857 Mon Sep 17 00:00:00 2001 From: Aidan Woods Date: Thu, 24 Jan 2019 21:56:20 +0000 Subject: [PATCH] Produce Blocks before converting to StateRenderables (As we do with Inlines) --- src/Parsedown.php | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/src/Parsedown.php b/src/Parsedown.php index ca1039f..2163050 100644 --- a/src/Parsedown.php +++ b/src/Parsedown.php @@ -124,8 +124,20 @@ final class Parsedown */ public function lines(Lines $Lines) { - /** @var StateRenderable[] */ - $StateRenderables = []; + return \array_map( + /** @return StateRenderable */ + function (Block $Block) { return $Block->stateRenderable($this); }, + $this->blocks($Lines) + ); + } + + /** + * @return Block[] + */ + public function blocks(Lines $Lines) + { + /** @var Block[] */ + $Blocks = []; /** @var Block|null */ $Block = null; /** @var Block|null */ @@ -176,7 +188,7 @@ final class Parsedown } if (isset($CurrentBlock) && ! $Block->acquiredPrevious()) { - $StateRenderables[] = $CurrentBlock->stateRenderable($this); + $Blocks[] = $CurrentBlock; } $CurrentBlock = $Block; @@ -195,7 +207,7 @@ final class Parsedown $CurrentBlock = $Block; } else { if (isset($CurrentBlock)) { - $StateRenderables[] = $CurrentBlock->stateRenderable($this); + $Blocks[] = $CurrentBlock; } $CurrentBlock = Paragraph::build($Context); @@ -205,12 +217,12 @@ final class Parsedown # ~ if (isset($CurrentBlock)) { - $StateRenderables[] = $CurrentBlock->stateRenderable($this); + $Blocks[] = $CurrentBlock; } # ~ - return $StateRenderables; + return $Blocks; } #