Ticket #4539: some_more_progress.php.diff
File some_more_progress.php.diff, 3.7 KB (added by , 14 years ago) |
---|
-
wp-testcase/test_includes_formatting.php
463 463 $this->assertEquals('‘<strong>Quoted Text</strong>’,', wptexturize("'<strong>Quoted Text</strong>',")); 464 464 $this->assertEquals('“<strong>Quoted Text</strong>”,', wptexturize('"<strong>Quoted Text</strong>",')); 465 465 } 466 466 467 //WP Ticket #15241 468 function test_many_single_quotes() { 469 $this->assertEquals('This isn’t inherently bad, but I don’t think it’s normal.', wptexturize("This isn't inherently bad, but I don't think it's normal.")); 470 } 471 472 //WP Ticket #1258 473 function test_enumeration() { 474 $this->assertEquals("‘products’, ‘services’", wptexturize("'products', 'services'")); 475 $this->assertEquals("‘hello’, ‘world’, ’tis ", wptexturize("'hello', 'world', 'tis ")); 476 } 477 478 //WP Ticket #11275 479 function test_quoting() { 480 $this->assertEquals('She said—“No!”', wptexturize('She said—"No!"')); 481 } 482 467 483 function test_x() { 468 484 $this->assertEquals('14×24', wptexturize("14x24")); 469 485 } -
wordpress/wp-includes/formatting.php
56 56 $static_characters = array_merge(array('---', ' -- ', '--', ' - ', 'xn–', '...', '``', '\'\'', ' (tm)'), $cockney); 57 57 $static_replacements = array_merge(array('—', ' — ', '–', ' – ', 'xn--', '…', $opening_quote, $closing_quote, ' ™'), $cockneyreplace); 58 58 59 $dynamic_ characters = array('/\'(\d\d(?:’|\')?s)/', '/\'(\d)/', '/(\s|\A|[([{<]|")\'/', '/(\d)"/', '/(\d)\'/', '/(\S)\'([^\'\s])/', '/(\s|\A|[([{<])"(?!\s)/', '/"(\s|\S|\Z)/', '/\'([\s.]|\Z)/', '/\b(\d+)x(\d+)\b/');60 $dynamic_replacements = array('’$1','’$1', '$1‘', '$1″', '$1′', '$1’$2', '$1' . $opening_quote . '$2', $closing_quote . '$1', '’$1', '$1×$2');59 $dynamic_map = array( 60 '/\'(\d)/' => '’$1', // '99 61 61 62 '/(\w)\'(\w)/' => '$1’$2', // test's 63 64 '/\'([^\']*)\'/' => '‘$1’', // 'asd' 65 '/"([^"]*)"/' => $opening_quote . '$1' . $closing_quote, // "qwe" 66 67 '/(\d)\'/' => '$1′', // 9' 68 '/(\d)"/' => '$1″', // 9" 69 70 '/\b(\d+)x(\d+)\b/' => '$1×$2' // 97x34 71 ); 72 73 $dynamic_characters = array_keys($dynamic_map); 74 $dynamic_replacements = array_values($dynamic_map); 75 62 76 $static_setup = true; 63 77 } 64 78 … … 70 84 $no_texturize_tags_stack = array(); 71 85 $no_texturize_shortcodes_stack = array(); 72 86 87 $single_quote_state = '‘'; 88 $double_quote_state = $opening_quote; 89 73 90 for ( $i = 0; $i < $stop; $i++ ) { 74 91 $curl = $textarr[$i]; 75 92 … … 80 97 $curl = str_replace($static_characters, $static_replacements, $curl); 81 98 // regular expressions 82 99 $curl = preg_replace($dynamic_characters, $dynamic_replacements, $curl); 100 // quotes that span multiple tags & shortcodes 101 while (($pos = strpos($curl, '\'')) !== FALSE) { 102 $curl = preg_replace('/\'/', $single_quote_state, $curl); 103 $single_quote_state = (($single_quote_state == '‘') ? '’' : '‘'); 104 } 105 while (($pos = strpos($curl, '"')) !== FALSE) { 106 $curl = preg_replace('/"/', $double_quote_state, $curl); 107 $double_quote_state = (($double_quote_state == $opening_quote) ? $closing_quote : $opening_quote); 108 } 83 109 } elseif (!empty($curl)) { 84 110 /* 85 111 * Only call _wptexturize_pushpop_element if first char is correct