From d7956e3adec12e6067badf8b6c464791760d0296 Mon Sep 17 00:00:00 2001 From: Aidan Woods Date: Sat, 25 Mar 2017 14:28:43 +0000 Subject: [PATCH] blockmarkup ends on interrupt by newline (CommonMark compliance) --- Parsedown.php | 29 ++--------------------------- 1 file changed, 2 insertions(+), 27 deletions(-) diff --git a/Parsedown.php b/Parsedown.php index f5dd0fa..e516f6b 100644 --- a/Parsedown.php +++ b/Parsedown.php @@ -683,7 +683,7 @@ class Parsedown return; } - if (preg_match('/^<(\w*)(?:[ ]*'.$this->regexHtmlAttribute.')*[ ]*(\/)?>/', $Line['text'], $matches)) + if (preg_match('/^<[\/]?+(\w*)(?:[ ]*'.$this->regexHtmlAttribute.')*[ ]*(\/)?>/', $Line['text'], $matches)) { $element = strtolower($matches[1]); @@ -694,7 +694,6 @@ class Parsedown $Block = array( 'name' => $matches[1], - 'depth' => 0, 'markup' => $Line['text'], ); @@ -730,35 +729,11 @@ class Parsedown protected function blockMarkupContinue($Line, array $Block) { - if (isset($Block['closed'])) + if (isset($Block['closed']) or isset($Block['interrupted'])) { return; } - if (preg_match('/^<'.$Block['name'].'(?:[ ]*'.$this->regexHtmlAttribute.')*[ ]*>/i', $Line['text'])) # open - { - $Block['depth'] ++; - } - - if (preg_match('/(.*?)<\/'.$Block['name'].'>[ ]*$/i', $Line['text'], $matches)) # close - { - if ($Block['depth'] > 0) - { - $Block['depth'] --; - } - else - { - $Block['closed'] = true; - } - } - - if (isset($Block['interrupted'])) - { - $Block['markup'] .= "\n"; - - unset($Block['interrupted']); - } - $Block['markup'] .= "\n".$Line['body']; return $Block;