Markdown 学习笔记(一)

标题

要创建标题,请#在单词或短语前面添加数字符号 ( )。您使用的数字符号数量应与标题级别相对应。例如,要创建三级标题 ( <h3>),请使用三个数字符号(例如### My Header)。

MarkdownHTML
# Heading level 1<h1>Heading level 1</h1>
## Heading level 2<h2>Heading level 2</h2>
### Heading level 3<h3>Heading level 3</h3>
#### Heading level 4<h4>Heading level 4</h4>
##### Heading level 5<h5>Heading level 5</h5>
###### Heading level 6<h6>Heading level 6</h6>

替代语法

或者,在文本下方的行中,添加任意数量的==1 级标题字符或--2 级标题字符。

MarkdownHTML
Heading level 1
===============
<h1>Heading level 1</h1>
Heading level 2
---------------
<h2>Heading level 2</h2>

标题最佳实践

Markdown 应用程序对于如何处理数字符号 ( #) 和标题名称之间缺少的空格意见不一。出于兼容性考虑,请始终在数字符号和标题名称之间留一个空格。

✅ 这样做❌ 不要这样做
# Here's a Heading
 
#Here's a Heading

为了兼容性,您还应该在标题前后放置空行。

✅ 这样做❌ 不要这样做
Try to put a blank line before...

# Heading

...and after a heading.
Without blank lines, this might not look right.
# Heading
Don't do this!

段落

要创建段落,请使用空行分隔一行或多行文本。

MarkdownHTML
I really like using Markdown.

I think I'll use it to format all of my documents from now on.
<p>I really like using Markdown.</p>

<p>I think I'll use it to format all of my documents from now on.</p>

段落最佳实践

除非段落在列表中,否则不要使用空格或制表符缩进段落。

 注意:如果需要在输出中缩进段落,请参阅有关如何缩进(tab)的部分。
✅ 这样做❌ 不要这样做
Don't put tabs or spaces in front of your paragraphs.

Keep lines left-aligned like this.

 

    This can result in unexpected formatting problems.

  Don't add tabs or spaces in front of paragraphs.

换行符

要创建换行符或新行 ( <br>),请用两个或更多空格结束一行,然后键入回车键。

MarkdownHTML渲染输出
This is the first line.  
And this is the second line.
<p>This is the first line.<br>
And this is the second line.</p>

这是第一行。
这是第二行。

换行最佳实践

几乎每个 Markdown 应用程序中都可以使用两个或更多空格(通常称为“尾随空格”)作为换行符,但这是存在争议的。在编辑器中很难看到尾随空格,许多人会无意或故意在每个句子后放两个空格。因此,您可能希望使用除尾随空格以外的其他符号作为换行符。如果您的 Markdown 应用程序支持 HTML,则可以使用<br>HTML 标签。

<br>为了兼容性,请在行尾使用尾随空格或HTML 标签。

还有两个我不推荐使用的选项。CommonMark 和其他一些轻量级标记语言允许您\在行尾输入反斜杠 ( ),但并非所有 Markdown 应用程序都支持此功能,因此从兼容性角度来看,这不是一个好选择。至少有几种轻量级标记语言不需要在行尾输入任何内容 - 只需输入回车键即可创建换行符。

✅ 这样做❌ 不要这样做
First line with two spaces after.  
And the next line.

First line with the HTML tag after.<br>
And the next line.

 
First line with a backslash after.\
And the next line.

First line with nothing after.
And the next line.

强调

粗体

要加粗单词中间部分以示强调,请在字母周围添加两个星号(不带空格)

MarkdownHTMLRendered Output
I just love **bold text**.I just love <strong>bold text</strong>.I just love bold text.
I just love __bold text__.I just love <strong>bold text</strong>.I just love bold text.
Love**is**boldLove<strong>is</strong>boldLoveisbold

粗体的最佳实践

✅ 这样做❌ 不要这样做
Love**is**boldLove__is__bold

斜体

要使单词中间部分变成斜体以示强调,请在字母周围添加一个星号(不带空格)

MarkdownHTML渲染输出
Italicized text is the *cat's meow*.Italicized text is the <em>cat's meow</em>.斜体文字是猫叫声
Italicized text is the _cat's meow_.Italicized text is the <em>cat's meow</em>.斜体文字是猫叫声
A*cat*meowA<em>cat</em>meow一只猫喵喵叫

斜体的最佳实践

✅ 这样做❌ 不要这样做
A*cat*meowA_cat_meow

粗体和斜体

要将单词中间部分加粗并设为斜体以强调,请在字母周围添加三个星号(不带空格)

MarkdownHTML渲染输出
This text is ***really important***.This text is <em><strong>really important</strong></em>.这篇文章确实很重要
This text is ___really important___.This text is <em><strong>really important</strong></em>.这篇文章确实很重要
This text is __*really important*__.This text is <em><strong>really important</strong></em>.这篇文章确实很重要
This text is **_really important_**.This text is <em><strong>really important</strong></em>.这篇文章确实很重要
This is really***very***important text.This is really<em><strong>very</strong></em>important text.这确实是非常重要的文本。

粗体和斜体的最佳实践

✅ 这样做❌ 不要这样做
This is really***very***important text.This is really___very___important text.

  • 12
    点赞
  • 14
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值