function _DoCodeBlocks_callback($matches) { $prevchar = $matches[1]; $newlines = $matches[2]; $codeblock = $matches[4]; $result; # return value $prefix = ""; if (!(preg_match('/\\s/', $prevchar) || $prevchar == "")) { $prefix = "{$prevchar}:"; } $codeblock = _EncodeCode(_Outdent($codeblock)); $codeblock = _Detab($codeblock); # trim leading newlines and trailing whitespace $codeblock = preg_replace(array('/\\A\\n+/', '/\\s+\\z/'), '', $codeblock); $result = $prefix . "\n\n<pre><code>" . $codeblock . "\n</code></pre>\n\n"; return $result; }
function _DoCodeBlocks_callback($matches) { $codeblock = $matches[1]; $codeblock = _EncodeCode(_Outdent($codeblock)); // $codeblock = _Detab($codeblock); # trim leading newlines and trailing whitespace $codeblock = preg_replace(array('/\\A\\n+/', '/\\s+\\z/'), '', $codeblock); $result = "\n\n<pre><code>" . $codeblock . "\n</code></pre>\n\n"; return $result; }