Make WordPress Core

Ticket #23185: miqro-23185.patch

File miqro-23185.patch, 2.9 KB (added by miqrogroove, 11 years ago)
  • src/wp-includes/formatting.php

     
    7070                        $cockney = $cockneyreplace = array();
    7171                }
    7272
    73                 $static_characters = array_merge( array( '---', ' -- ', '--', ' - ', 'xn–', '...', '``', '\'\'', ' (tm)' ), $cockney );
    74                 $static_replacements = array_merge( array( $em_dash, ' ' . $em_dash . ' ', $en_dash, ' ' . $en_dash . ' ', 'xn--', '…', $opening_quote, $closing_quote, ' ™' ), $cockneyreplace );
     73                $static_characters = array_merge( array( '---', '...', '``', '\'\'', ' (tm)' ), $cockney );
     74                $static_replacements = array_merge( array( $em_dash, '…', $opening_quote, $closing_quote, ' ™' ), $cockneyreplace );
    7575
    7676                /*
    7777                 * Regex for common whitespace characters.
     
    126126                        $dynamic[ '/\'(?=\Z|\.|' . $spaces . ')/' ] = $closing_single_quote;
    127127                }
    128128
     129                // Dashes and spaces
     130                $dynamic[ '/(?<=' . $spaces . ')--(?=' . $spaces . ')/' ] = $em_dash;
     131                $dynamic[ '/(?<!xn)--/' ] = $en_dash;
     132                $dynamic[ '/(?<=' . $spaces . ')-(?=' . $spaces . ')/' ] = $en_dash;
     133
    129134                $dynamic_characters = array_keys( $dynamic );
    130135                $dynamic_replacements = array_values( $dynamic );
    131136        }
  • tests/phpunit/tests/formatting/WPTexturize.php

     
    187187         * @ticket 23185
    188188         */
    189189        function test_spaces_around_hyphens() {
     190                $nbsp = "\xC2\xA0";
     191
    190192                $this->assertEquals( ' &#8211; ', wptexturize( ' - ' ) );
    191193                $this->assertEquals( '&nbsp;&#8211;&nbsp;', wptexturize( '&nbsp;-&nbsp;' ) );
    192194                $this->assertEquals( ' &#8211;&nbsp;', wptexturize( ' -&nbsp;' ) );
    193195                $this->assertEquals( '&nbsp;&#8211; ', wptexturize( '&nbsp;- ') );
     196                $this->assertEquals( "$nbsp&#8211;$nbsp", wptexturize( "$nbsp-$nbsp" ) );
     197                $this->assertEquals( " &#8211;$nbsp", wptexturize( " -$nbsp" ) );
     198                $this->assertEquals( "$nbsp&#8211; ", wptexturize( "$nbsp- ") );
    194199
    195200                $this->assertEquals( ' &#8212; ', wptexturize( ' -- ' ) );
    196201                $this->assertEquals( '&nbsp;&#8212;&nbsp;', wptexturize( '&nbsp;--&nbsp;' ) );
    197202                $this->assertEquals( ' &#8212;&nbsp;', wptexturize( ' --&nbsp;' ) );
    198203                $this->assertEquals( '&nbsp;&#8212; ', wptexturize( '&nbsp;-- ') );
     204                $this->assertEquals( "$nbsp&#8212;$nbsp", wptexturize( "$nbsp--$nbsp" ) );
     205                $this->assertEquals( " &#8212;$nbsp", wptexturize( " --$nbsp" ) );
     206                $this->assertEquals( "$nbsp&#8212; ", wptexturize( "$nbsp-- ") );
    199207        }
    200208
    201209        /**
     
    929937                        ),
    930938                        array(
    931939                                "word xn&#8211; word",
    932                                 "word xn-- word",
     940                                "word xn&#8211; word",
    933941                        ),
    934942                        array(
    935943                                "wordxn&#8211;word",
     944                                "wordxn&#8211;word",
     945                        ),
     946                        array(
    936947                                "wordxn--word",
     948                                "wordxn--word",
    937949                        ),
    938950                );
    939951        }