Mackdown官方教程

Markdown是一種輕量級(jí)標(biāo)記語言碱妆,排版語法簡(jiǎn)潔鲜屏,讓人們更多地關(guān)注內(nèi)容本身而非排版烹看。它使用易讀易寫的純文本格式編寫文檔,可與HTML混編洛史,可導(dǎo)出 HTML惯殊、PDF 以及本身的 .md 格式的文件。因簡(jiǎn)潔也殖、高效土思、易讀、易寫忆嗜,Markdown被大量使用己儒,如Github、Wikipedia捆毫、簡(jiǎn)書等闪湾。

Markdown 標(biāo)題語法

要?jiǎng)?chuàng)建標(biāo)題,請(qǐng)?jiān)趩卧~或短語前面添加井號(hào) (#) 绩卤。# 的數(shù)量代表了標(biāo)題的級(jí)別途样。例如江醇,添加三個(gè) # 表示創(chuàng)建一個(gè)三級(jí)標(biāo)題 (<h3>) (例如:### My Header)。

Markdown語法 HTML 預(yù)覽效果
Heading level 1 <h1>Heading level 1</h1> # Heading level 1
## Heading level 2 <h2>Heading level 2</h2> ## Heading level 2
### Heading level 3 <h3>Heading level 3</h3> ### Heading level 3
#### Heading level 4 <h4>Heading level 4</h4> #### Heading level 4
##### Heading level 5 <h5>Heading level 5</h5> ##### Heading level 5
###### Heading level 6 <h6>Heading level 6</h6> ###### Heading level 6

可選語法

還可以在文本下方添加任意數(shù)量的 == 號(hào)來標(biāo)識(shí)一級(jí)標(biāo)題何暇,或者 -- 號(hào)來標(biāo)識(shí)二級(jí)標(biāo)題陶夜。

Markdown語法 HTML 預(yù)覽效果
Heading level 1=============== <h1>Heading level 1</h1> # Heading level 1
Heading level 2--------------- <h2>Heading level 2</h2> ## Heading level 2

最佳實(shí)踐

不同的 Markdown 應(yīng)用程序處理 # 和標(biāo)題之間的空格方式并不一致。為了兼容考慮裆站,請(qǐng)用一個(gè)空格在 # 和標(biāo)題之間進(jìn)行分隔条辟。

? Do this ? Don't do this
# Here's a Heading #Here's a Heading

Markdown 段落

要?jiǎng)?chuàng)建段落,請(qǐng)使用空白行將一行或多行文本進(jìn)行分隔宏胯。

Markdown語法 HTML 預(yù)覽效果
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> I really like using Markdown.I think I'll use it to format all of my documents from now on

段落(Paragraph)用法的最佳實(shí)

不要用空格(spaces)或制表符( tabs)縮進(jìn)段落捂贿。

? Do this ? Don't do this
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.

Markdown 換行語法

在一行的末尾添加兩個(gè)或多個(gè)空格,然后按回車鍵,即可創(chuàng)建一個(gè)換行胳嘲。

MARKDOWN語法 HTML 預(yù)覽效果
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> This is the first line. And this is the second line.

換行(Line Break)用法的最佳實(shí)踐

幾乎每個(gè) Markdown 應(yīng)用程序都支持兩個(gè)或多個(gè)空格進(jìn)行換行,稱為 結(jié)尾空格(trailing whitespace) 的方式扣草,但這是有爭(zhēng)議的了牛,因?yàn)楹茈y在編輯器中直接看到空格,并且很多人在每個(gè)句子后面都會(huì)有意或無意地添加兩個(gè)空格辰妙。由于這個(gè)原因鹰祸,你可能要使用除結(jié)尾空格以外的其它方式來換行。幸運(yùn)的是密浑,幾乎每個(gè) Markdown 應(yīng)用程序都支持另一種換行方式:HTML 的 <br> 標(biāo)簽蛙婴。

為了兼容性,請(qǐng)?jiān)谛形蔡砑印敖Y(jié)尾空格”或 HTML 的 <br> 標(biāo)簽來實(shí)現(xiàn)換行尔破。

