WordPress.org

Make WordPress Core

Changeset 28765


Ignore:
Timestamp:
06/17/2014 08:18:38 PM (7 years ago)
Author:
wonderboymusic
Message:

Fix abbreviations mixed with quotes, example: '99% of people'.
Add/alter unit tests.

Props miqrogroove.
Fixes #26850.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/formatting.php

    r28764 r28765  
    112112        }
    113113
    114         // '99 '99s '99's (apostrophe)  But never '9 or '999 or '99.0.
     114        // '99 '99s '99's (apostrophe)  But never '9 or '99% or '999 or '99.0.
    115115        if ( "'" !== $apos ) {
    116             $dynamic[ '/\'(?=\d\d(?:\Z|(?!\d|[.,]\d)))/' ] = $apos;
     116            $dynamic[ '/\'(?=\d\d(?:\Z|(?![%\d]|[.,]\d)))/' ] = $apos;
    117117        }
    118118
    119119        // Quoted Numbers like "42" or '42.00'
    120120        if ( '"' !== $opening_quote && '"' !== $closing_quote ) {
    121             $dynamic[ '/(?<=\A|' . $spaces . ')"(\d[\d\.\,]*)"/' ] = $opening_quote . '$1' . $closing_quote;
     121            $dynamic[ '/(?<=\A|' . $spaces . ')"(\d[.,\d]*)"/' ] = $opening_quote . '$1' . $closing_quote;
    122122        }
    123123        if ( "'" !== $opening_single_quote && "'" !== $closing_single_quote ) {
    124             $dynamic[ '/(?<=\A|' . $spaces . ')\'(\d[\d\.\,]*)\'/' ] = $opening_single_quote . '$1' . $closing_single_quote;
     124            $dynamic[ '/(?<=\A|' . $spaces . ')\'(\d[.,\d]*)\'/' ] = $opening_single_quote . '$1' . $closing_single_quote;
    125125        }
    126126
  • trunk/tests/phpunit/tests/formatting/WPTexturize.php

    r28764 r28765  
    314314            ),
    315315            array(
    316                 "according to our source, '33% of all students scored less than 50' on the test.", // Apostrophes and primes have priority over quotes
    317                 "according to our source, &#8217;33% of all students scored less than 50&#8242; on the test.",
     316                "according to our source, '33 students scored less than 50' on the test.", // Apostrophes and primes have priority over quotes
     317                "according to our source, &#8217;33 students scored less than 50&#8242; on the test.",
    318318            ),
    319319        );
     
    10611061            ),
    10621062            array(
    1063                 "word '99's word", // Is this correct?
    1064                 "word &#8216;99&#8217;s word",
     1063                "word '99's word",
     1064                "word &#8217;99&#8217;s word",
    10651065            ),
    10661066            array(
    10671067                "word '99'samsonite",
    1068                 "word &#8216;99&#8217;samsonite",
     1068                "word &#8217;99&#8217;samsonite",
    10691069            ),
    10701070        );
     
    13401340                "word '999 word", // Does not match the apos pattern, should be opening quote.
    13411341                "word &#8216;999 word",
     1342            ),
     1343            array(
     1344                "word '99% word",
     1345                "word &#8216;99% word",
    13421346            ),
    13431347            array(
Note: See TracChangeset for help on using the changeset viewer.