Index: wp-includes/formatting.php
===================================================================
--- wp-includes/formatting.php (revision 19734)
+++ wp-includes/formatting.php (working copy)
@@ -177,6 +177,20 @@
return '';
$pee = $pee . "\n"; // just to make things a little easier, pad the end
$pee = preg_replace('|
\s*
|', "\n\n", $pee);
+
+ // Save pre tags
+ $pre_blocks = array();
+ if ( preg_match_all( '/
]*>(.*?)<\/pre>/is', $pee, $matches ) ) { + $counter = 0; + foreach ( (array) $matches as $match ) { + $token = ''; + $pre_blocks[$token] = $match[0]; + $pos = strpos( $pee, $match[0] ); + if ( false !== $pos ) + $pee = substr( $pee, 0, $pos ) . $token . substr( $pee, $pos + strlen( $match[0] ) ); + } + } + // Space things out a little $allblocks = '(?:table|thead|tfoot|caption|col|colgroup|tbody|tr|td|th|div|dl|dd|dt|ul|ol|li|pre|select|option|form|map|area|blockquote|address|math|style|input|p|h[1-6]|hr|fieldset|legend|section|article|aside|hgroup|header|footer|nav|figure|figcaption|details|menu|summary)'; $pee = preg_replace('!(<' . $allblocks . '[^>]*>)!', "\n$1", $pee); @@ -207,8 +221,11 @@ } $pee = preg_replace('!(?' . $allblocks . '[^>]*>)\s*
!', "$1", $pee); $pee = preg_replace('!
(\s*?(?:p|li|div|dl|dd|dt|th|pre|td|ul|ol)[^>]*>)!', '$1', $pee); - if (strpos($pee, ']*>)(.*?)!is', 'clean_pre', $pee ); + + // Replace pre tags + if ( !empty( $pre_blocks ) ) + $pee = str_replace( array_keys( $pre_blocks ), array_values( $pre_blocks ), $pee ); + $pee = preg_replace( "|\n$|", '', $pee ); return $pee;