Emphasis with `_`

Rad Geek technophilia at radgeek.com
Tue May 24 20:55:39 EDT 2005


On Tue, 24 May 2005 20:13:11 -0400, Kyle Maxwell <krmaxwell at gmail.com>  
wrote:

> On 5/24/05, Michel Fortin <michel.fortin at michelf.com> wrote:
>> There was a discussion about this back in december on this list. Since
>> then, I got many reports about erroneous emphasis in path names, urls,
>> and function names, all caused by a `_` character. The problem mostly
>> arise in Markdown-formatted comments, where the commenter is not that
>> much familiar with the Markdown syntax.

> In particular, IMHO if the URL is marked with angle brackets, Markdown
> should disregard any underscores in it.

Well, Markdown *already* does this.  
`<http://www.url.com/with_underscores_in_it>` converts to `<a  
href="http://www.url.com/with_underscores_in_it">http://www.url.com/with_underscores_in_it</a>`,  
at least in my local copy and in the current Markdown Dingus.

The question about asymmetry was whether the rules for asterisk-emphasis  
and underscore-emphasis should be different--specifically whether it might  
be better to stop underscores from being interpreted as emphasis if they  
occur in the middle of a "word," but to leave the asterisk-emphasis rules  
as they currently are. The four cases to consider are:

1.   Asterisk word/phrase emphasis: `You *misheard* me.`
2.   Underscore word/phrase emphasis: `You _misheard_ me.`
3.   Asterisk emphasis within word: `You *mis*heard me.`
4.   Underscore emphasis within word: `You _mis_heard me.`

The basic intuition was that (1) and (2) and (3) all look like natural  
ways to mark up emphasis in plaintext, but (4) looks *weird*; underscores  
flanking a word or phrase look like emphasis, but underscores in the  
middle of a word don't look like emphasis so much as they look like breaks  
in the word. And if you make (1)-(3) all do emphasis, but not (4), this  
will make it so that you can write sentences containing (unescaped,  
uncoded) filenames like this:

	Next you want to delete the file install_my_software.php ...

... without the underscores being mistakenly treated as emphasis.

There are *already* three or four ways to successfully keep underscores  
 from being mangled by Markdown: (1) wrapping them in `code` quotes, (2)  
using backslashes to escape it (like this: `install\_my\_software.php`),  
(3) wrapping the whole block-level element in the appropriate block-level  
HTML tag (`<p>Next you want to delte the file install_my_software.php  
...</p>`; this unfortunately disables Markdown *everywhere* in the block),  
or (4) using angle brackets if the token with underscores happens to be a  
URI. The problem is that (4) is not always applicable in the first place,  
(3) has serious drawbacks, (2) is ugly, and (1) is easy to forget and not  
always semantically appropriate. Plus it's just easy to forget to do any  
of these, and a pain when you forget to do it (particularly when you  
forget to do it in comment forms, where you may not be able to fix your  
mistake at all).

For what it's worth, I (still) think that this asymmetry would be a good  
idea to include in upcoming versions of Markdown.

-- 
Charles Johnson <technophilia at radgeek.com>
AIM: AiPuch
WWW: http://www.radgeek.com/

Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/


More information about the Markdown-Discuss mailing list