diff --git a/src/wp-includes/formatting.php b/src/wp-includes/formatting.php index f8d1e74264..2bfb1376b6 100644 --- a/src/wp-includes/formatting.php +++ b/src/wp-includes/formatting.php @@ -174,9 +174,9 @@ function wptexturize($text, $reset = false) { // Dashes and spaces $dynamic[ '/---/' ] = $em_dash; - $dynamic[ '/(?<=' . $spaces . ')--(?=' . $spaces . ')/' ] = $em_dash; + $dynamic[ '/(?<=^|' . $spaces . ')--(?=$|' . $spaces . ')/' ] = $em_dash; $dynamic[ '/(?assertEquals( "$nbsp— ", wptexturize( "$nbsp-- ") ); } + /** + * @ticket 31030 + */ + function test_hyphens_at_start_and_end() { + $this->assertEquals( '– ', wptexturize( '- ' ) ); + $this->assertEquals( '– –', wptexturize( '- -' ) ); + $this->assertEquals( ' –', wptexturize( ' -' ) ); + + $this->assertEquals( '— ', wptexturize( '-- ' ) ); + $this->assertEquals( '— —', wptexturize( '-- --' ) ); + $this->assertEquals( ' —', wptexturize( ' --' ) ); + } + /** * Test spaces around quotes. *