Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions Parsedown.php
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ protected function linesElements(array $lines)
{
$Elements = array();
$CurrentBlock = null;
$CurrentBlockHelper = null;

foreach ($lines as $line)
{
Expand All @@ -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;
}

Expand Down Expand Up @@ -245,17 +249,17 @@ 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))
{
$Block['type'] = $blockType;

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;
Expand Down Expand Up @@ -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);
Expand Down