You are here

protected function Markdown::doCodeBlocks in Markdown 7

* Process Markdown `<pre><code>` blocks. *

Parameters

string $text: * @return string

File

includes/Markdown.php, line 1189

Class

Markdown
Markdown Parser Class

Namespace

Michelf

Code

protected function doCodeBlocks($text) {
  $text = preg_replace_callback('{
				(?:\\n\\n|\\A\\n?)
				(	            # $1 = the code block -- one or more lines, starting with a space/tab
				  (?>
					[ ]{' . $this->tab_width . '}  # Lines must start with a tab or a tab-width of spaces
					.*\\n+
				  )+
				)
				((?=^[ ]{0,' . $this->tab_width . '}\\S)|\\Z)	# Lookahead for non-space at line-start, or end of doc
			}xm', array(
    $this,
    '_doCodeBlocks_callback',
  ), $text);
  return $text;
}