還有兩種其他方式我并不推薦使用街图。CommonMark 和其它幾種輕量級(jí)標(biāo)記語言支持在行尾添加反斜杠 (\) 的方式實(shí)現(xiàn)換行,但是并非所有 Markdown 應(yīng)用程序都支持此種方式懒构,因此從兼容性的角度來看餐济,不推薦使用。并且至少有兩種輕量級(jí)標(biāo)記語言支持無須在行尾添加任何內(nèi)容胆剧,只須鍵入回車鍵(return)即可實(shí)現(xiàn)換行絮姆。

? DO THIS ? DON'T DO THIS
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.

Markdown 強(qiáng)調(diào)語法

粗體(bold)

要加粗文本,請(qǐng)?jiān)趩卧~或短語的前后各添加兩個(gè)星號(hào)(asterisks)或下劃線(underscores)秩霍。

Markdown語法 HTML 預(yù)覽效果
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**bold Love<strong>is</strong>bold Loveisbold

粗體(Bold)用法最佳實(shí)踐

Markdown 應(yīng)用程序在如何處理單詞或短語中間的下劃線上并不一致篙悯。為兼容考慮,在單詞或短語中間部分加粗的話铃绒,請(qǐng)使用星號(hào)(asterisks)鸽照。

? Do this ? Don't do this
Love**is**bold Love__is__bold

斜體(ltalic)

要用斜體顯示文本,請(qǐng)?jiān)趩卧~或短語前后添加一個(gè)星號(hào)(asterisk)或下劃線(underscore)匿垄。要斜體突出單詞的中間部分移宅,請(qǐng)?jiān)谧帜盖昂蟾魈砑右粋€(gè)星號(hào)归粉,中間不要帶空格

斜體(Italic)用法的最佳實(shí)踐

要同時(shí)用粗體和斜體突出顯示文本,請(qǐng)?jiān)趩卧~或短語的前后各添加三個(gè)星號(hào)或下劃線漏峰。要加粗并用斜體顯示單詞或短語的中間部分糠悼,請(qǐng)?jiān)谝怀鲲@示的部分前后各添加三個(gè)星號(hào),中間不要帶空格浅乔。

? Do this ? Don't do this
A*cat*meow A_cat_meow

粗體(Bold)和斜體(Italic)

要同時(shí)用粗體和斜體突出顯示文本倔喂,請(qǐng)?jiān)趩卧~或短語的前后各添加三個(gè)星號(hào)或下劃線。要加粗并用斜體顯示單詞或短語的中間部分靖苇,請(qǐng)?jiān)谝怀鲲@示的部分前后各添加三個(gè)星號(hào)席噩,中間不要帶空格槐秧。

粗體(Bold)和斜體(Italic)用法的最佳實(shí)踐

Markdown 應(yīng)用程序在處理單詞或短語中間添加的下劃線上并不一致括荡。為了實(shí)現(xiàn)兼容性,請(qǐng)使用星號(hào)將單詞或短語的中間部分加粗并以斜體顯示综看,以示重要脾拆。

? Do this ? Don't do this
This is really***very***important text. This is really___very___important text.

Markdown 引用語法

要?jiǎng)?chuàng)建塊引用馒索,請(qǐng)?jiān)诙温淝疤砑右粋€(gè) > 符號(hào)

> Dorothy followed her through many of the beautiful rooms in her castle.

多個(gè)段落的塊引用

塊引用可以包含多個(gè)段落。為段落之間的空白行添加一個(gè) > 符號(hào)名船。

> Dorothy followed her through many of the beautiful rooms in her castle.
>
> The Witch bade her clean the pots and kettles and sweep the floor and keep the fire fed with wood.

嵌套塊引用

塊引用可以嵌套绰上。在要嵌套的段落前添加一個(gè) >> 符號(hào)。

> Dorothy followed her through many of the beautiful rooms in her castle.
>
>> The Witch bade her clean the pots and kettles and sweep the floor and keep the fire fed with wood.

帶有其它元素的塊引用

