Changeset 28971
- Timestamp:
- 07/03/2014 04:21:18 PM (11 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/formatting.php
r28929 r28971 105 105 // '99' and '99" are ambiguous among other patterns; assume it's an abbreviated year at the end of a quotation. 106 106 if ( "'" !== $apos || "'" !== $closing_single_quote ) { 107 $dynamic[ '/\'(\d\d)\'(?=\Z|[.,)} >\-\]]|' . $spaces . ')/' ] = $apos . '$1' . $closing_single_quote;107 $dynamic[ '/\'(\d\d)\'(?=\Z|[.,)}\-\]]|>|' . $spaces . ')/' ] = $apos . '$1' . $closing_single_quote; 108 108 } 109 110 109 if ( "'" !== $apos || '"' !== $closing_quote ) { 111 $dynamic[ '/\'(\d\d)"(?=\Z|[.,)} >\-\]]|' . $spaces . ')/' ] = $apos . '$1' . $closing_quote;110 $dynamic[ '/\'(\d\d)"(?=\Z|[.,)}\-\]]|>|' . $spaces . ')/' ] = $apos . '$1' . $closing_quote; 112 111 } 113 112 … … 127 126 // Single quote at start, or preceded by (, {, <, [, ", -, or spaces. 128 127 if ( "'" !== $opening_single_quote ) { 129 $dynamic[ '/(?<=\A|[([{ <"\-]|' . $spaces . ')\'/' ] = $opening_single_quote;128 $dynamic[ '/(?<=\A|[([{"\-]|<|' . $spaces . ')\'/' ] = $opening_single_quote; 130 129 } 131 130 132 131 // Apostrophe in a word. No spaces, double apostrophes, or other punctuation. 133 132 if ( "'" !== $apos ) { 134 $dynamic[ '/(?<!' . $spaces . ')\'(?!\Z|[.,:;"\'(){} <>[\]\-]|' . $spaces . ')/' ] = $apos;133 $dynamic[ '/(?<!' . $spaces . ')\'(?!\Z|[.,:;"\'(){}[\]\-]|&[lg]t;|' . $spaces . ')/' ] = $apos; 135 134 } 136 135 … … 147 146 // Double quote at start, or preceded by (, {, <, [, -, or spaces, and not followed by spaces. 148 147 if ( '"' !== $opening_quote ) { 149 $dynamic[ '/(?<=\A|[([{ <\-]|' . $spaces . ')"(?!' . $spaces . ')/' ] = $opening_quote;148 $dynamic[ '/(?<=\A|[([{\-]|<|' . $spaces . ')"(?!' . $spaces . ')/' ] = $opening_quote; 150 149 } 151 150 … … 157 156 // Single quotes followed by spaces or ending punctuation. 158 157 if ( "'" !== $closing_single_quote ) { 159 $dynamic[ '/\'(?=\Z|[.,)} >\-\]]|' . $spaces . ')/' ] = $closing_single_quote;158 $dynamic[ '/\'(?=\Z|[.,)}\-\]]|>|' . $spaces . ')/' ] = $closing_single_quote; 160 159 } 161 160 -
trunk/tests/phpunit/tests/formatting/WPTexturize.php
r28860 r28971 118 118 //$this->assertEquals('“Class of 99”', wptexturize("\"Class of 99\"")); 119 119 $this->assertEquals('“Class of ’99”', wptexturize("\"Class of '99\"")); 120 $this->assertEquals('{“Class of ’99”}', wptexturize("{\"Class of '99\"}")); 121 $this->assertEquals(' “Class of ’99” ', wptexturize(" \"Class of '99\" ")); 122 $this->assertEquals('}”Class of ’99″{', wptexturize("}\"Class of '99\"{")); // Not a quotation, may be between two other quotations. 120 123 } 121 124 … … 347 350 ), 348 351 array( 349 "word <'word word", // Invalid HTML input ?350 "word <̵ 6;word word",351 ), 352 array( 353 "word <'word word", // Valid HTML input triggers the apos in a word pattern354 "word <̵ 7;word word",352 "word <'word word", // Invalid HTML input triggers the apos in a word pattern. 353 "word <’word word", 354 ), 355 array( 356 "word <'word word", // Valid HTML input makes curly quotes. 357 "word <‘word word", 355 358 ), 356 359 array( … … 376 379 array( 377 380 "word<'word word", 378 "word<̵ 6;word word",381 "word<’word word", 379 382 ), 380 383 array( 381 384 "word<'word word", 382 "word<̵ 7;word word",385 "word<‘word word", 383 386 ), 384 387 array( … … 403 406 ), 404 407 array( 405 "word <' word word", // Invalid HTML input?406 "word <̵ 6; word word",407 ), 408 array( 409 "word <' word word", // Valid HTML input triggers the closing single quote here410 "word <̵ 7; word word",408 "word <' word word", 409 "word <’ word word", 410 ), 411 array( 412 "word <' word word", 413 "word <‘ word word", 411 414 ), 412 415 array( … … 432 435 array( 433 436 "word<' word word", 434 "word<̵ 6; word word",437 "word<’ word word", 435 438 ), 436 439 array( 437 440 "word<' word word", 438 "word<̵ 7; word word",441 "word<‘ word word", 439 442 ), 440 443 array( … … 534 537 ), 535 538 array( 536 "word word'. word", // Quotes with outside punctuation could end with apostrophes instead of closing quotes (may affect i18n) 537 "word word’. word", 538 ), 539 array( 540 "word ]'. word", 541 "word ]’. word", 542 ), 543 array( 544 "word )'. word", 545 "word )’. word", 546 ), 547 array( 548 "word }'. word", 549 "word }’. word", 550 ), 551 array( 552 "word >'. word", // Not tested 553 "word >’. word", 554 ), 555 array( 556 "word >'. word", 557 "word >’. word", 558 ), 559 ); 560 } 561 562 /** 563 * Double quote after a space or ([{< becomes “ (opening_quote) if not followed by spaces 539 "word'[ word", // Apostrophes are never followed by opening punctuation. 540 "word'[ word", 541 ), 542 array( 543 "word'( word", 544 "word'( word", 545 ), 546 array( 547 "word'{ word", 548 "word'{ word", 549 ), 550 array( 551 "word'< word", 552 "word'< word", 553 ), 554 array( 555 "word'< word", // Invalid HTML input does trigger the apos pattern. 556 "word’< word", 557 ), 558 ); 559 } 560 561 /** 562 * Double quote after a space or ([-{< becomes “ (opening_quote) if not followed by spaces 564 563 * 565 564 * Checks all baseline patterns. If anything ever changes in wptexturize(), these tests may fail. … … 587 586 ), 588 587 array( 589 'word <"word word', // Invalid HTML input ?590 'word <̶ 0;word word',591 ), 592 array( 593 'word <"word word', // Valid HTML input triggers the closing quote pattern594 'word <̶ 1;word word',588 'word <"word word', // Invalid HTML input triggers the closing quote pattern. 589 'word <”word word', 590 ), 591 array( 592 'word <"word word', 593 'word <“word word', 595 594 ), 596 595 array( … … 599 598 ), 600 599 array( 600 'word -"word word', 601 'word -“word word', 602 ), 603 array( 604 'word-"word word', 605 'word-“word word', 606 ), 607 array( 601 608 '"word word', 602 609 '“word word', … … 611 618 ), 612 619 array( 613 'word<"word word', // Invalid HTML input?614 'word<̶ 0;word word',615 ), 616 array( 617 'word<"word word', // Valid HTML input triggers the closing quote pattern618 'word<̶ 1;word word',620 'word<"word word', 621 'word<”word word', 622 ), 623 array( 624 'word<"word word', 625 'word<“word word', 619 626 ), 620 627 array( … … 699 706 700 707 /** 701 * Test that single quotes followed by a space or a periodbecome ’ (closing_single_quote)708 * Test that single quotes followed by a space or .,-)}]> become ’ (closing_single_quote) 702 709 * 703 710 * Checks all baseline patterns. If anything ever changes in wptexturize(), these tests may fail. … … 727 734 "word word', she said", 728 735 "word word’, she said", 736 ), 737 array( 738 "word word'- word", 739 "word word’- word", 740 ), 741 array( 742 "word word') word", 743 "word word’) word", 744 ), 745 array( 746 "word word'} word", 747 "word word’} word", 748 ), 749 array( 750 "word word'] word", 751 "word word’] word", 752 ), 753 array( 754 "word word'> word", 755 "word word’> word", 729 756 ), 730 757 array(
Note: See TracChangeset
for help on using the changeset viewer.