WordPress.org

Make WordPress Core

Ticket #23185: FixHyphens.diff

File FixHyphens.diff, 1.4 KB (added by redsweater, 5 years ago)
  • 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('xn–', '...', '``', '\'\'', ' (tm)' ), $cockney );
     74                $static_replacements = array_merge( array('xn--', '…', $opening_quote, $closing_quote, ' ™' ), $cockneyreplace );
    7575
    7676                $dynamic = array();
    7777                if ( "'" != $apos ) {
     
    9595
    9696                $dynamic[ '/\b(\d+)x(\d+)\b/'              ] = '$1×$2'; // 9x9 (times)
    9797
     98                $dynamic[ '/---/' ] = $em_dash; // Triple-hyphen becomes em dash
     99
     100                // Hyphen or double-hyphen surrounded by space become en or em dash
     101                $dynamic[ '/( | )-( | )/' ] = '$1' . $en_dash . '$2';
     102                $dynamic[ '/( | )--( | )/' ] = '$1' . $em_dash . '$2';
     103
     104                $dynamic[ '/--/' ] = $en_dash; // Remaining double-hyphens become en-dash
     105
    98106                $dynamic_characters = array_keys( $dynamic );
    99107                $dynamic_replacements = array_values( $dynamic );
    100108        }