Interesting Issue

John Gruber gruber at fedora.net
Thu Dec 9 01:01:26 EST 2004


Christopher Biagini <chris at assortedgeekery.com> wrote on 12/09/04 at 12:09am:

> I'm writing a paper for one of my classes, and I quote some manpages 
> that make mention of constants with underscores in their 
> names--Markdown treats the underscores as the start and end of 
> emphasized text.
>
> [...]
>
> Which isn't quite what I had in mind. Is this an unfortunate 
> consequence of proper behavior, or a bug?

Unfortunate consequence.

What you can do is backslash-escape the literal underscores. By
default, underscores and asterisks are emphasis delimiters in
Markdown, not literal punctuation characters. So you could write:

    ... blah blah PTHREAD\_SCOPE\_SYSTEM ...

to produce:

    ... blah blah PTHREAD_SCOPE_SYSTEM ...

in your output.

A lot of times, especially with underscores, they're being used in a
code context, so it might be appropriate to wrap them in code spans:

    ... blah blah `PTHREAD\_SCOPE\_SYSTEM` ...

which produces:

    ... blah blah <code>PTHREAD_SCOPE_SYSTEM</code> ...


* * *

The problem here is that it's very natural to just instinctively
write what you mean. Human minds are so adept at pattern and
language recognition that we don't even think of it as a problem.
I can write this:

    No, *you* told me that *'s are called "asterisks".

Or:

    I _never_ told you that $THIS_VARIABLE or $THAT_VARIABLE could
    be modified in the middle of the loop.

and you know exactly what I mean with those '*' and '_' characters.
You don't even have to think about it. But it's devilishly tricky to
get a computer program to understand the difference contexts there.

Some people have suggested that Markdown should only allow emphasis
to start and end at the beginning of "words", so that you can use
underscores mid-word without triggering <em> tags. But I think
that's too strict, because sometimes you want to emphasis only part
of a word:

    un*fucking*believable

Maybe there's some additional cleverness we can add, however.

-J.G.



More information about the Markdown-discuss mailing list