Thursday Night

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

Stop Wordpress from turning double-dash into long dash

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