Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why are _ and * used equally for bold and italics in markdown?

Tags:

markdown

These two markdowns:

A Freudian slip is when you say _one thing_ but mean __your mother__
A Freudian slip is when you say *one thing* but mean **your mother**

Get marked down as equally:

A Freudian slip is when you say one thing but mean your mother

that is, both _one thing_ and *one thing* have the effect of italic. And both __your mother__ and **your mother** make the text bold.

Is there any historical/specific reason why both italics and bold have two different, synonymous, syntaxes? I could not find any other case when this happens.

The official page for Markdown states in its section Syntax:

To this end, Markdown’s syntax is comprised entirely of punctuation characters, which punctuation characters have been carefully chosen so as to look like what they mean. E.g., asterisks around a word actually look like *emphasis*. Markdown lists look like, well, lists. Even blockquotes look like quoted passages of text, assuming you’ve ever used email.

And then:

EMPHASIS
Markdown treats asterisks (*) and underscores (_) as indicators of emphasis
(...)
You can use whichever style you prefer; the lone restriction is that the same character must be used to open and close an emphasis span.

But it does mention why _ was introduced to mimic the usage of *.

like image 484
fedorqui 'SO stop harming' Avatar asked Aug 24 '16 10:08

fedorqui 'SO stop harming'


People also ask

What do asterisks do in markdown?

Italics and Bold: use asterisks and underscores to indicate spans of emphasis. Use one asterisk (or underscore) for italics and two asterisks (or two underscores) for bold. For example... Some of these words *are emphasized*.

How do you bold and italicize in markdown?

Bold & Italics: Simply enclose the text between double asterisk ( **text** ) or two underscores ( __text__ ) to bold text. To italicise text, use single asterisks ( *text* ) or underscores ( _text_ ) before and after the text.

What symbols would you use to make something bold hint use the markdown guide?

Markdown makes it especially easy to create bold and italicized text. Only asterisks are required to this end. To write in italics, add an asterisk before and after the word or words. For bold text, use two asterisks – and if you want a text to be both bold and italicized, three asterisks are necessary.

What is the main purpose of using bold italic and underline?

Content will be more scannable – When you use bold, italics, and underlines properly it will make the content more scannable to readers. They can easily identify words and phrases that carry more weight in the content.


1 Answers

Via the link fedorqui posted in his second comment, there is another link to an old email reply where Gruber motivates his choice of giving both _ and * equivalent functionality.

One of the key points is that he uses his own email conversations to conclude that rather than thinking of it in italics and bold font, people generally use either single wrapping underscores or asterisks to emphasize (<em>) a word, while they tend to use double wrapping underscores or asterisks to strongly emphasize (<strong>) a word. He uses a single * for <em> himself.

There seems to be some issues with rendering html tags in the first version I read but I found a seemingly complete archived version elsewhere. I have pasted the content below, only adding backticks to avoid SO formatting the asterisks and underscores:

John Gruber gruber at fedora.net Mon Mar 15 21:11:34 EST 2004

Previous message: asterisks as bold or italic?
Next message: asterisks as bold or italic?
Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

Merlin Mann wrote on 03/15/04 at 8:10p:

Markdown treats asterisks * and underscores _ as indicators of emphasis. Text wrapped with one * or _ will be wrapped with an HTML <em> tag; double * or _ will be wrapped with an HTML <strong> tag.

It's probably late in the game for a syntax suggestion, but I'm having a hard time getting used to *foo* making text <em> instead of <strong>.

It is late in the game for a change like this, but, trust me, even if would have had the opportunity to make this case months ago, you wouldn't have succeeded.

It's not that I think you're *wrong*, per se. But the very first feature in Markdown -- before it could even wrap <p> tags around paragraphs, even -- was a regex pattern that turned:

*this*

into:

<em>this</em>

In short, you're sort of screwed, because that's how I write, and it's how I've written since around 1992.

I wonder if my experience is unique, but I've always seen and used asterisks to make something bold while wrapping with the space/underscore would style text as italic. This goes for wikis I've used as well as text mail from my provider (http://www.fastmail.fm) (among others, I'm pretty sure).

It wasn't just based on my personal whim. If you look around, you can find support for both ways of interpretting single asterisks (em vs. strong). Textile agree with you, for example.

reStructuredText, however, agrees with me:

http://docutils.sourceforge.net/docs/rst/quickstart.html#text-styles

The actual spec for Setext says that **double** asterisks are equivalent to strong emphasis, but uses ~tildas~ for italics. (But neither of the two Setext-formatted newsletters I read, TidBITS and MDJ, use tildas for emphasis.)

I also searched through an awful lot of my email, and what I found is that both _underscores_ and *asterisks* are in wide use, but both styles tend to be used to imply normal word emphasis. E.g., if you stop thinking about "italics" and "bold", and think instead of "emphasis" and "strong emphasis", I think it's very fair to say that _this_ and *this* both imply normal emphasis.

It would certainly be faster and less-error-prone to type a single character in each case, plus it might open up the double characters for use as "-like" escape characters in the future.

I can see the case for ** and __ being somewhat reasonable escape sequences to generate single-literal characters, but I'm not the least bit persuaded by the idea that it's faster to type *this* instead of **this**.

If it's just my own peculiar habit, I can certainly un-learn it, but I'm curious if anyone else had this experience when using Markdown.

I'll emphasize that I don't think there's anything peculiar about your habit; and I'm sure others share it. And I sympathize with the fact that my decision has broken your habit. But I'm also sure that there are others whose habits match mine.

Now, of course, the other route would be to make these emphasis sequences configurable. Or, at least, to offer a few preset variations on how to interpret them.

The advantage would be that most people could get Markdown to treat word emphasis exactly how they prefer. That'd be good.

The downside would be that Markdown's format would no longer be the same everywhere. If there's just once consistent style, Markdown should work exactly the same everywhere.

It's also the case that this would add an entire layer of complexity to the software.

Sorry to disappoint,

-J.G.

like image 120
joelostblom Avatar answered Jan 01 '23 00:01

joelostblom