Support » How-To and Troubleshooting » Removing “emdash” replacement

Removing “emdash” replacement

  • WordPress is automatically replacing “–” with an eNdash. This makes things look like they’re hyphenated. The proper replacement would be an eMdash–but I don’t even want that. I want 2 dashes.

    The use of a double dash (“–“) rather than an emdash is a valid and traditionally-accepted practice. How do I remove this “fix” from WP? I’ve dug through both formatting.php and functions-formatting.php, but can’t find where to remove this. The only place that looks like it would fit the bill is an array dealing with the Cockney translations, and removing the emdash/endash items results in a white page.

Viewing 9 replies - 1 through 9 (of 9 total)
  • A double dash is a typewriter’s way of mimicking an em-dash, just as underlining is (or was originally, at least) a way of indicating italics. You can get a real em-dash in WordPress by using three dashes in a row—like this. You can do it with a space on either side, too — like this. It’s better than the two-dash look, anyway.

    If it’s just the dash replacement you want to get rid of, you’ll have to edit the wp_texturize() function, which is defined in wp-includes/formatting.php.

    If you’re like me and you dislike all of the replacement it does (dashes as well as ellipses, quotes, and other stuff), though, you can get rid of it all just by adding a few lines of PHP to your header file:

    remove_filter ('the_content', 'wptexturize');
    remove_filter ('comment_text', 'wptexturize');
    remove_filter ('single_post_title', 'wptexturize');
    remove_filter ('the_title', 'wptexturize');
    remove_filter ('the_excerpt', 'wptexturize');

    Satchel: “a better look” is entirely subjective. I find that the endash which WP inserts makes words look hyphenated rather than properly separated. I make use of this convention frequently and want to make sure that my readers understand what I’m typing. Unlike in print, I have little control over the font in which the readers are viewing my posts. While I may specify a font family–or even a specific font–it can be easily overridden by the reader in their preferences. Different fonts display the emdash and endash differently, and using the double-dash makes it harder to mistake one for the other. In addition, some browsers, fonts, and/or translations may not render either the em- or endash properly, but instead put in an “unknown” symbol. Using a double-dash eliminates this issue and allows for clean and acceptably-correct copy across the widest range of browsers–including lynx and other text-based browsers.

    Lavender: Thanks. I very much dislike programs which “correct” my writing style–both for the reasons listed above, and because I often write in non-standard styles for a specific reason. The wp_texturize() function is what I was looking for. I got hung up in the cockney hack 🙂

    An alternative – you could turn off the Visual Rich Editor. The regular screen doesn’t format your dashes (not as far as I know anyway – it’s never happened to me – but the VRE will.)

    my writing style–both
    Even with 2 dashes those two words look like hyphenated, whatever you say.
    Learn to use the “space” before and after them 🙂

    I was sad to see that no one gave what was to me a satisfactory answer, so I’ve created it.

    For WP 2.2 (I don’t know about other versions), Find these lines in /wp-includes/formatting.php (they’re near the top):

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

    [Sadly this page is displaying the em and en dashes, etc, rather than the code, so that’s not what the PHP file will look like. I apologize, but I don’t know how to fix it. Look for the first line, the second line will be immediately after it, though it’ll look different than this.]

    Because you’re looking to change the replacement of ‘–‘ to the EM dash (#8212) from the EN dash (#8211), simply change the third value in the second (_replacements) array. Make it say, #8212, not #8211. In other words, the lines should look like [but not really] this when you’re done:

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

    I will also note that I know that both moshu’s ( — ) and satchel’s (—) solutions work–they create the desired EM dash (though moshu’s obviously has spaces around it). I realize that blaze went a different way, but now when someone finds this page through Google (as I did) they’ll have the answer they’re seeking.

    I’d like to ressurect this thread, as, I too would like to disble WP’s automatic formatting. One can just hack the source file, or one can search for a plugin to help. (I tried the Text-Control plugin, but it’s ZIP download is corrupt.)

    However, I’d like to see a WP option to disable these character translations. Just a checkbox in the Options/Writing/Formatting block along with “Convert emoticons…” to “Convert normal text formatting to those horrible HTML entities.”

    I have been searching for a while, and have found no docs about even where to look to make such a change.

    Perhaps other have some ideas on this subject and can offer suggestions.

    Also, how about a new parameter to ‘the_content()’? Such as ‘translate=no’?

    this whole thing is really screwed up. My WP 2.3.3 install rewrites the code when I’m NOT using the visual editor too, and when I try and use <!–more–> it rewrites that too and the page never breaks…I’ll never know if anyone responds to this since these forums have no mechanism for notification at all.

    My WP 2.3.3 install rewrites the code when I’m NOT using the visual editor too, and when I try and use <!–more–> it rewrites that too and the page never breaks..

    2.5 fixed the editor. But when I used 2.3.3, I had problems with the visual editor when I turned it off at the write screen. Even off, it always seemed to muck things up anyway. Until…

    … I finally figured out how to turn it off on my User page. After that it never messed with my code again.

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Removing “emdash” replacement’ is closed to new replies.
Skip to toolbar