You are here

protected function Markdown::_doCodeBlocks_callback in Express 8

* Code block parsing callback *

Parameters

array $matches: * @return string

File

vendor/michelf/php-markdown/Michelf/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";
}