diff --git a/Parsedown.php b/Parsedown.php index a3efd7a..1dde17d 100755 --- a/Parsedown.php +++ b/Parsedown.php @@ -513,42 +513,39 @@ class Parsedown protected function blockHeader($Line) { - if (isset($Line['text'][1])) + $level = 1; + + while (isset($Line['text'][$level]) and $Line['text'][$level] === '#') { - $level = 1; - - while (isset($Line['text'][$level]) and $Line['text'][$level] === '#') - { - $level ++; - } - - if ($level > 6) - { - return; - } - - $text = trim($Line['text'], '#'); - - if ($this->strictMode and ( ! isset($text[0]) or $text[0] !== ' ')) - { - return; - } - - $text = trim($text, ' '); - - $Block = array( - 'element' => array( - 'name' => 'h' . min(6, $level), - 'handler' => array( - 'function' => 'lineElements', - 'argument' => $text, - 'destination' => 'elements', - ) - ), - ); - - return $Block; + $level ++; } + + if ($level > 6) + { + return; + } + + $text = trim($Line['text'], '#'); + + if ($this->strictMode and isset($text[0]) and $text[0] !== ' ') + { + return; + } + + $text = trim($text, ' '); + + $Block = array( + 'element' => array( + 'name' => 'h' . min(6, $level), + 'handler' => array( + 'function' => 'lineElements', + 'argument' => $text, + 'destination' => 'elements', + ) + ), + ); + + return $Block; } # diff --git a/test/data/atx_heading.html b/test/data/atx_heading.html index 387e2ec..3b09c38 100644 --- a/test/data/atx_heading.html +++ b/test/data/atx_heading.html @@ -6,7 +6,8 @@
####### not a heading
#
+ +