diff --git a/Parsedown.php b/Parsedown.php index fb5239d1..4ff4f7c5 100644 --- a/Parsedown.php +++ b/Parsedown.php @@ -168,6 +168,7 @@ protected function linesElements(array $lines) { $Elements = array(); $CurrentBlock = null; + $CurrentBlockHelper = null; foreach ($lines as $line) { @@ -178,8 +179,11 @@ protected function linesElements(array $lines) $CurrentBlock['interrupted'] = (isset($CurrentBlock['interrupted']) ? $CurrentBlock['interrupted'] + 1 : 1 ); + $CurrentBlockHelper = $CurrentBlock; + $CurrentBlock = $Block = null; + $blockTypes = $this->unmarkedBlockTypes; + $marker = ''; } - continue; } @@ -245,7 +249,7 @@ protected function linesElements(array $lines) foreach ($blockTypes as $blockType) { - $Block = $this->{"block$blockType"}($Line, $CurrentBlock); + $Block = $this->{"block$blockType"}($Line, $CurrentBlock?: $CurrentBlockHelper); if (isset($Block)) { @@ -253,9 +257,9 @@ protected function linesElements(array $lines) if ( ! isset($Block['identified'])) { - if (isset($CurrentBlock)) + if (isset($CurrentBlock) || isset($CurrentBlockHelper)) { - $Elements[] = $this->extractElement($CurrentBlock); + $Elements[] = $CurrentBlock ? $this->extractElement($CurrentBlock):$this->extractElement($CurrentBlockHelper); } $Block['identified'] = true; @@ -285,9 +289,9 @@ protected function linesElements(array $lines) } else { - if (isset($CurrentBlock)) + if (isset($CurrentBlock) || isset($CurrentBlockHelper)) { - $Elements[] = $this->extractElement($CurrentBlock); + $Elements[] = $CurrentBlock ?$this->extractElement($CurrentBlock): $this->extractElement($CurrentBlockHelper); } $CurrentBlock = $this->paragraph($Line);