*** markdown.orig.php	2010-01-30 18:54:25.000000000 -0500
--- markdown.php	2010-01-30 18:55:38.000000000 -0500
***************
*** 1249,1255 ****
  		$text = preg_replace('/\A\n+|\n+\z/', '', $text);
  
  		$grafs = preg_split('/\n{2,}/', $text, -1, PREG_SPLIT_NO_EMPTY);
! 
  		#
  		# Wrap <p> tags and unhashify HTML blocks
  		#
--- 1249,1255 ----
  		$text = preg_replace('/\A\n+|\n+\z/', '', $text);
  
  		$grafs = preg_split('/\n{2,}/', $text, -1, PREG_SPLIT_NO_EMPTY);
! 		
  		#
  		# Wrap <p> tags and unhashify HTML blocks
  		#
***************
*** 2432,2437 ****
--- 2432,2462 ----
  				(
  					~{3,} # Marker: three tilde or more.
  				)
+ 				[ ]*
+ 				(
+ 					[a-zA-Z="\s]+
+ 				)
+ 				[ ]* \n # Whitespace and newline following marker.
+ 				
+ 				# 2: Content
+ 				(
+ 					(?>
+ 						(?!\1 [ ]* \n)	# Not a closing marker.
+ 						.*\n+
+ 					)+
+ 				)
+ 				
+ 				# Closing marker.
+ 				\1 [ ]* \n
+ 			}xm',
+ 			array(&$this, '_doCodeBlocks_fenced_attrib_callback'), $text);
+ 
+ 		$text = preg_replace_callback('{
+ 				(?:\n|\A)
+ 				# 1: Opening marker
+ 				(
+ 					~{3,} # Marker: three tilde or more.
+ 				)
  				[ ]* \n # Whitespace and newline following marker.
  				
  				# 2: Content
***************
*** 2451,2457 ****
--- 2476,2492 ----
  
  		return $text;
  	}
+ 	function _doCodeBlocks_fenced_attrib_callback($matches) {
+ 		$class = $matches[2];
+ 		$codeblock = $matches[3];
+ 		$codeblock = htmlspecialchars($codeblock, ENT_NOQUOTES);
+ 		$codeblock = preg_replace_callback('/^\n+/',
+ 			array(&$this, '_doCodeBlocks_fenced_newlines'), $codeblock);
+ 		$codeblock = "<pre $class>$codeblock</pre>";
+ 		return "\n\n".$this->hashBlock($codeblock)."\n\n";
+ 	}
  	function _doCodeBlocks_fenced_callback($matches) {
+ 		print_r($matches);
  		$codeblock = $matches[2];
  		$codeblock = htmlspecialchars($codeblock, ENT_NOQUOTES);
  		$codeblock = preg_replace_callback('/^\n+/',
