WordPress.org

Ready to get started?Download WordPress

Forums

em-dash replacement (5 posts)

  1. marky
    Member
    Posted 10 years ago #

    I appreciate the punctuation filter, but I'd prefer that a double dash (--) be replaced by an em-dash, not an en-dash. Is there any way to configure WP to do this?

  2. miahz
    Member
    Posted 10 years ago #

    you can enable the textile plugin, which, i believe, uses double dashes for em-dashes.

  3. marky
    Member
    Posted 10 years ago #

    The problem is Textile adds other strange markup and features I don't really want. For example, in the following sentence, "This is--and I can't emphasise this enough--a sentence," Textile assumes I want to wrap del tags around the inner phrase rather than simply replace them with em-dashes. (Yes, I'm from the puncutation school that doesn't surround em-dashes with spaces :-)
    Incidentally, I did find a way to alter the default filter to do what I want. There's a very simple mapping at the beginning of the functions-fomatting.php file that can be altered. :-)

  4. iamPariah
    Member
    Posted 9 years ago #

    I'm a little late to this discussion, but I wholly agree with Marky. Em dashes indicate related but separate thoughts and clauses from the surrounding sentence. The space-em-space convention is a copywriting device popular online because it allows the sentence to wrap at the em placement if needed--which, of course, makes it useful but not grammatically correct.

    I too am annoyed by WordPress making the assumption that a double-hyphen should be an en dash and a triple-hyphen an em dash. Who types that way?

    I'm going to troll around and play with the code to see if I can find where to fix this erroneous text replacement implementation.

  5. iamPariah
    Member
    Posted 9 years ago #

    In WP 1.5, open \wp-includes\functions-formatting.php and look for the below lines:

    $curl = str_replace('---', '& #8212;', $curl);
    $curl = str_replace(' -- ', ' & #8212; ', $curl);
    $curl = str_replace('--', '& #8211;', $curl);

    Replace with:

    $curl = str_replace('--', '& #8212;', $curl);
    $curl = str_replace(' -- ', ' & #8212; ', $curl);
    $curl = str_replace('---', '& #8211;', $curl);

    Remember to take out the space between & and # in each of the above; the space was necessary to make it display the code here.

    8212 is the entity for em dashes, 8211 the entity for en dashes. I changed my ens to a triple-hyphen, but you may want something else (for example, all hyphens).`

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.