为什么 _ 和 * 在降价中同样用于粗体和斜体?

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

这两个降价:

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**

被标记为平等:

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

_one thing_*one thing*都有斜体的效果。 __your mother__**your mother** 都将文本设为粗体。

斜体和粗体有两种不同的同义语法,有什么 historical/specific 的原因吗?当发生这种情况时,我找不到任何其他情况。

Markdown 的官方页面在其 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.

然后:

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.

但它确实提到了为什么引入 _ 来模仿 * 的用法。

发布 Markdown 一天后,John Gruber 发布了 long explanation 他创建 Markdown 的动机。他部分表示:

You don’t need to “preview” an email before you send it — you write it, you read it, you edit it, right there.

In fact, I love writing email. Email is my favorite writing medium. I’ve sent over 16,000 emails in the last five years. The conventions of plain text email allow me to express myself clearly and precisely, without ever getting in my way.

Thus, Markdown. Email-style writing for the web.

我现在找不到了,但我记得他在别处解释说这是他做出选择的主要因素(见 ). Many of the syntax rules were derived from the way people were already using plain text to author emails. For example, (as the OP found and noted in a comment) he stated 多年后:

Asterisks were never in doubt. Underscores were added as a secondary syntax because enough people seemed to use them in email.

我记得,星号也是如此。许多人已经在电子邮件中使用它们。

通过在他的第二条评论中发布的 link fedorqui,还有另一个 link 旧电子邮件回复,其中 Gruber 促使他选择同时提供 _* 等效功能。

其中一个关键点是他使用自己的电子邮件对话得出结论,而不是用 斜体粗体 来思考它字体,人们通常使用单环绕下划线或星号来 强调 (<em>) 一个词,而他们倾向于使用双环绕下划线或星号来 强调强调(<strong>)一个字。他自己 <em> 使用单个 *

在我阅读的第一个版本中,渲染 html 标签似乎存在一些问题,但我发现了一个 seemingly complete archived version elsewhere。我已经粘贴了下面的内容,只添加反引号以避免 SO 格式化星号和下划线:

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.

语法建议可能已经晚了,但我有一个 很难习惯 *foo* 制作文本 <em> 而不是 <strong>.

进行这样的更改已经晚了,但是,相信我,即使 几个月前就有机会提出这个案子,你 不会成功的。

并不是说我认为你 *wrong* 本身。但是第一个 Markdown 中的功能——在它甚至可以包装 <p> 标签之前 段落,甚至 -- 是一个正则表达式模式,它变成了:

*this*

进入:

<em>this</em>

简而言之,你有点搞砸了,因为我就是这样写的,而且它是 自 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).

这不仅仅是基于我个人的心血来潮。如果你环顾四周,你可以 找到对解释单个星号的两种方式的支持(em 与 强的)。纺织同意你的例子。

然而,

reStructuredText 同意我的观点:

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

Setext 的实际规范说 **double** 星号是 相当于强调,但使用 ~tildas~ 表示斜体。 (但 我读过的两份 Setext 格式的时事通讯,TidBITS 和 MDJ,使用 tildas 强调。)

我还搜索了很多我的电子邮件,我发现的是 _underscores_*asterisks* 都被广泛使用,但两者 风格往往被用来暗示正常的单词强调。例如,如果你 停止思考 "italics" 和 "bold",而是思考 "emphasis" 和 "strong emphasis",我认为这样说很公平 _this_*this* 都表示正常强调。

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.

我可以看到 **__ 有点合理的逃避 生成单文字字符的序列,但我不是最不重要的 有点相信输入 *this* 比输入更快 **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.

我要强调一下,我不认为你有什么特别之处 习惯;我相信其他人也会分享。我同情这个事实 我的决定打破了你的习惯。但我也确信那里 其他人的习惯跟我一样。

现在,当然,另一个途径是强调这些 序列可配置。或者,至少,提供一些预设变体 关于如何解读它们。

好处是大多数人都可以用 Markdown 来对待 单词强调正是他们喜欢的方式。那就好。

缺点是 Markdown 的格式将不再是 到处都一样。如果只有一次一致的风格,Markdown 应该在任何地方都完全一样。

也有这样的情况,这会增加一整层的复杂性 到软件。

抱歉让您失望了,

-J.G.