WordPress and Dashes

In my last post I posted two mozconfig options, both of which involved a dash followed by a dash. I wrote that part of the blog entry like this:

<code>ac_add_options --enable-foo
ac_add_options --enable-bar</code>

Once I posted that, people started complaining that I only put one dash before “enable-bar” while “enable-foo” was fine, so I went to fix it. When I edited the post I saw that there actually were two dashes before “enable-bar” already, so there was nothing to fix. Why was WordPress displaying double dashes on the second line of a code section as one dash but doing it fine on the first line?

I rewrote that part of the blog entry like this and everything displays correctly.

<code>ac_add_options --enable-foo</code>
<code>ac_add_options --enable-bar</code>

What is up with that?

5 thoughts on “WordPress and Dashes

  1. If only ASCII is available, a double endash is often used in place of an to an emdash, so WP thinks you meant to type an emdash but didn’t know how.

  2. My guess (after grabbing the WordPress source and searching for “–“) would be that the problem is in the fragile-looking parser in wptexturize. After a code-start-tag, no string replacement occurs until the next tag (regardless if it is an end-code-tag or not). So in your first version, the br-tag is turning the string replacement on again.

  3. double dash is a sort of shortcut or macro for em-dash in the language used by WP to generate the code (MarkDown ?) If you put it in code blocks like you did in this post, then no conversion is done.

  4. Philippe is exactly right. I believe Markdown is on by default in WordPress (both the hosted blog, like you have, and in the standalone install), and two en dashes (or hyphens) are taken to mean an em dash.

    If you don’t like it, you may be able to turn Markdown off, but a better solution is probably to enclose your code snippets in CODE tags, as you found for your workaround.

    cl

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s