summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndy Miller <rhuk@mac.com>2015-12-17 10:46:44 -0700
committerAndy Miller <rhuk@mac.com>2015-12-17 10:46:44 -0700
commit5ad15b87faa2ab10f7cda7593e2e92696fafadd2 (patch)
tree19e8dfb44c006563f19cd20bb70c67b4578ff717
parentb166cab9a252f4093af1f33cb178a86f6047d08a (diff)
downloadparsedown-5ad15b87faa2ab10f7cda7593e2e92696fafadd2.zip
parsedown-5ad15b87faa2ab10f7cda7593e2e92696fafadd2.tar.gz
parsedown-5ad15b87faa2ab10f7cda7593e2e92696fafadd2.tar.bz2
Break out method_exists checks into extendable methods to allow for better pluggability
-rw-r--r--Parsedown.php25
1 files 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);
}
@@ -279,6 +279,19 @@ class Parsedown
}
#
+ # 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
protected function blockCode($Line, $Block = null)
@@ -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',
);
}