塊引用可以包含其他 Markdown 格式的元素渠驼。并非所有元素都可以使用蜈块,你需要進(jìn)行實(shí)驗(yàn)以查看哪些元素有效

> #### The quarterly results look great!
>
> - Revenue was off the chart.
> - Profits were higher than ever.
>
>  *Everything* is going according to **plan**.

markdown列表語法

有序列表

要?jiǎng)?chuàng)建有序列表,請(qǐng)?jiān)诿總€(gè)列表項(xiàng)前添加數(shù)字并緊跟一個(gè)英文句點(diǎn)迷扇。數(shù)字不必按數(shù)學(xué)順序排列百揭,但是列表應(yīng)當(dāng)以數(shù)字 1 起始。

Markdown語法 HTML 預(yù)覽效果
1. First item2. Second item3. Third item4. Fourth item <ol><li>First item</li><li>Second item</li><li>Third item</li><li>Fourth item</li></ol> First itemSecond itemThird itemFourth item
1. First item1. Second item1. Third item1. Fourth item <ol><li>First item</li><li>Second item</li><li>Third item</li><li>Fourth item</li></ol> First itemSecond itemThird itemFourth item
1. First item8. Second item3. Third item5. Fourth item <ol><li>First item</li><li>Second item</li><li>Third item</li><li>Fourth item</li></ol> First itemSecond itemThird itemFourth item
1. First item2. Second item3. Third item 1. Indented item 2. Indented item4. Fourth item <ol><li>First item</li><li>Second item</li><li>Third item<ol><li>Indented item</li><li>Indented item</li></ol></li><li>Fourth item</li></ol> First itemSecond itemThird itemIndented itemIndented itemFourth item

有序列表最佳實(shí)踐

CommonMark and a few other lightweight markup languages let you use a parenthesis ()) as a delimiter (e.g., 1) First item), but not all Markdown applications support this, so it isn’t a great option from a compatibility perspective. For compatibility, use periods only.

? Do this ? Don't do this
1. First item2. Second item 1) First item2) Second item

無序列表

要?jiǎng)?chuàng)建無序列表谋梭,請(qǐng)?jiān)诿總€(gè)列表項(xiàng)前面添加破折號(hào) (-)信峻、星號(hào) (*) 或加號(hào) (+) ∥痛玻縮進(jìn)一個(gè)或多個(gè)列表項(xiàng)可創(chuàng)建嵌套列表盹舞。

Markdown語法 HTML 預(yù)覽效果
- First item- Second item- Third item- Fourth item <ul><li>First item</li><li>Second item</li><li>Third item</li><li>Fourth item</li></ul> First itemSecond itemThird itemFourth item
* First item* Second item* Third item* Fourth item <ul><li>First item</li><li>Second item</li><li>Third item</li><li>Fourth item</li></ul> First itemSecond itemThird itemFourth item
+ First item+ Second item+ Third item+ Fourth item <ul><li>First item</li><li>Second item</li><li>Third item</li><li>Fourth item</li></ul> First itemSecond itemThird itemFourth item
- First item- Second item- Third item - Indented item - Indented item- Fourth item <ul><li>First item</li><li>Second item</li><li>Third item<ul><li>Indented item</li><li>Indented item</li></ul></li><li>Fourth item</li></ul> First itemSecond itemThird itemIndented itemIndented itemFourth item

無序列表最佳實(shí)踐

Markdown applications don’t agree on how to handle different delimiters in the same list. For compatibility, don't mix and match delimiters in the same list — pick one and stick with it.

? Do this ? Don't do this
- First item- Second item- Third item- Fourth item + First item* Second item- Third item+ Fourth item

在列表中嵌套其他元素

要在保留列表連續(xù)性的同時(shí)在列表中添加另一種元素,請(qǐng)將該元素縮進(jìn)四個(gè)空格或一個(gè)制表符隘庄,如下例所示:

段落

*   This is the first list item.
*   Here's the second list item.

    I need to add another paragraph below the second list item.

*   And here's the third list item.

渲染效果如下:

  • This is the first list item.

  • Here's the second list item.

    I need to add another paragraph below the second list item.

  • And here's the third list item.

引用塊

