gpt4 book ai didi

markdown - 为什么 _ 和 * 在 Markdown 中同样用于粗体和斜体?

转载 作者:行者123 更新时间:2023-12-04 14:41:08 29 4
gpt4 key购买 nike

这两个 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**使文本加粗。

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

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.



但它确实提到了为什么 _被引入以模仿 * 的用法.

最佳答案

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

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

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

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 vs.
强的)。例如,Textile 同意你的看法。

然而,reStructuredText 同意我的看法:
http://docutils.sourceforge.net/docs/rst/quickstart.html#text-styles

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

我还搜索了很多我的电子邮件,我发现的是
这两个 _underscores_*asterisks*被广泛使用,但两者
样式往往被用来暗示正常的单词强调。例如,如果你
停止思考“斜体”和“粗体”,而是思考
“强调”和“强调”,我觉得这样说很公平
_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.

关于markdown - 为什么 _ 和 * 在 Markdown 中同样用于粗体和斜体?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39120561/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com