From 12e7d6744bfdffb6411e46533e03a56e2e8b15df Mon Sep 17 00:00:00 2001 From: Scott Taylor Date: Tue, 10 Jun 2014 02:09:15 +0000 Subject: [PATCH] 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 --- wp-includes/formatting.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/wp-includes/formatting.php b/wp-includes/formatting.php index a36129767f..3086a092e8 100644 --- a/wp-includes/formatting.php +++ b/wp-includes/formatting.php @@ -79,8 +79,8 @@ function wptexturize($text) { $cockney = $cockneyreplace = array(); } - $static_characters = array_merge( array( '---', ' -- ', '--', ' - ', 'xn–', '...', '``', '\'\'', ' (tm)' ), $cockney ); - $static_replacements = array_merge( array( $em_dash, ' ' . $em_dash . ' ', $en_dash, ' ' . $en_dash . ' ', 'xn--', '…', $opening_quote, $closing_quote, ' ™' ), $cockneyreplace ); + $static_characters = array_merge( array( '---', '...', '``', '\'\'', ' (tm)' ), $cockney ); + $static_replacements = array_merge( array( $em_dash, '…', $opening_quote, $closing_quote, ' ™' ), $cockneyreplace ); $spaces = wp_spaces_regexp(); @@ -128,6 +128,11 @@ function wptexturize($text) { $dynamic[ '/\'(?=\Z|\.|' . $spaces . ')/' ] = $closing_single_quote; } + // Dashes and spaces + $dynamic[ '/(?<=' . $spaces . ')--(?=' . $spaces . ')/' ] = $em_dash; + $dynamic[ '/(?