*   This is the first list item.
*   Here's the second list item.

    > A blockquote would look great below the second list item.

*   And here's the third list item.

渲染效果如下:

  • This is the first list item.

  • Here's the second list item.

    A blockquote would look great below the second list item.

  • And here's the third list item.

代碼塊

  1. Open the file containing the Linux mascot.

  2. Marvel at its beauty.

    [圖片上傳失敗...(image-d11660-1652865733162)]

  3. Close the file.

列表

You can nest an unordered list in an ordered list, or vice versa.

1. First item
2. Second item
3. Third item
    - Indented item
    - Indented item
4. Fourth item

渲染效果如下:

  1. First item
  2. Second item
  3. Third item
    • Indented item
    • Indented item
  4. Fourth item

Markdown 代碼語法

要將單詞或短語表示為代碼踢步,請(qǐng)將其包裹在反引號(hào) (```) 中。

MARKDOWN語法 HTML 預(yù)覽效果
At the command prompt, typenano. At the command prompt, type <code>nano</code>. At the command prompt, type nano.

轉(zhuǎn)義反引號(hào)

如果你要表示為代碼的單詞或短語中包含一個(gè)或多個(gè)反引號(hào)丑掺,則可以通過將單詞或短語包裹在雙反引號(hào)(````)中获印。

MARKDOWN語法 HTML 預(yù)覽效果
Usecodein your Markdown file. <code>Usecodein your Markdown file.</code> Usecodein your Markdown file.

代碼塊

要?jiǎng)?chuàng)建代碼塊,請(qǐng)將代碼塊的每一行縮進(jìn)至少四個(gè)空格或一個(gè)制表符街州。

Markdown 分隔線語法

要?jiǎng)?chuàng)建分隔線兼丰,請(qǐng)?jiān)趩为?dú)一行上使用三個(gè)或多個(gè)星號(hào) (***)玻孟、破折號(hào) (---) 或下劃線 (___) ,并且不能包含其他內(nèi)容鳍征。
以上三個(gè)分隔線的渲染效果看起來都一樣:

------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------分隔線(Horizontal Rule)用法最佳實(shí)踐

為了兼容性黍翎,請(qǐng)?jiān)诜指艟€的前后均添加空白行。

? DO THIS ? DON'T DO THIS
Try to put a blank line before...---...and after a horizontal rule. Without blank lines, this would be a heading.---Don't do this!

Markdown 鏈接語法

鏈接文本放在中括號(hào)內(nèi)艳丛,鏈接地址放在后面的括號(hào)中匣掸,鏈接title可選。

超鏈接Markdown語法代碼:[超鏈接顯示名](超鏈接地址 "超鏈接title")

對(duì)應(yīng)的HTML代碼:<a href="超鏈接地址" title="超鏈接title">超鏈接顯示名</a>

這是一個(gè)鏈接 [Markdown語法](https://markdown.com.cn)氮双。

渲染效果如下:

這是一個(gè)鏈接 Markdown語法碰酝。

給鏈接增加 Title

鏈接title是當(dāng)鼠標(biāo)懸停在鏈接上時(shí)會(huì)出現(xiàn)的文字,這個(gè)title是可選的戴差,它放在圓括號(hào)中鏈接地址后面送爸,跟鏈接地址之間以空格分隔。

這是一個(gè)鏈接 [Markdown語法](https://markdown.com.cn "最好的markdown教程")暖释。

渲染效果如下:

這是一個(gè)鏈接 Markdown語法碱璃。

網(wǎng)址和Email地址

使用尖括號(hào)可以很方便地把URL或者email地址變成可點(diǎn)擊的鏈接。

<https://markdown.com.cn>
<fake@example.com>

渲染效果如下:

https://markdown.com.cn
fake@example.com

帶格式化的鏈接

強(qiáng)調(diào) 鏈接, 在鏈接語法前后增加星號(hào)饭入。 要將鏈接表示為代碼,請(qǐng)?jiān)诜嚼ㄌ?hào)中添加反引號(hào)肛真。

I love supporting the **[EFF](https://eff.org)**.
This is the *[Markdown Guide](https://www.markdownguide.org)*.
See the section on [`code`](#code).

渲染效果如下:

I love supporting the EFF.
This is the Markdown Guide.
See the section on code.

引用類型鏈接

引用樣式鏈接是一種特殊的鏈接谐丢,它使URL在Markdown中更易于顯示和閱讀。參考樣式鏈接分為兩部分:與文本保持內(nèi)聯(lián)的部分以及存儲(chǔ)在文件中其他位置的部分蚓让,以使文本易于閱讀乾忱。

鏈接的第一部分格式

引用類型的鏈接的第一部分使用兩組括號(hào)進(jìn)行格式設(shè)置。第一組方括號(hào)包圍應(yīng)顯示為鏈接的文本历极。第二組括號(hào)顯示了一個(gè)標(biāo)簽窄瘟,該標(biāo)簽用于指向您存儲(chǔ)在文檔其他位置的鏈接。

盡管不是必需的趟卸,可以在第一組和第二組括號(hào)之間包含一個(gè)空格蹄葱。第二組括號(hào)中的標(biāo)簽不區(qū)分大小寫,可以包含字母锄列,數(shù)字图云,空格或標(biāo)點(diǎn)符號(hào)。

以下示例格式對(duì)于鏈接的第一部分效果相同:

  • [hobbit-hole][1]
  • [hobbit-hole] [1]

鏈接的第二部分格式

引用類型鏈接的第二部分使用以下屬性設(shè)置格式:

  1. 放在括號(hào)中的標(biāo)簽邻邮,其后緊跟一個(gè)冒號(hào)和至少一個(gè)空格(例如[label]:)竣况。
  2. 鏈接的URL,可以選擇將其括在尖括號(hào)中筒严。
  3. 鏈接的可選標(biāo)題丹泉,可以將其括在雙引號(hào)情萤,單引號(hào)或括號(hào)中。

以下示例格式對(duì)于鏈接的第二部分效果相同:

  • [1]: https://en.wikipedia.org/wiki/Hobbit#Lifestyle
  • [1]: https://en.wikipedia.org/wiki/Hobbit#Lifestyle "Hobbit lifestyles"
  • [1]: https://en.wikipedia.org/wiki/Hobbit#Lifestyle 'Hobbit lifestyles'
  • [1]: https://en.wikipedia.org/wiki/Hobbit#Lifestyle (Hobbit lifestyles)
  • [1]: <https://en.wikipedia.org/wiki/Hobbit#Lifestyle> "Hobbit lifestyles"
  • [1]: <https://en.wikipedia.org/wiki/Hobbit#Lifestyle> 'Hobbit lifestyles'
  • [1]: <https://en.wikipedia.org/wiki/Hobbit#Lifestyle> (Hobbit lifestyles)

可以將鏈接的第二部分放在Markdown文檔中的任何位置摹恨。有些人將它們放在出現(xiàn)的段落之后筋岛,有些人則將它們放在文檔的末尾(例如尾注或腳注)。

鏈接最佳實(shí)踐

不同的 Markdown 應(yīng)用程序處理URL中間的空格方式不一樣睬塌。為了兼容性泉蝌,請(qǐng)盡量使用%20代替空格。

? Do this ? Don't do this
[link](https://www.example.com/my%20great%20page) [link](https://www.example.com/my great page)

Markdown 圖片語法

要添加圖像揩晴,請(qǐng)使用感嘆號(hào) (!), 然后在方括號(hào)增加替代文本勋陪,圖片鏈接放在圓括號(hào)里,括號(hào)里的鏈接后可以增加一個(gè)可選的圖片標(biāo)題文本硫兰。

插入圖片Markdown語法代碼:[圖片上傳失敗...(image-6ad623-1652865733162)]诅愚。

對(duì)應(yīng)的HTML代碼:<img src="圖片鏈接" alt="圖片alt" title="圖片title">

![這是圖片](/assets/img/philly-magic-garden.jpg "Magic Gardens")

鏈接圖片

給圖片增加鏈接,請(qǐng)將圖像的Markdown 括在方括號(hào)中劫映,然后將鏈接添加在圓括號(hào)中违孝。

[![沙漠中的巖石圖片](/assets/img/shiprock.jpg "Shiprock")](https://markdown.com.cn)

Markdown 轉(zhuǎn)義字符語法

要顯示原本用于格式化 Markdown 文檔的字符,請(qǐng)?jiān)谧址懊嫣砑臃葱备茏址?\ 泳赋。

\* Without the backslash, this would be a bullet in an unordered list.

渲染效果如下:

  • Without the backslash, this would be a bullet in an unordered list.

可做轉(zhuǎn)義的字符

以下列出的字符都可以通過使用反斜杠字符從而達(dá)到轉(zhuǎn)義目的雌桑。

Character Name
\ backslash
` backtick (see also escaping backticks in code)
* asterisk
_ underscore
{ } curly braces
[ ] brackets
( ) parentheses
# pound sign
+ plus sign
- minus sign (hyphen)
. dot
! exclamation mark
pipe (see also escaping pipe in tables)

特殊字符自動(dòng)轉(zhuǎn)義

在 HTML 文件中,有兩個(gè)字符需要特殊處理: <& 祖今。 < 符號(hào)用于起始標(biāo)簽校坑,& 符號(hào)則用于標(biāo)記 HTML 實(shí)體,如果你只是想要使用這些符號(hào)千诬,你必須要使用實(shí)體的形式耍目,像是 &lt;&amp;

& 符號(hào)其實(shí)很容易讓寫作網(wǎng)頁文件的人感到困擾徐绑,如果你要打「AT&T」 邪驮,你必須要寫成「AT&amp;T」 ,還得轉(zhuǎn)換網(wǎng)址內(nèi)的 & 符號(hào)傲茄,如果你要鏈接到:

http://images.google.com/images?num=30&q=larry+bird

你必須要把網(wǎng)址轉(zhuǎn)成:

http://images.google.com/images?num=30&amp;q=larry+bird

才能放到鏈接標(biāo)簽的 href 屬性里毅访。不用說也知道這很容易忘記,這也可能是 HTML 標(biāo)準(zhǔn)檢查所檢查到的錯(cuò)誤中盘榨,數(shù)量最多的俺抽。

Markdown 允許你直接使用這些符號(hào),它幫你自動(dòng)轉(zhuǎn)義字符较曼。如果你使用 & 符號(hào)的作為 HTML 實(shí)體的一部分磷斧,那么它不會(huì)被轉(zhuǎn)換,而在其它情況下,它則會(huì)被轉(zhuǎn)換成 &amp;弛饭。所以你如果要在文件中插入一個(gè)著作權(quán)的符號(hào)冕末,你可以這樣寫:

&copy;

Markdown 將不會(huì)對(duì)這段文字做修改,但是如果你這樣寫:

AT&T

Markdown 就會(huì)將它轉(zhuǎn)為:

AT&amp;T

類似的狀況也會(huì)發(fā)生在 < 符號(hào)上侣颂,因?yàn)?Markdown 支持 行內(nèi) HTML 档桃,如果你使用 < 符號(hào)作為 HTML 標(biāo)簽的分隔符,那 Markdown 也不會(huì)對(duì)它做任何轉(zhuǎn)換憔晒,但是如果你是寫:

