You are here

function Markdown_Parser::doCodeBlocks in Markdown 6

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

File

./markdown.php, line 1117

Class

Markdown_Parser

Code

function doCodeBlocks($text) {

  #

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

  #
  $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;
}