ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

Markdown语法

2021-06-02 16:02:44  阅读:376  来源: 互联网

标签:Markdown Third 语法 item Second Fourth First


基本语法(所有内容来源于网络,本文只用来做笔记)

段落和换行

段落是由一行或多行连续文本组成的, 这条规则使得 Markdown 支持 "硬换行". 这个其他的文本到HTML转换器有很大不同 (包括 Movable Type 的 "Convert Line Breaks" 选项) , 通常这些转换器会将段落中的每个换行都转换为一个 <br /> 标签.
当你 确实需要 在 Markdown 中输入 <br /> 标签, 只需要在行尾加上两个及以上的空格, 然后换行.

要创建段落,请使用空白行分隔一行或多行文本。您不应缩进带有空格或制表符的段落。

Markdown HTML 渲染输出
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> 我真的很喜欢使用Markdown。我想从现在开始,我将使用它来格式化所有文档。
Markdown HTML 渲染输出
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 支持两种形式的标题, [Setext] [1] 和 [atx] [2].

Setext 样式

//等号来表示一级标题
this is an H1
=============
//使用连字符表示二级标题
This is an H2
-------------

Atx 样式

//Atx 样式的标题每行开头使用 1-6 井号, 对应 1-6 级标题. 
# This is an H1
## This is an H2
###### This is an H6
Markdown HTML 渲染输出
# 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

着重

您可以通过使文本变为粗体或斜体来增加着重。

粗体

要加粗文本,请在单词或短语的前后添加两个星号或下划线。要加粗一个单词的中部以强调,请在字母周围添加两个星号,且各空格之间不加空格。

Markdown HTML 渲染输出
I just love **bold text**. I just love <strong>bold text</strong>. 我只喜欢粗体字
I just love __bold text__. I just love <strong>bold text</strong>. 我只喜欢粗体字
Love**is**bold Love<strong>is</strong>bold 大胆的

斜体

要斜体显示文本,请在单词或短语的前后添加一个星号或下划线。要斜体突出单词的中间部分,请在字母周围添加一个星号,中间不要带空格。

Markdown HTML 渲染输出
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*meow A<em>cat</em>meow 一个

粗体和斜体

Markdown HTML 渲染输出
This text is ***really important***. This text is <strong><em>really important</em></strong>. 这段文字*真的很重要*
This text is ___really important___. This text is <strong><em>really important</em></strong>. 这段文字*真的很重要*
This text is __*really important*__. This text is <strong><em>really important</em></strong>. 这段文字*真的很重要*
This text is **_really important_**. This text is <strong><em>really important</em></strong>. 这段文字*真的很重要*

块引用

要创建blockquote,请>在段落前面添加一个。

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

呈现的输出如下所示:

桃乐丝(Dorothy)跟着她走过了她城堡中许多美丽的房间。

具有多个段落的块引用

块引用可以包含多个段落。>在段落之间的空白行上添加一个。

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

呈现的输出如下所示:

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.

嵌套块引用

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

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格式的元素。并非所有元素都可以使用-您需要进行实验以查看哪些元素有效。

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

呈现的输出如下所示:

The quarterly results look great!

  • Revenue was off the chart.
  • Profits were higher than ever.

Everything is going according to plan.

列表

您可以将项目组织成有序和无序列表。

有序列表

要创建有序列表,请在订单项中添加数字和句点。数字不必按数字顺序排列,但列表应以数字开头。

//Markdown
1. First item
2. Second item
3. Third item
4. Fourth item
//HTML
<ol>
<li>First item</li>
<li>Second item</li>
<li>Third item</li>
<li>Fourth item</li>
</ol>

渲染输出

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

Markdown

  1. First item
  2. Second item
  3. Third item
  4. Fourth item
    HTML
//Markdown
1. First item
2. Second item
3. Third item
    1. Indented item
    2. Indented item
4. Fourth item
//HTML
<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>
</ol>

渲染输出

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

无序列表

要创建无序列表,请在订单项前添加破折号(-),星号(*)或加号(+)。缩进一个或多个项目以创建嵌套列表。

//Markdown
- First item
- Second item
- Third item
- Fourth item
* First item
* Second item
* Third item
* Fourth item
+ First item
* Second item
- Third item
+ Fourth item
- First item
- Second item
- Third item
    - Indented item
    - Indented item