4 < 5

Markdown 將會(huì)把它轉(zhuǎn)換為:

4 &lt; 5

需要特別注意的是藻肄,在 Markdown 的塊級(jí)元素和內(nèi)聯(lián)元素中, <& 兩個(gè)符號(hào)都會(huì)被自動(dòng)轉(zhuǎn)換成 HTML 實(shí)體拒担,這項(xiàng)特性讓你可以很容易地用 Markdown 寫 HTML嘹屯。(在 HTML 語法中,你要手動(dòng)把所有的 <& 都轉(zhuǎn)換為 HTML 實(shí)體从撼。)

Markdown 內(nèi)嵌 HTML 標(biāo)簽

對(duì)于 Markdown 涵蓋范圍之外的標(biāo)簽州弟,都可以直接在文件里面用 HTML 本身。如需使用 HTML低零,不需要額外標(biāo)注這是 HTML 或是 Markdown婆翔,只需 HTML 標(biāo)簽添加到 Markdown 文本中即可。

行級(jí)內(nèi)聯(lián)標(biāo)簽

HTML 的行級(jí)內(nèi)聯(lián)標(biāo)簽如 <span>掏婶、<cite>啃奴、<del> 不受限制,可以在 Markdown 的段落雄妥、列表或是標(biāo)題里任意使用纺腊。依照個(gè)人習(xí)慣,甚至可以不用 Markdown 格式茎芭,而采用 HTML 標(biāo)簽來格式化。例如:如果比較喜歡 HTML 的 <a><img> 標(biāo)簽誓沸,可以直接使用這些標(biāo)簽梅桩,而不用 Markdown 提供的鏈接或是圖片語法。當(dāng)你需要更改元素的屬性時(shí)(例如為文本指定顏色或更改圖像的寬度)拜隧,使用 HTML 標(biāo)簽更方便些宿百。

