Thursday Night

Paul Betts’s personal website / blog / what-have-you

Stop Wordpress from turning double-dash into long dash

2 comments

As an aside, Wordpress has this handy “feature” that automatically converts two dashes (’–’) into an emphasized dash (’–’, U+2013). While nicer typographically, this completely breaks code samples of any kind, as people will copy-paste it and get very confusing errors. I can’t believe the Wordpress coders wouldn’t get bit by this themselves. Alas, here’s how to fix it. Open up wordpress/wp-includes/formatting.php and find these lines near the top of the file, in wp_texturize

$static_characters = array_merge(array(‘—’, ‘ — ‘, ‘–’, ‘xn–’, ‘…’, ‘“’, \’s’, \’\’, ‘ ™’), $cockney);
$static_replacements = array_merge(array(‘—’, ‘ — ‘, ‘–’, ‘xn--’, ‘…’, ‘“’, ‘’s’, ‘”’, ‘ ™’), $cockneyreplace);

Comment out the first four elements of both arrays, so that it looks like this:

$static_characters = array_merge(array( /* ‘—’, ‘ — ‘, ‘–’, ‘xn–’, */ ‘…’, ‘“’, \’s’, \’\’, ‘ ™’), $cockney);
$static_replacements = array_merge(array(/* ‘—’, ‘ — ‘, ‘–’, ‘xn--’, */ ‘…’, ‘“’, ‘’s’, ‘”’, ‘ ™’), $cockneyreplace);

This fix applies retroactively too, so you don’t have to go back and edit old entries, all of them will be updated automatically

Written by Paul Betts

June 1st, 2007 at 11:23 am

2 Responses to 'Stop Wordpress from turning double-dash into long dash'

Subscribe to comments with RSS or TrackBack to 'Stop Wordpress from turning double-dash into long dash'.

  1. I didn’t realise it was dumb enough to do that.

    If you open a ticket on Trac, they might fix it. (Or, I might fix it if I get my head around the logic!)

    Jeremy

    1 Jun 07 at 5:57 pm

  2. Thanks, this was making my flash imports crazy.
    It’s weird though, SwfObject 2.1 uses “” for static embedding, and alot of people use SwfObject… this should definitely be a setting.

    Ari

    25 Mar 09 at 9:15 am

Leave a Reply