Swap undefined type for type === 'Paragraph' for ease of reading

The way in which we use this assumes that it is a paragraph, for example
appending text into the handler argument — so there is no loss of
generality here, we're simply being explicit.
This commit is contained in:
Aidan Woods 2018-04-08 20:34:57 +01:00
parent 5353ebb524
commit ae8067e862
No known key found for this signature in database
GPG Key ID: 9A6A8EFAA512BBB9
1 changed files with 8 additions and 10 deletions

View File

@ -302,8 +302,7 @@ class Parsedown
if ( if (
isset($CurrentBlock) isset($CurrentBlock)
and isset($CurrentBlock['element']['name']) and $CurrentBlock['type'] === 'Paragraph'
and $CurrentBlock['element']['name'] === 'p'
and ! isset($CurrentBlock['interrupted']) and ! isset($CurrentBlock['interrupted'])
) { ) {
$CurrentBlock['element']['handler']['argument'] .= "\n".$text; $CurrentBlock['element']['handler']['argument'] .= "\n".$text;
@ -355,7 +354,7 @@ class Parsedown
protected function blockCode($Line, $Block = null) protected function blockCode($Line, $Block = null)
{ {
if (isset($Block) and ! isset($Block['type']) and ! isset($Block['interrupted'])) if (isset($Block) and $Block['type'] === 'Paragraph' and ! isset($Block['interrupted']))
{ {
return; return;
} }
@ -610,7 +609,7 @@ class Parsedown
{ {
if ( if (
isset($CurrentBlock) isset($CurrentBlock)
and ! isset($CurrentBlock['type']) and $CurrentBlock['type'] === 'Paragraph'
and ! isset($CurrentBlock['interrupted']) and ! isset($CurrentBlock['interrupted'])
) { ) {
return; return;
@ -803,7 +802,7 @@ class Parsedown
protected function blockSetextHeader($Line, array $Block = null) protected function blockSetextHeader($Line, array $Block = null)
{ {
if ( ! isset($Block) or isset($Block['type']) or isset($Block['interrupted'])) if ( ! isset($Block) or $Block['type'] !== 'Paragraph' or isset($Block['interrupted']))
{ {
return; return;
} }
@ -890,7 +889,7 @@ class Parsedown
protected function blockTable($Line, array $Block = null) protected function blockTable($Line, array $Block = null)
{ {
if ( ! isset($Block) or isset($Block['type']) or isset($Block['interrupted'])) if ( ! isset($Block) or $Block['type'] !== 'Paragraph' or isset($Block['interrupted']))
{ {
return; return;
} }
@ -1070,18 +1069,17 @@ class Parsedown
protected function paragraph($Line) protected function paragraph($Line)
{ {
$Block = array( return array(
'type' => 'Paragraph',
'element' => array( 'element' => array(
'name' => 'p', 'name' => 'p',
'handler' => array( 'handler' => array(
'function' => 'lineElements', 'function' => 'lineElements',
'argument' => $Line['text'], 'argument' => $Line['text'],
'destination' => 'elements', 'destination' => 'elements',
) ),
), ),
); );
return $Block;
} }
# #