1
0
mirror of https://github.com/erusev/parsedown.git synced 2023-08-10 21:13:06 +03:00

Merge pull request #373 from getgrav/master

Simple changes to make Parsedown more pluggable
This commit is contained in:
Emanuil Rusev 2015-12-19 16:39:29 +02:00
commit 32de2cedcc

View File

@ -115,7 +115,7 @@ class Parsedown
# Blocks # Blocks
# #
private function lines(array $lines) protected function lines(array $lines)
{ {
$CurrentBlock = null; $CurrentBlock = null;
@ -175,7 +175,7 @@ class Parsedown
} }
else else
{ {
if (method_exists($this, 'block'.$CurrentBlock['type'].'Complete')) if ($this->isBlockCompletable($CurrentBlock['type']))
{ {
$CurrentBlock = $this->{'block'.$CurrentBlock['type'].'Complete'}($CurrentBlock); $CurrentBlock = $this->{'block'.$CurrentBlock['type'].'Complete'}($CurrentBlock);
} }
@ -216,7 +216,7 @@ class Parsedown
$Block['identified'] = true; $Block['identified'] = true;
} }
if (method_exists($this, 'block'.$blockType.'Continue')) if ($this->isBlockContinuable($blockType))
{ {
$Block['continuable'] = true; $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->isBlockCompletable($CurrentBlock['type']))
{ {
$CurrentBlock = $this->{'block'.$CurrentBlock['type'].'Complete'}($CurrentBlock); $CurrentBlock = $this->{'block'.$CurrentBlock['type'].'Complete'}($CurrentBlock);
} }
@ -278,6 +278,19 @@ class Parsedown
return $markup; return $markup;
} }
#
# Allow for plugin extensibility
#
protected function isBlockContinuable($Type)
{
return method_exists($this, 'block'.$Type.'Continue');
}
protected function isBlockCompletable($Type)
{
return method_exists($this, 'block'.$Type.'Complete');
}
# #
# Code # Code