- Fourth item
//HTML
<ul>
<li>First item</li>
<li>Second item</li>
<li>Third item</li>
<li>Fourth item</li>
</ul>
<ul>
<li>First item</li>
<li>Second item</li>
<li>Third item</li>
<li>Fourth item</li>
</ul>
<ul>
<li>First item</li>
<li>Second item</li>
<li>Third item</li>
<li>Fourth item</li>
</ul>
<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 item
  • Second item
  • Third item
  • Fourth item
  • First item
  • Second item
  • Third item
  • Fourth item
  • First item
  • Second item
  • Third item
  • Fourth item
  • First item
  • Second item
  • Third item
    • Indented item
    • Indented item
  • Fourth 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.

    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.
2.  Find the following code block on line 21:

        <html>
          <head>
            <title>Test</title>
          </head>

3.  Update the title to match the name of your website.

呈现的输出如下所示:

  1. Open the file.

  2. Find the following code block on line 21:

    <html>
      <head>
        <title>Test</title>
      </head>
    
  3. Update the title to match the name of your website.

图片

1.  Open the file containing the Linux mascot.
2.  Marvel at its beauty.

    ![Tux, the Linux mascot](https://d33wubrfki0l68.cloudfront.net/e7ed9fe4bafe46e275c807d63591f85f9ab246ba/e2d28/assets/images/tux.png)

3.  Close the file.

呈现的输出如下所示:

  1. Open the file containing the Linux mascot.

  2. Marvel at its beauty.

    Tux, the Linux mascot

  3. Close the file.

代码

要将单词或短语表示为代码,请将其括在勾号(`)中。

//Markdown
At the command prompt, type `nano`.
//HTML
At the command prompt, type <code>nano</code>

呈现的输出如下所示:

At the command prompt, type nano.

转义刻度线

如果要表示为代码的单词或短语包含一个或多个刻度线,可以通过将单词或短语括在双刻度线(````)中来对其进行转义。

//Markdown
``Use `code` in your Markdown file.``
//HTML
<code>Use `code` in your Markdown file.</code>

呈现的输出如下所示:

Use `code` in your Markdown file.

代码块

要创建代码块,请在代码块的每一行缩进至少四个空格或一个制表符。

    <html>
      <head>
      </head>
    </html>

呈现的输出如下所示:

<html>
  <head>
  </head>
</html>

注意:要创建没有缩进线的代码块,请使用围栅代码块

水平线

要创建水平线***,请单独在一行上使用三个或更多的星号(),破折号(---)或下划线(___)。

//Markdown
***

---

_________________
//所有这三个的渲染输出看起来都相同:

输出效果:


链接

要创建链接,请将链接文本括在方括号(例如[Duck Duck Go])中,然后立即在URL后面加上括号(例如(https://duckduckgo.com))中的URL 。

My favorite search engine is [Duck Duck Go](https://duckduckgo.com).

呈现的输出如下所示:

我最喜欢的搜索引擎是Duck Duck Go

添加标题

您可以选择为链接添加标题。当用户将鼠标悬停在链接上时,这将显示为工具提示。要添加标题,请将其括在URL后面的括号中。

My favorite search engine is [Duck Duck Go](https://duckduckgo.com "The best search engine for privacy").

呈现的输出如下所示:

My favorite search engine is Duck Duck Go.

网址和电子邮件地址

要将URL或电子邮件地址快速转换为链接,请将其括在尖括号中。

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

呈现的输出如下所示:

https://markdown.p2hp.com

fake@example.com

格式化链接

为了强调链接,请在方括号和括号之前和之后添加星号。

I love supporting the **[EFF](https://eff.org)**.
This is the *[Markdown Guide](https://markdown.p2hp.com)*.

呈现的输出如下所示:

I love supporting the EFF.
This is the Markdown Guide.

图片

要添加图像,请添加感叹号(!),然后在括号中添加替代文本,并在括号中添加图像资源的路径或URL。您可以选择在括号中的URL之后添加标题。

![百度logo](https://www.baidu.com/img/PCtm_d9c8750bed0b3c7d089fa7d55720d6cf.png "百度logo")

呈现的输出如下所示:

百度logo

链接图像

[![百度logo](https://www.baidu.com/img/PCtm_d9c8750bed0b3c7d089fa7d55720d6cf.png "百度logo")](https://www.baidu.com)

呈现的输出如下所示:

百度logo

转义字符

要显示原义字符,否则将用于设置Markdown文档中的文本格式\,请在字符前面添加反斜杠()。

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

呈现的输出如下所示:

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

你可以转义的字符

字符 名称
\ 反斜杠
` 刻度线(另请参见转义刻度线中的代码
* 星号
_ 下划线
{} 大括号
[] 中括号
() 括号
# 井号
+ 加号
- 减号(连字符)
.
! 感叹号
| 管道(另请参见表中的转义管道

标签:Markdown,Third,语法,item,Second,Fourth,First
来源: https://www.cnblogs.com/michaelshen/p/14841645.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有