Optional code block content function added.
This commit is contained in:
parent
e1aabe1817
commit
1df2655b8b
1 changed files with 9 additions and 0 deletions
|
|
@ -43,6 +43,9 @@ class MarkdownExtra extends \Michelf\Markdown {
|
|||
# setting this to true will put attributes on the `pre` tag instead.
|
||||
public $code_attr_on_pre = false;
|
||||
|
||||
# Optional content function for code blocks
|
||||
public $code_block_content_func = null;
|
||||
|
||||
# Predefined abbreviations.
|
||||
public $predef_abbr = array();
|
||||
|
||||
|
|
@ -1318,6 +1321,12 @@ class MarkdownExtra extends \Michelf\Markdown {
|
|||
$classname =& $matches[2];
|
||||
$attrs =& $matches[3];
|
||||
$codeblock = $matches[4];
|
||||
|
||||
if ($this->code_block_content_func) {
|
||||
$codeblock = call_user_func($this->code_block_content_func, $codeblock, $classname);
|
||||
return "\n\n".$this->hashBlock($codeblock)."\n\n";
|
||||
}
|
||||
|
||||
$codeblock = htmlspecialchars($codeblock, ENT_NOQUOTES);
|
||||
$codeblock = preg_replace_callback('/^\n+/',
|
||||
array($this, '_doFencedCodeBlocks_newlines'), $codeblock);
|
||||
|
|
|
|||
Loading…
Reference in a new issue