ICode9

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

MarkDown基础语法笔记

2021-10-22 15:02:17  阅读:136  来源: 互联网

标签:空格 MarkDown 笔记 语法 item Markdown 链接


目录

本文为参考MarkDown官方教程,学习过程记录笔记。
Markdown官方教程

1、标题语法

#Heading level 1 <h1>Heading level 1</h1>

Heading level 1

\#######Heading level 6
Heading level 6
Heading level 1 ##### 为了兼容考虑,请用一个空格在\#和标题之间进行分割。

2、段落语法(空格&emsp;)

要创建段落,请使用空白行将一行或多行文本进行分割
I really like using MarkDown.

I really like using MarkDown.

I think I'll use it to format al of may documents from now on.

##### 不要使用空格(space)或制表符(tabs)缩进段落

3、换行语法

在一行的末尾添加两个或多个空格,然后按回车键,即可创建一个换行
This is the first line.
And this is the second line.
<p> this is the tirst line.<br>
And this is the second line.<\p>
This is the first line.
And this is the second line.
为了兼容性考虑,请在行尾添加“结尾空格”或HTML的<br>标签来实现换行
CommonMark和其他几种轻量级标记语言支持在行尾添加反斜杠(\)的方式来换行,但并非所有MrkDown应用程序都支持此种方式。因此从兼容性角度,不推荐使用。
有两种轻量级标记语言支持无需在行尾添加任何内容,只需键入回车键

4、强调语法

通过将文本设置为粗体或斜体来强调其重要性。

1.粗体(Bold)

在单词或短语前后添加两个星号(asterisks)或下划线(undercores)。
如需要加粗一个单词或短语的中间部分用以强调语法的话,请在要加粗部分的两侧各添加两个星号(asterisks)
I just **bold text**.
I just __bold text__.
I just <strong>bold text </strong>.
I just bold text.
I just bold text.
I just bold text .
MarkDown应用程序在如何处理单词或短语中间的下划线并不一致。
为了兼容性处理,在单词和短语中间部分加粗,请使用星号(asterisks)

2.斜体

在单词或短语前后添加一个星号(asterisks)或下划线(underscore)。要斜体突出单词的中间部分,请在字母后面各添加一个星号,中间不要带空格
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 cat’s meow.
Italicized :用斜体印刷/单词斜体
meow :喵

3.粗体(Bold)和斜体(Italic)

要同时用粗体和斜体突出显示文本,请在单词或短语的前后添加三个星号或下划线。
要加粗并用斜体显示单词或短语的中间部分,请在要突出显示部分的前后各添加三个星号,中间不要带空格
This text is ***really important***.
This text is <strong><em>really important</em></strong>.
This text is rally important.
MarkDown应用程序在处理单词或短语中间添加的下划线并不一致。
为了兼容性,请使用星号将单词或短语的中间部分加粗并以斜体显示,以示重要。

5、引用语法

要创建块引用,请在段落前添加一个>符号(尽量添加空格).
>Dorothy follow her through many of the beautiful rooms in her castle.
多萝茜跟着她穿过城堡里许多美丽的房间。

过去都是假的,回忆没有归路,春天总是一去不返。

1.多个段落的块引用

块引用可以包含多个段落。为段落之间的空白行添加一个>符号。
>Dorothy follow her through many of the beautiful rooms in her castle.
>
>The wich babe her clean pots and kettles and sweep the floor and keep the fire fed with wood.

Dorothy follow her through many of the beautiful rooms in her castle.

The wich babe her clean pots and kettles and sweep the floor and keep the fire fed with wood.

2.嵌套块引用

块引用可以嵌套,在要嵌套的段落前加一个>>符号
>Dorothy follow her through many of the beautiful rooms in her castle.
>
>>The wich babe her clean pots and kettles and sweep the floor and keep the fire fed with wood.

Dorothy follow her through many of the beautiful rooms in her castle.

The wich babe her clean pots and kettles and sweep the floor and keep the fire fed with wood.

3.带有其他元素的块引用

块引用可以包含其他MarkDown格式的元素(并非所有元素都可以使用)。
> ##### The quarterly results look great!
>
> - Revenue was off the chart.
> - Profits were higher than ever.
>
> Everythig is ***going*** according to **plan**.

The quarterly results look great!

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

Everythig is going according to plan.

6、MarkDown列表语法

1.有序列表

(<ol><li></li></ol>)
要创建有序列表,在每个列表项前面添加数字并紧跟一个英文标点。
数字不必按照数学顺序排列,但是列表应当以数字1起始。
\1. First item
\2. Second item
\3. Third item
\4. Fourth item
<ol>
<li>First item</li>
<li>Second item</li>
<li>Third item</li>
<li>Tourth item</li>
</ol>

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

\1. First item
\1. Second item
\1. Third item

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

\1. First item
\2. Second item
\3. Third item
\1. Indented item
\2. 缩进、锯齿状的 item
\4. Fourth item

  1. First item
  2. Second item
  3. Third item
    1. 快捷键切换到这里按Tabs键
    2. Indented item
    3. 缩进、锯齿状的 item
    4. 快捷键退出这个缩进按Backspace键
  4. Fourth item

2.无序列表

(<ul><li></li></ul>)
要创建无序列表,请在每个列表项前面添加破折号(-)、星号(*)或加号(+)
缩进一个或多个列表项可创建嵌套列表。
- First item
  - Indented item
   - Indented item

  • First item
    • Indented item
      • Indented item

3.在列表中嵌套其他元素

- 段落

