Added a hook to change blocks on-the-fly

This commit is contained in:
Bruno P. Gonçalves 2019-05-17 23:10:00 -03:00
parent bfaa76d370
commit d13dec2510

View File

@ -13,12 +13,15 @@
#
#
class Parsedown
class Parsedown
{
# ~
const version = '1.8.0-beta-7';
# ~
protected $texthook = NULL;
# ~
function text($text)
@ -1720,6 +1723,11 @@ class Parsedown
$permitRawHtml = false;
// Add a hook for change blocks on the fly
if(is_callable($this->texthook)) {
$Element = call_user_func($this->texthook, $Element);
}
if (isset($Element['text']))
{
$text = $Element['text'];
@ -1750,6 +1758,8 @@ class Parsedown
}
else
{
if (!$permitRawHtml)
{
$markup .= self::escape($text, true);
@ -1770,6 +1780,13 @@ class Parsedown
return $markup;
}
/**
* Set callback hool
*/
public function setTextHook($callback) {
$this->texthook = $callback;
}
protected function elements(array $Elements)
{
$markup = '';