Ticket #27350: formatting-27350.diff
File formatting-27350.diff, 3.4 KB (added by , 10 years ago) |
---|
-
src/wp-includes/formatting.php
147 147 $dynamic_characters['apos'] = array_keys( $dynamic ); 148 148 $dynamic_replacements['apos'] = array_values( $dynamic ); 149 149 $dynamic = array(); 150 150 151 151 // Quoted Numbers like "42" 152 152 if ( '"' !== $opening_quote && '"' !== $closing_quote ) { 153 153 $dynamic[ '/(?<=\A|' . $spaces . ')"(\d[.,\d]*)"/' ] = $opening_quote . '$1' . $closing_quote; … … 167 167 if ( '"' !== $closing_quote ) { 168 168 $dynamic[ '/"/' ] = $closing_quote; 169 169 } 170 170 171 171 $dynamic_characters['quote'] = array_keys( $dynamic ); 172 172 $dynamic_replacements['quote'] = array_values( $dynamic ); 173 173 $dynamic = array(); 174 174 175 175 // Dashes and spaces 176 176 $dynamic[ '/---/' ] = $em_dash; 177 177 $dynamic[ '/(?<=' . $spaces . ')--(?=' . $spaces . ')/' ] = $em_dash; … … 387 387 388 388 $pee = preg_replace('|<br />\s*<br />|', "\n\n", $pee); 389 389 // Space things out a little 390 $allblocks = '(?:table|thead|tfoot|caption|col|colgroup|tbody|tr|td|th|div|dl|dd|dt|ul|ol|li|pre|form|map|area|blockquote|address|math|style|p|h[1-6]|hr|fieldset|legend|section|article|aside|hgroup|header|footer|nav|figure|details|menu|summary) ';390 $allblocks = '(?:table|thead|tfoot|caption|col|colgroup|tbody|tr|td|th|div|dl|dd|dt|ul|ol|li|pre|form|map|area|blockquote|address|math|style|p|h[1-6]|hr|fieldset|legend|section|article|aside|hgroup|header|footer|nav|figure|details|menu|summary)\b'; 391 391 $pee = preg_replace('!(<' . $allblocks . '[^>]*>)!', "\n$1", $pee); 392 392 $pee = preg_replace('!(</' . $allblocks . '>)!', "$1\n\n", $pee); 393 393 $pee = str_replace(array("\r\n", "\r"), "\n", $pee); // cross-platform newlines … … 414 414 415 415 $pee = preg_replace("/\n\n+/", "\n\n", $pee); // take care of duplicates 416 416 // make paragraphs, including one at the end 417 $pees = preg_split('/\n\s*\n/', $pee, -1, PREG_SPLIT_NO_EMPTY);417 $pees = preg_split('/\n\s*\n/', ltrim($pee), -1, PREG_SPLIT_NO_EMPTY); 418 418 $pee = ''; 419 419 420 420 foreach ( $pees as $tinkle ) { 421 $pee .= '<p>' . trim($tinkle, "\n") . "</p>\n"; 421 if ( preg_match( '!</?blockquote([^>]*)>!', $tinkle) >= 1 ) { 422 // pee inside blockquotes (prevent splashing) 423 $blockquote = preg_replace('|<blockquote([^>]*)>|i', "<blockquote$1><p>", $tinkle); 424 $blockquote = str_replace('</blockquote>', '</p></blockquote>', $blockquote); 425 $pee .= $blockquote . "\n"; 426 } elseif ( preg_match( '!</?' . $allblocks . '[^>]*>!', $tinkle ) >= 1 ) { 427 $pee .= trim($tinkle, "\n") . "\n"; // avoid peeing on block elements in the stream 428 } else { 429 $pee .= '<p>' . trim($tinkle, "\n") . "</p>\n"; 430 } 422 431 } 423 432 424 433 $pee = preg_replace('|<p>\s*</p>|', '', $pee); // under certain strange conditions it could create a P of entirely whitespace 425 434 $pee = preg_replace('!<p>([^<]+)</(div|address|form)>!', "<p>$1</p></$2>", $pee); 426 435 $pee = preg_replace('!<p>\s*(</?' . $allblocks . '[^>]*>)\s*</p>!', "$1", $pee); // don't pee all over a tag 427 436 $pee = preg_replace("|<p>(<li.+?)</p>|", "$1", $pee); // problem with nested lists 428 $pee = preg_replace('|<p><blockquote([^>]*)>|i', "<blockquote$1><p>", $pee);429 $pee = str_replace('</blockquote></p>', '</p></blockquote>', $pee);430 437 $pee = preg_replace('!<p>\s*(</?' . $allblocks . '[^>]*>)!', "$1", $pee); 431 438 $pee = preg_replace('!(</?' . $allblocks . '[^>]*>)\s*</p>!', "$1", $pee); 432 439