From b166cab9a252f4093af1f33cb178a86f6047d08a Mon Sep 17 00:00:00 2001 From: Andy Miller Date: Thu, 17 Dec 2015 10:46:04 -0700 Subject: [PATCH 1/4] Make `lines` protected to allow for extendability --- Parsedown.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Parsedown.php b/Parsedown.php index c8c92a3..b0e7094 100644 --- a/Parsedown.php +++ b/Parsedown.php @@ -115,7 +115,7 @@ class Parsedown # Blocks # - private function lines(array $lines) + protected function lines(array $lines) { $CurrentBlock = null; From 5ad15b87faa2ab10f7cda7593e2e92696fafadd2 Mon Sep 17 00:00:00 2001 From: Andy Miller Date: Thu, 17 Dec 2015 10:46:44 -0700 Subject: [PATCH 2/4] Break out method_exists checks into extendable methods to allow for better pluggability --- Parsedown.php | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/Parsedown.php b/Parsedown.php index b0e7094..b04ee4a 100644 --- a/Parsedown.php +++ b/Parsedown.php @@ -175,7 +175,7 @@ class Parsedown } else { - if (method_exists($this, 'block'.$CurrentBlock['type'].'Complete')) + if ($this->isBlockCompleteable($CurrentBlock['type'])) { $CurrentBlock = $this->{'block'.$CurrentBlock['type'].'Complete'}($CurrentBlock); } @@ -216,7 +216,7 @@ class Parsedown $Block['identified'] = true; } - if (method_exists($this, 'block'.$blockType.'Continue')) + if ($this->isBlockContinueable($blockType)) { $Block['continuable'] = true; } @@ -245,7 +245,7 @@ class Parsedown # ~ - if (isset($CurrentBlock['continuable']) and method_exists($this, 'block'.$CurrentBlock['type'].'Complete')) + if (isset($CurrentBlock['continuable']) and $this->isBlockCompleteable($CurrentBlock['type'])) { $CurrentBlock = $this->{'block'.$CurrentBlock['type'].'Complete'}($CurrentBlock); } @@ -278,6 +278,19 @@ class Parsedown return $markup; } + # + # Allow for plugin extensibility + # + protected function isBlockContinueable($Type) + { + return method_exists($this, 'block'.$Type.'Continue'); + } + + protected function isBlockCompleteable($Type) + { + return method_exists($this, 'block'.$Type.'Complete'); + } + # # Code @@ -1521,8 +1534,8 @@ class Parsedown 'q', 'rt', 'ins', 'font', 'strong', 's', 'tt', 'sub', 'mark', 'u', 'xm', 'sup', 'nobr', - 'var', 'ruby', - 'wbr', 'span', - 'time', + 'var', 'ruby', + 'wbr', 'span', + 'time', ); } From 10a7ff776c3f16b1b3aa41c176c48150fc091065 Mon Sep 17 00:00:00 2001 From: Andy Miller Date: Thu, 17 Dec 2015 10:48:21 -0700 Subject: [PATCH 3/4] Left as-is --- Parsedown.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Parsedown.php b/Parsedown.php index b04ee4a..60d315f 100644 --- a/Parsedown.php +++ b/Parsedown.php @@ -1534,8 +1534,8 @@ class Parsedown 'q', 'rt', 'ins', 'font', 'strong', 's', 'tt', 'sub', 'mark', 'u', 'xm', 'sup', 'nobr', - 'var', 'ruby', - 'wbr', 'span', - 'time', + 'var', 'ruby', + 'wbr', 'span', + 'time', ); } From e7443a2bd868e78946ae6a01a1b07d477ce6f4cc Mon Sep 17 00:00:00 2001 From: Andy Miller Date: Fri, 18 Dec 2015 20:45:14 -0700 Subject: [PATCH 4/4] Fixed really sorry spelling errors --- Parsedown.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Parsedown.php b/Parsedown.php index 60d315f..6ffb402 100644 --- a/Parsedown.php +++ b/Parsedown.php @@ -175,7 +175,7 @@ class Parsedown } else { - if ($this->isBlockCompleteable($CurrentBlock['type'])) + if ($this->isBlockCompletable($CurrentBlock['type'])) { $CurrentBlock = $this->{'block'.$CurrentBlock['type'].'Complete'}($CurrentBlock); } @@ -216,7 +216,7 @@ class Parsedown $Block['identified'] = true; } - if ($this->isBlockContinueable($blockType)) + if ($this->isBlockContinuable($blockType)) { $Block['continuable'] = true; } @@ -245,7 +245,7 @@ class Parsedown # ~ - if (isset($CurrentBlock['continuable']) and $this->isBlockCompleteable($CurrentBlock['type'])) + if (isset($CurrentBlock['continuable']) and $this->isBlockCompletable($CurrentBlock['type'])) { $CurrentBlock = $this->{'block'.$CurrentBlock['type'].'Complete'}($CurrentBlock); } @@ -281,12 +281,12 @@ class Parsedown # # Allow for plugin extensibility # - protected function isBlockContinueable($Type) + protected function isBlockContinuable($Type) { return method_exists($this, 'block'.$Type.'Continue'); } - protected function isBlockCompleteable($Type) + protected function isBlockCompletable($Type) { return method_exists($this, 'block'.$Type.'Complete'); }