Ticket #28724: miqro-28724.2.patch
| File miqro-28724.2.patch, 4.6 KB (added by , 12 years ago) |
|---|
-
src/wp-includes/formatting.php
96 96 $static_characters = array_merge( array( '...', '``', '\'\'', ' (tm)' ), $cockney ); 97 97 $static_replacements = array_merge( array( '…', $opening_quote, $closing_quote, ' ™' ), $cockneyreplace ); 98 98 99 $spaces = wp_spaces_regexp();100 99 101 102 100 // Pattern-based replacements of characters. 101 // Sort the remaining patterns into several arrays for performance tuning. 102 $dynamic_characters = array( 'apos' => array(), 'quote' => array(), 'dash' => array() ); 103 $dynamic_replacements = array( 'apos' => array(), 'quote' => array(), 'dash' => array() ); 103 104 $dynamic = array(); 105 $spaces = wp_spaces_regexp(); 104 106 105 107 // '99' and '99" are ambiguous among other patterns; assume it's an abbreviated year at the end of a quotation. 106 108 if ( "'" !== $apos || "'" !== $closing_single_quote ) { … … 115 117 $dynamic[ '/\'(?=\d\d(?:\Z|(?![%\d]|[.,]\d)))/' ] = $apos; 116 118 } 117 119 118 // Quoted Numbers like "42" or '42.00' 119 if ( '"' !== $opening_quote && '"' !== $closing_quote ) { 120 $dynamic[ '/(?<=\A|' . $spaces . ')"(\d[.,\d]*)"/' ] = $opening_quote . '$1' . $closing_quote; 121 } 120 // Quoted Numbers like '0.42' 122 121 if ( "'" !== $opening_single_quote && "'" !== $closing_single_quote ) { 123 122 $dynamic[ '/(?<=\A|' . $spaces . ')\'(\d[.,\d]*)\'/' ] = $opening_single_quote . '$1' . $closing_single_quote; 124 123 } … … 133 132 $dynamic[ '/(?<!' . $spaces . ')\'(?!\Z|[.,:;"\'(){}[\]\-]|&[lg]t;|' . $spaces . ')/' ] = $apos; 134 133 } 135 134 135 // 9' (prime) 136 if ( "'" !== $prime ) { 137 $dynamic[ '/(?<=\d)\'/' ] = $prime; 138 } 139 140 // Single quotes followed by spaces or ending punctuation. 141 if ( "'" !== $closing_single_quote ) { 142 $dynamic[ '/\'(?=\Z|[.,)}\-\]]|>|' . $spaces . ')/' ] = $closing_single_quote; 143 } 144 145 $dynamic_characters['apos'] = array_keys( $dynamic ); 146 $dynamic_replacements['apos'] = array_values( $dynamic ); 147 $dynamic = array(); 148 149 // Quoted Numbers like "42" 150 if ( '"' !== $opening_quote && '"' !== $closing_quote ) { 151 $dynamic[ '/(?<=\A|' . $spaces . ')"(\d[.,\d]*)"/' ] = $opening_quote . '$1' . $closing_quote; 152 } 153 136 154 // 9" (double prime) 137 155 if ( '"' !== $double_prime ) { 138 156 $dynamic[ '/(?<=\d)"/' ] = $double_prime; 139 157 } 140 158 141 // 9' (prime)142 if ( "'" !== $prime ) {143 $dynamic[ '/(?<=\d)\'/' ] = $prime;144 }145 146 159 // Double quote at start, or preceded by (, {, <, [, -, or spaces, and not followed by spaces. 147 160 if ( '"' !== $opening_quote ) { 148 161 $dynamic[ '/(?<=\A|[([{\-]|<|' . $spaces . ')"(?!' . $spaces . ')/' ] = $opening_quote; … … 152 165 if ( '"' !== $closing_quote ) { 153 166 $dynamic[ '/"/' ] = $closing_quote; 154 167 } 155 156 // Single quotes followed by spaces or ending punctuation. 157 if ( "'" !== $closing_single_quote ) { 158 $dynamic[ '/\'(?=\Z|[.,)}\-\]]|>|' . $spaces . ')/' ] = $closing_single_quote; 159 } 160 168 169 $dynamic_characters['quote'] = array_keys( $dynamic ); 170 $dynamic_replacements['quote'] = array_values( $dynamic ); 171 $dynamic = array(); 172 161 173 // Dashes and spaces 162 174 $dynamic[ '/---/' ] = $em_dash; 163 175 $dynamic[ '/(?<=' . $spaces . ')--(?=' . $spaces . ')/' ] = $em_dash; … … 164 176 $dynamic[ '/(?<!xn)--/' ] = $en_dash; 165 177 $dynamic[ '/(?<=' . $spaces . ')-(?=' . $spaces . ')/' ] = $en_dash; 166 178 167 $dynamic_characters = array_keys( $dynamic );168 $dynamic_replacements = array_values( $dynamic );179 $dynamic_characters['dash'] = array_keys( $dynamic ); 180 $dynamic_replacements['dash'] = array_values( $dynamic ); 169 181 } 170 182 171 183 // Must do this every time in case plugins use these filters in a context sensitive manner … … 237 249 // This is neither a delimeter, nor is this content inside of no_texturize pairs. Do texturize. 238 250 239 251 $curl = str_replace( $static_characters, $static_replacements, $curl ); 240 $curl = preg_replace( $dynamic_characters, $dynamic_replacements, $curl );241 252 253 if ( false !== strpos( $curl, "'" ) ) { 254 $curl = preg_replace( $dynamic_characters['apos'], $dynamic_replacements['apos'], $curl ); 255 } 256 if ( false !== strpos( $curl, '"' ) ) { 257 $curl = preg_replace( $dynamic_characters['quote'], $dynamic_replacements['quote'], $curl ); 258 } 259 if ( false !== strpos( $curl, '-' ) ) { 260 $curl = preg_replace( $dynamic_characters['dash'], $dynamic_replacements['dash'], $curl ); 261 } 262 242 263 // 9x9 (times), but never 0x9999 243 264 if ( 1 === preg_match( '/(?<=\d)x-?\d/', $curl ) ) { 244 265 // Searching for a digit is 10 times more expensive than for the x, so we avoid doing this one!