You are here

function Markdown_Parser::_doCodeBlocks_callback in Markdown 5

Same name and namespace in other branches
  1. 6 markdown.php \Markdown_Parser::_doCodeBlocks_callback()

File

./markdown.php, line 1091

Class

Markdown_Parser

Code

function _doCodeBlocks_callback($matches) {
  $codeblock = $matches[1];
  $codeblock = $this
    ->outdent($codeblock);
  $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";
}