You are here

protected function Markdown::_doCodeBlocks_callback in Markdown 7

* Code block parsing callback *

Parameters

array $matches: * @return string

File

includes/Markdown.php, line 1210

Class

Markdown
Markdown Parser Class

Namespace

Michelf

Code

protected function _doCodeBlocks_callback($matches) {
  $codeblock = $matches[1];
  $codeblock = $this
    ->outdent($codeblock);
  if ($this->code_block_content_func) {
    $codeblock = call_user_func($this->code_block_content_func, $codeblock, "");
  }
  else {
    $codeblock = htmlspecialchars($codeblock, ENT_NOQUOTES);
  }

  # trim leading newlines and trailing newlines
  $codeblock = preg_replace('/\\A\\n+|\\n+\\z/', '', $codeblock);
  $codeblock = "<pre><code>{$codeblock}\n</code></pre>";
  return "\n\n" . $this
    ->hashBlock($codeblock) . "\n\n";
}