From 4c067bd327fc28441bc0bc47e2d60debd504e7b7 Mon Sep 17 00:00:00 2001 From: Scott Taylor Date: Tue, 10 Jun 2014 14:22:15 +0000 Subject: [PATCH] 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. Built from https://develop.svn.wordpress.org/trunk@28726 git-svn-id: http://core.svn.wordpress.org/trunk@28540 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/formatting.php | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/wp-includes/formatting.php b/wp-includes/formatting.php index d4612c4c2b..12dc1868a3 100644 --- a/wp-includes/formatting.php +++ b/wp-includes/formatting.php @@ -91,8 +91,8 @@ function wptexturize($text) { $cockney = $cockneyreplace = array(); } - $static_characters = array_merge( array( '---', '...', '``', '\'\'', ' (tm)' ), $cockney ); - $static_replacements = array_merge( array( $em_dash, '…', $opening_quote, $closing_quote, ' ™' ), $cockneyreplace ); + $static_characters = array_merge( array( '...', '``', '\'\'', ' (tm)' ), $cockney ); + $static_replacements = array_merge( array( '…', $opening_quote, $closing_quote, ' ™' ), $cockneyreplace ); $spaces = wp_spaces_regexp(); @@ -113,9 +113,9 @@ function wptexturize($text) { $dynamic[ '/\'(?=\d)/' ] = $apos; } - // Single quote at start, or preceded by (, {, <, [, ", or spaces. + // Single quote at start, or preceded by (, {, <, [, ", -, or spaces. if ( "'" !== $opening_single_quote ) { - $dynamic[ '/(?<=\A|[([{<"]|' . $spaces . ')\'/' ] = $opening_single_quote; + $dynamic[ '/(?<=\A|[([{<"\-]|' . $spaces . ')\'/' ] = $opening_single_quote; } // Apostrophe in a word. No spaces or double apostrophes. @@ -133,9 +133,9 @@ function wptexturize($text) { $dynamic[ '/(?<=\d)\'/' ] = $prime; } - // Double quote at start, or preceded by (, {, <, [, or spaces, and not followed by spaces. + // Double quote at start, or preceded by (, {, <, [, -, or spaces, and not followed by spaces. if ( '"' !== $opening_quote ) { - $dynamic[ '/(?<=\A|[([{<]|' . $spaces . ')"(?!' . $spaces . ')/' ] = $opening_quote; + $dynamic[ '/(?<=\A|[([{<\-]|' . $spaces . ')"(?!' . $spaces . ')/' ] = $opening_quote; } // Any remaining double quotes. @@ -149,6 +149,7 @@ function wptexturize($text) { } // Dashes and spaces + $dynamic[ '/---/' ] = $em_dash; $dynamic[ '/(?<=' . $spaces . ')--(?=' . $spaces . ')/' ] = $em_dash; $dynamic[ '/(?