要保留列表连续性的同时,在列表中添加另一种元素,请将该元素缩进四个空格或一个制表符
/* 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.

- 引用块(需要一个制表符或4个空格)

  1. This is the first list item.

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

  2. Here’s the second list item.

- 代码块

代码块通常采用四个空格或一个制表符缩进。当他们被放到列表中时,请将它们缩进八个空格或两个制表符

  1. Open the file.
  2. Find the following code block on line 21:
    <html> <head> <title>I'm the title.</title> </head>
  3. Updata 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](/picture/download.png)
\3. Close the file.

  1. Open the file containing the Linux mascot.
  2. Marvel at its beauty.
    [外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-VppQ4uFX-1634885210751)(/picture/download.png)]
  3. Close the file.

- 列表

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

7、MarkDown代码语法

要将单词或短语表示为代码,请将其包裹在反引号(`)中。

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

1.转义反引号

如果要表示为代码的单词或短语中包含一个或多个反引号,则可以通过将单词或短语包裹在双反引号(``)中

``Use `code` in your Markdown file.``
Use `code` in your Markdown file.
<code> Use ‘code’ in your Markdown file.</code>
Use ‘code’ in your Markdown file.

2.代码块

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

8、MarkDown分割线语法

在单独一行上使用三个或多个星号(***)、破折号(—)、或下划线(___)并且不能包含其他内容
***

___




1.分割线(Horizontal Rule)

为了兼容性,请在分割线的前后都添加空白行
Try to put a line before…

/—

…and use a horizontal rule.

9、MarkDown链接语法

链接文本放在中括号内,链接地址放在后面的括号中,链接title(鼠标悬停显示的文字)可选
超链接MarkDown语法代码:[超链接显示名](超链接地址 “超链接title”)
对应的HTML代码为:<a href = “超链接地址” title = “超链接title”>超链接显示的名称</a>
这是一个链接[Markdown语法](https://markdown.com.cn/basic-syntax/links.html “Markdown官方教程”)
这是一个链接Markdown语法

1.网址和Email地址

使用尖括号可以很方便地把URL或者email地址变成可点击的链接
<https://markdown.com.cn/basic-syntax/links.html>
https://markdown.com.cn/basic-syntax/links.html

2.带格式化的链接

强调链接,在链接语法前后增加星号。要将链接表示为代码,请在方括号中添加反引号。
I love supporting the *[Markdown](http:s//markdown.com.cn/)**
I love supporting the *[Markdown](http:s//markdown.com.cn/)

See the section on code

I love supporting the Markdown
I love supporting the Markdown
See the section on [`code`](#code)

3.引用类型的链接

引用样式链接是一种特殊的链接,它使URL在MarkDown中更易显示和阅读。参考样式链接分为两部分;
与文本保持内联的部分以及存储在文件中其他位置的部分,以使文本易于阅读。

- 链接的第一部分格式

引用类型的链接的第一部分使用两组括号进行格式设置([][])。
第一组方括号包围应显示为链接的文本
第二组括号显示了一个标签,该标签用于指向您存储在文档其他位置的链接。
尽管不是必须的,可以在两组括号之间包含一个空格
第二组括号中的标签不区分大小写,可以包含字母、数字、空格和标点符号

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

- 链接的第二部分

引用类型链接的第二部分使用以下属性设置格式:

  1. 放在括号中的标签,其后紧跟一个冒号和至少一个空格(例如:[label]:)
  2. 链接的URL,可以选择将其放在尖括号中。
  3. 链接的可选标题,可以将其括在双引号、单引号和括号中。
    实例:
    https://markdown.com.cn/

[1]: https://markdown.com.cn/
[1]: https://markdown.com.cn/ “Markdown”
[1]: https://markdown.com.cn/ ‘Markdown’
[1]: https://markdown.com.cn/ (Markdown)
[1]: <https://markdown.com.cn/> “Markdown”
[1]: <https://markdown.com.cn/> ‘Markdown’
[1]: <https://markdown.com.cn/> (Markdown)

可以将链接的第二部分放在Markdown文档中的任何位置。有些人将它们放在出现的段落之后,有些人则将它们放在文档的末尾(例如尾注或脚注)。

10、Markdown图片语法

使用感叹号(!),然后在方括号增加替带文本,图片链接放在圆括号中里,括号里的链接后可以增加一个可选的图片标题文本。
插入图片Markdown语法代码:![图片alt](图片链接 “图片title”)
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-kocvv88r-1634885210757)(/picture/12.jpg)]
![这是图片](https://markdown.com.cn/assets/img/philly-magic-garden.9c0b4415.jpg)
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-B31D2m7u-1634885210759)(https://markdown.com.cn/assets/img/philly-magic-garden.9c0b4415.jpg)]

1.链接图片

将图片的Markdown括在方括号中,然后将链接添加到圆括号中
[[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-5ulET9Qo-1634885210761)(\picture/10.jpg “Markdown”)]](https://markdown.com.cn/basic-syntax/images.html)
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-eKr5VPDE-1634885210765)(\picture/10.jpg “Markdown”)]

11、Markdown转义字符语法

要显示原本用于格式化Markdown文档的字符,请在字符前面添加反斜杠(\).
* Without the backslash, this would be a bullet in an unordered list.

- 可做转义的字符

CharacterName
\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 excaping pipe in tables)

- 特殊字符自动转义

“<“和”&”
"<"用于起始标签  "&"用于HTML实体
如果你只是想要使用这些符号,必须要使用实体的形式,
像是&lt;和&amp;  <和&

如果你要打[AT&T],你必须要写成[AT&amp;T],还需要转换网址内的&符号
© &copy;

标签:空格,MarkDown,笔记,语法,item,Markdown,链接
来源: https://blog.csdn.net/weixin_50957373/article/details/120905787

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

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

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

ICode9版权所有