Changeset 27839 for trunk/src/wp-includes/formatting.php
- Timestamp:
- 03/29/2014 07:15:33 AM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/formatting.php
r27761 r27839 74 74 $static_replacements = array_merge( array( $em_dash, ' ' . $em_dash . ' ', $en_dash, ' ' . $en_dash . ' ', 'xn--', '…', $opening_quote, $closing_quote, ' ™' ), $cockneyreplace ); 75 75 76 /* 77 * Regex for common whitespace characters. 78 * 79 * By default, spaces include new lines, tabs, nbsp entities, and the UTF-8 nbsp. 80 * This is designed to replace the PCRE \s sequence. In #WP22692, that sequence 81 * was found to be unreliable due to random inclusion of the A0 byte. 82 */ 83 $spaces = '[\r\n\t ]|\xC2\xA0| '; 84 85 86 // Pattern-based replacements of characters. 76 87 $dynamic = array(); 77 if ( "'" != $apos ) { 78 $dynamic[ '/\'(\d\d(?:’|\')?s)/' ] = $apos . '$1'; // '99's 79 $dynamic[ '/\'(\d)/' ] = $apos . '$1'; // '99 80 } 88 89 // '99 '99s '99's (apostrophe) 90 if ( "'" != $apos ) 91 $dynamic[ '/\'(?=\d)/' ] = $apos; 92 93 // Single quote at start, or preceded by (, {, <, [, ", or spaces. 81 94 if ( "'" != $opening_single_quote ) 82 $dynamic[ '/(\s|\A|[([{<]|")\'/' ] = '$1' . $opening_single_quote; // opening single quote, even after (, {, <, [ 95 $dynamic[ '/(?<=\A|[([{<"]|' . $spaces . ')\'/' ] = $opening_single_quote; 96 97 // 9" (double prime) 83 98 if ( '"' != $double_prime ) 84 $dynamic[ '/(\d)"/' ] = '$1' . $double_prime; // 9" (double prime) 99 $dynamic[ '/(?<=\d)"/' ] = $double_prime; 100 101 // 9' (prime) 85 102 if ( "'" != $prime ) 86 $dynamic[ '/(\d)\'/' ] = '$1' . $prime; // 9' (prime) 103 $dynamic[ '/(?<=\d)\'/' ] = $prime; 104 105 // Apostrophe in a word. No spaces or double primes. 87 106 if ( "'" != $apos ) 88 $dynamic[ '/(\S)\'([^\'\s])/' ] = '$1' . $apos . '$2'; // apostrophe in a word 107 $dynamic[ '/(?<!' . $spaces . ')\'(?!\'|' . $spaces . ')/' ] = $apos; 108 109 // Double quote at start, or preceded by (, {, <, [, or spaces, and not followed by spaces. 89 110 if ( '"' != $opening_quote ) 90 $dynamic[ '/(\s|\A|[([{<])"(?!\s)/' ] = '$1' . $opening_quote . '$2'; // opening double quote, even after (, {, <, [ 111 $dynamic[ '/(?<=\A|[([{<]|' . $spaces . ')"(?!' . $spaces . ')/' ] = $opening_quote; 112 113 // Any remaining double quotes. 91 114 if ( '"' != $closing_quote ) 92 $dynamic[ '/"(\s|\S|\Z)/' ] = $closing_quote . '$1'; // closing double quote 115 $dynamic[ '/"/' ] = $closing_quote; 116 117 // Single quotes followed by spaces or a period. 93 118 if ( "'" != $closing_single_quote ) 94 $dynamic[ '/\'([\s.]|\Z)/' ] = $closing_single_quote . '$1'; // closing single quote 95 96 $dynamic[ '/\b(\d+)x(\d+)\b/' ] = '$1×$2'; // 9x9 (times) 119 $dynamic[ '/\'(?=\Z|\.|' . $spaces . ')/' ] = $closing_single_quote; 97 120 98 121 $dynamic_characters = array_keys( $dynamic ); … … 135 158 _wptexturize_pushpop_element($curl, $no_texturize_shortcodes_stack, $no_texturize_shortcodes, '[', ']'); 136 159 } elseif ( empty($no_texturize_shortcodes_stack) && empty($no_texturize_tags_stack) ) { 160 137 161 // This is not a tag, nor is the texturization disabled static strings 138 162 $curl = str_replace($static_characters, $static_replacements, $curl); 163 139 164 // regular expressions 140 165 $curl = preg_replace($dynamic_characters, $dynamic_replacements, $curl); 166 167 // 9x9 (times) 168 if ( 1 === preg_match( '/(?<=\d)x\d/', $text ) ) { 169 // Searching for a digit is 10 times more expensive than for the x, so we avoid doing this one! 170 $curl = preg_replace( '/\b(\d+)x(\d+)\b/', '$1×$2', $curl ); 171 } 141 172 } 173 174 // Replace each & with & unless it already looks like an entity. 142 175 $curl = preg_replace('/&([^#])(?![a-zA-Z1-4]{1,8};)/', '&$1', $curl); 143 176 }
Note: See TracChangeset
for help on using the changeset viewer.