Ticket #19855: 19855.patch
File 19855.patch, 1.7 KB (added by , 13 years ago) |
---|
-
wp-includes/formatting.php
177 177 return ''; 178 178 $pee = $pee . "\n"; // just to make things a little easier, pad the end 179 179 $pee = preg_replace('|<br />\s*<br />|', "\n\n", $pee); 180 181 // Save pre tags 182 $pre_blocks = array(); 183 if ( preg_match_all( '/<pre[^>]*>(.*?)<\/pre>/is', $pee, $matches ) ) { 184 $counter = 0; 185 foreach ( (array) $matches as $match ) { 186 $token = '<WPPre_' . $counter++ . ' />'; 187 $pre_blocks[$token] = $match[0]; 188 $pos = strpos( $pee, $match[0] ); 189 if ( false !== $pos ) 190 $pee = substr( $pee, 0, $pos ) . $token . substr( $pee, $pos + strlen( $match[0] ) ); 191 } 192 } 193 180 194 // Space things out a little 181 195 $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)'; 182 196 $pee = preg_replace('!(<' . $allblocks . '[^>]*>)!', "\n$1", $pee); … … 207 221 } 208 222 $pee = preg_replace('!(</?' . $allblocks . '[^>]*>)\s*<br />!', "$1", $pee); 209 223 $pee = preg_replace('!<br />(\s*</?(?:p|li|div|dl|dd|dt|th|pre|td|ul|ol)[^>]*>)!', '$1', $pee); 210 if (strpos($pee, '<pre') !== false) 211 $pee = preg_replace_callback('!(<pre[^>]*>)(.*?)</pre>!is', 'clean_pre', $pee ); 224 225 // Replace pre tags 226 if ( !empty( $pre_blocks ) ) 227 $pee = str_replace( array_keys( $pre_blocks ), array_values( $pre_blocks ), $pee ); 228 212 229 $pee = preg_replace( "|\n</p>$|", '</p>', $pee ); 213 230 214 231 return $pee;