HTML 行級(jí)內(nèi)聯(lián)標(biāo)簽和區(qū)塊標(biāo)簽不同,在內(nèi)聯(lián)標(biāo)簽的范圍內(nèi)洪添, Markdown 的語法是可以解析的垦页。

This **word** is bold. This <em>word</em> is italic.

渲染效果如下:

This word is bold. This word is italic.

區(qū)塊標(biāo)簽

區(qū)塊元素──比如 <div><table>干奢、<pre>痊焊、<p> 等標(biāo)簽,必須在前后加上空行,以便于內(nèi)容區(qū)分薄啥。而且這些元素的開始與結(jié)尾標(biāo)簽辕羽,不可以用 tab 或是空白來縮進(jìn)。Markdown 會(huì)自動(dòng)識(shí)別這區(qū)塊元素垄惧,避免在區(qū)塊標(biāo)簽前后加上沒有必要的 <p> 標(biāo)簽刁愿。

例如,在 Markdown 文件里加上一段 HTML 表格:

This is a regular paragraph.

<table>
    <tr>
        <td>Foo</td>
    </tr>
</table>

This is another regular paragraph.

請(qǐng)注意到逊,Markdown 語法在 HTML 區(qū)塊標(biāo)簽中將不會(huì)被進(jìn)行處理铣口。例如,你無法在 HTML 區(qū)塊內(nèi)使用 Markdown 形式的*強(qiáng)調(diào)*觉壶。

