Make WordPress Core


Ignore:
Timestamp:
06/10/2014 02:21:36 PM (12 years ago)
Author:
wonderboymusic
Message:

In wptexturize(), allow dashes before and after curly quotes. Example: This is what she said---"Wow that is cool."

Adds unit tests.

Props adamsilverstein, miqrogroove.
Fixes #20342.

File:
1 edited

Legend:

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

    r28725 r28726  
    9292                }
    9393
    94                 $static_characters = array_merge( array( '---', '...', '``', '\'\'', ' (tm)' ), $cockney );
    95                 $static_replacements = array_merge( array( $em_dash, '…', $opening_quote, $closing_quote, ' ™' ), $cockneyreplace );
     94                $static_characters = array_merge( array( '...', '``', '\'\'', ' (tm)' ), $cockney );
     95                $static_replacements = array_merge( array( '…', $opening_quote, $closing_quote, ' ™' ), $cockneyreplace );
    9696
    9797                $spaces = wp_spaces_regexp();
     
    114114                }
    115115
    116                 // Single quote at start, or preceded by (, {, <, [, ", or spaces.
     116                // Single quote at start, or preceded by (, {, <, [, ", -, or spaces.
    117117                if ( "'" !== $opening_single_quote ) {
    118                         $dynamic[ '/(?<=\A|[([{<"]|' . $spaces . ')\'/' ] = $opening_single_quote;
     118                        $dynamic[ '/(?<=\A|[([{<"\-]|' . $spaces . ')\'/' ] = $opening_single_quote;
    119119                }
    120120
     
    134134                }
    135135
    136                 // Double quote at start, or preceded by (, {, <, [, or spaces, and not followed by spaces.
     136                // Double quote at start, or preceded by (, {, <, [, -, or spaces, and not followed by spaces.
    137137                if ( '"' !== $opening_quote ) {
    138                         $dynamic[ '/(?<=\A|[([{<]|' . $spaces . ')"(?!' . $spaces . ')/' ] = $opening_quote;
     138                        $dynamic[ '/(?<=\A|[([{<\-]|' . $spaces . ')"(?!' . $spaces . ')/' ] = $opening_quote;
    139139                }
    140140
     
    150150
    151151                // Dashes and spaces
     152                $dynamic[ '/---/' ] = $em_dash;
    152153                $dynamic[ '/(?<=' . $spaces . ')--(?=' . $spaces . ')/' ] = $em_dash;
    153154                $dynamic[ '/(?<!xn)--/' ] = $en_dash;
Note: See TracChangeset for help on using the changeset viewer.