In `wptexturize()`, treat ` ` like whitespace when texturizing hyphens.

Adds unit tests.

Props redsweater, miqrogroove.
Fixes #23185.

Built from https://develop.svn.wordpress.org/trunk@28718


git-svn-id: http://core.svn.wordpress.org/trunk@28532 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Scott Taylor 2014-06-10 02:09:15 +00:00
parent 6cb51c9ceb
commit 12e7d6744b
1 changed files with 7 additions and 2 deletions

View File

@ -79,8 +79,8 @@ function wptexturize($text) {
$cockney = $cockneyreplace = array(); $cockney = $cockneyreplace = array();
} }
$static_characters = array_merge( array( '---', ' -- ', '--', ' - ', 'xn–', '...', '``', '\'\'', ' (tm)' ), $cockney ); $static_characters = array_merge( array( '---', '...', '``', '\'\'', ' (tm)' ), $cockney );
$static_replacements = array_merge( array( $em_dash, ' ' . $em_dash . ' ', $en_dash, ' ' . $en_dash . ' ', 'xn--', '…', $opening_quote, $closing_quote, ' ™' ), $cockneyreplace ); $static_replacements = array_merge( array( $em_dash, '…', $opening_quote, $closing_quote, ' ™' ), $cockneyreplace );
$spaces = wp_spaces_regexp(); $spaces = wp_spaces_regexp();
@ -128,6 +128,11 @@ function wptexturize($text) {
$dynamic[ '/\'(?=\Z|\.|' . $spaces . ')/' ] = $closing_single_quote; $dynamic[ '/\'(?=\Z|\.|' . $spaces . ')/' ] = $closing_single_quote;
} }
// Dashes and spaces
$dynamic[ '/(?<=' . $spaces . ')--(?=' . $spaces . ')/' ] = $em_dash;
$dynamic[ '/(?<!xn)--/' ] = $en_dash;
$dynamic[ '/(?<=' . $spaces . ')-(?=' . $spaces . ')/' ] = $en_dash;
$dynamic_characters = array_keys( $dynamic ); $dynamic_characters = array_keys( $dynamic );
$dynamic_replacements = array_values( $dynamic ); $dynamic_replacements = array_values( $dynamic );
} }