用法最佳實(shí)踐

出于安全原因脑题,并非所有 Markdown 應(yīng)用程序都支持在 Markdown 文檔中添加 HTML。如有疑問掰曾,請(qǐng)查看相應(yīng) Markdown 應(yīng)用程序的手冊(cè)旭蠕。某些應(yīng)用程序只支持 HTML 標(biāo)簽的子集。

對(duì)于 HTML 的塊級(jí)元素 <div>旷坦、<table>掏熬、<pre><p>,請(qǐng)?jiān)谄淝昂笫褂每招校╞lank lines)與其它內(nèi)容進(jìn)行分隔秒梅。盡量不要使用制表符(tabs)或空格(spaces)對(duì) HTML 標(biāo)簽做縮進(jìn)旗芬,否則將影響格式。

在 HTML 塊級(jí)標(biāo)簽內(nèi)不能使用 Markdown 語法捆蜀。例如 <p>italic and **bold**</p> 將不起作用疮丛。

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
禁止轉(zhuǎn)載,如需轉(zhuǎn)載請(qǐng)通過簡(jiǎn)信或評(píng)論聯(lián)系作者辆它。
  • 序言:七十年代末誊薄,一起剝皮案震驚了整個(gè)濱河市锰茉,隨后出現(xiàn)的幾起案子协屡,更是在濱河造成了極大的恐慌,老刑警劉巖,帶你破解...
    沈念sama閱讀 219,427評(píng)論 6 508
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件窑睁,死亡現(xiàn)場(chǎng)離奇詭異狭姨,居然都是意外死亡师抄,警方通過查閱死者的電腦和手機(jī),發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 93,551評(píng)論 3 395
  • 文/潘曉璐 我一進(jìn)店門剿干,熙熙樓的掌柜王于貴愁眉苦臉地迎上來,“玉大人置尔,你說我怎么就攤上這事杠步。” “怎么了?”我有些...
    開封第一講書人閱讀 165,747評(píng)論 0 356
  • 文/不壞的土叔 我叫張陵幽歼,是天一觀的道長朵锣。 經(jīng)常有香客問我,道長甸私,這世上最難降的妖魔是什么诚些? 我笑而不...
    開封第一講書人閱讀 58,939評(píng)論 1 295
  • 正文 為了忘掉前任,我火速辦了婚禮皇型,結(jié)果婚禮上诬烹,老公的妹妹穿的比我還像新娘。我一直安慰自己弃鸦,他們只是感情好绞吁,可當(dāng)我...
    茶點(diǎn)故事閱讀 67,955評(píng)論 6 392
  • 文/花漫 我一把揭開白布。 她就那樣靜靜地躺著唬格,像睡著了一般家破。 火紅的嫁衣襯著肌膚如雪。 梳的紋絲不亂的頭發(fā)上购岗,一...
    開封第一講書人閱讀 51,737評(píng)論 1 305
  • 那天汰聋,我揣著相機(jī)與錄音,去河邊找鬼藕畔。 笑死马僻,一個(gè)胖子當(dāng)著我的面吹牛,可吹牛的內(nèi)容都是我干的注服。 我是一名探鬼主播韭邓,決...
    沈念sama閱讀 40,448評(píng)論 3 420
  • 文/蒼蘭香墨 我猛地睜開眼,長吁一口氣:“原來是場(chǎng)噩夢(mèng)啊……” “哼溶弟!你這毒婦竟也來了女淑?” 一聲冷哼從身側(cè)響起,我...
    開封第一講書人閱讀 39,352評(píng)論 0 276
  • 序言:老撾萬榮一對(duì)情侶失蹤辜御,失蹤者是張志新(化名)和其女友劉穎鸭你,沒想到半個(gè)月后,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體擒权,經(jīng)...
    沈念sama閱讀 45,834評(píng)論 1 317
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡袱巨,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 37,992評(píng)論 3 338
  • 正文 我和宋清朗相戀三年,在試婚紗的時(shí)候發(fā)現(xiàn)自己被綠了碳抄。 大學(xué)時(shí)的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片愉老。...
    茶點(diǎn)故事閱讀 40,133評(píng)論 1 351
  • 序言:一個(gè)原本活蹦亂跳的男人離奇死亡,死狀恐怖剖效,靈堂內(nèi)的尸體忽然破棺而出嫉入,到底是詐尸還是另有隱情焰盗,我是刑警寧澤,帶...
    沈念sama閱讀 35,815評(píng)論 5 346
  • 正文 年R本政府宣布咒林,位于F島的核電站熬拒,受9級(jí)特大地震影響,放射性物質(zhì)發(fā)生泄漏垫竞。R本人自食惡果不足惜澎粟,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 41,477評(píng)論 3 331
  • 文/蒙蒙 一、第九天 我趴在偏房一處隱蔽的房頂上張望件甥。 院中可真熱鬧捌议,春花似錦、人聲如沸引有。這莊子的主人今日做“春日...
    開封第一講書人閱讀 32,022評(píng)論 0 22
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽譬正。三九已至宫补,卻和暖如春,著一層夾襖步出監(jiān)牢的瞬間曾我,已是汗流浹背粉怕。 一陣腳步聲響...
    開封第一講書人閱讀 33,147評(píng)論 1 272
  • 我被黑心中介騙來泰國打工, 沒想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留抒巢,地道東北人贫贝。 一個(gè)月前我還...
    沈念sama閱讀 48,398評(píng)論 3 373
  • 正文 我出身青樓,卻偏偏與公主長得像蛉谜,于是被迫代替她去往敵國和親稚晚。 傳聞我的和親對(duì)象是個(gè)殘疾皇子,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 45,077評(píng)論 2 355

推薦閱讀更多精彩內(nèi)容