# MarkDown是什么? *** Markdown是一种轻量级的标记语言,可用于将格式设置元素添加到纯文本文档中。Markdown 由[John Gruber](https://daringfireball.net/projects/markdown/)于2004年创建,如今已成为世界上最受欢迎的标记语言之一。 使用Markdown与使用[WYSIWYG](https://en.wikipedia.org/wiki/WYSIWYG)编辑器不同。在Microsoft Word之类的应用程序中,单击按钮以设置单词和短语的格式,更改立即可见。Markdown不是那样的。当您创建Markdown格式的文件时,可以在文本中添加Markdown语法,以指示哪些单词和短语看起来应该有所不同。 例如,要表示标题,请在其前面添加一个数字符号(例如# Heading One)。或将短语加粗,可在其前后添加两个星号(例如\*\*this text is bold\*\*)。可能需要一段时间才能习惯于在文本中看到Markdown语法,特别是如果您习惯于所见即所得的应用程序。 您可以使用文本编辑器应用程序将Markdown格式元素添加到纯文本文件。或者,您可以将多种Markdown应用程序之一用于macOS,Windows,Linux,iOS和Android操作系统。还有一些基于Web的应用程序专门用于Markdown编写。 根据您使用的应用程序,您可能无法实时预览格式化的文档。但这没关系。[根据Gruber的说法](http://daringfireball.net/projects/markdown/),Markdown语法被设计为可读性强且不显眼,因此即使未呈现Markdown文件中的文本也可以读取。 ### 标题 要创建标题,请#在单词或短语的前面添加数字符号()。您使用的数字符号的数量应与标题级别相对应。例如,要创建标题级别三(\<h3\>),请使用三个数字符号(例如### My Header)。 ```markdown # Heading level 1 ## Heading level 2 ### Heading level 3 #### Heading level 4 ##### Heading level 5 ###### Heading level 6 ``` # Heading level 1 ## Heading level 2 ### Heading level 3 #### Heading level 4 ##### Heading level 5 ###### Heading level 6 或者,在文本下方的行上,添加任意数量的==标题级别1的--字符或标题级别2的字符。 ```markdown Heading level 1 =============== Heading level 2 --------------- ``` Heading level 1 =============== Heading level 2 --------------- ### 水平线 要创建水平线\*\*\*,请单独在一行上使用三个或更多的星号,破折号(\-\-\-)或下划线(\_\_\_)。 ```markdown *** --- --------------- ``` *** --- -------------- ### 段落 要创建段落,请使用空白行分隔一行或多行文本。您不应缩进带有空格或制表符的段落。 ### 链接 要创建链接,请将链接文本括在方括号(例如\[libcc\])中,然后立即在URL后面加上括号(例如 https://libcc.cn )中的URL 。 您可以选择为链接添加标题。当用户将鼠标悬停在链接上时,这将显示为工具提示。要添加标题,请将其括在URL后面的括号中。 ###### 1.网址链接和标题 ```markdown This is link [libcc.cn](https://libcc.cn). My favorite C open source library is [libcc](https://github.com/libcc/libcc "The latest version of this library is available from GitHub."). ``` This is link [libcc.cn](https://libcc.cn). This is email (libcc.cn@gmail.com). My favorite C open source library is [libcc](https://github.com/libcc/libcc "The latest version of this library is available from GitHub."). ##### 2.网址和电子邮件地址 ```markdown (https://libcc.cn) (libcc.cn@gmail.com) ``` ###### 3.格式化链接 为了强调链接,请在方括号和括号之前和之后添加星号。 ```markdown I love supporting the **[EFF](https://eff.org\)** This is the *[Markdown Guide](https://markdown.p2hp.com)* ``` I love supporting the **[EFF](https://eff.org)**. This is the *[Markdown Guide](https://markdown.p2hp.com)*. ###### 4.禁用自动URL链接 如果您不希望自动链接URL,则可以通过将URL表示为带有刻度线的代码来删除该链接。 ```markdown `http://libcc.cn` ``` `http://libcc.cn` ### 换行 要创建换行符(\<br\>),请以两个或多个空格结束一行,然后键入return。 ### 着重 您可以通过使文本变为粗体或斜体来增加着重。 ##### 1. 粗体 要加粗文本,请在单词或短语的前后添加两个星号或下划线。要加粗一个单词的中部以强调,请在字母周围添加两个星号,且各空格之间不加空格。 ```markdown This text is **bold text**. This text is __bold text__. ``` This text is **bold text**. This text is __bold text__. ##### 2. 斜体 要斜体显示文本,请在单词或短语的前后添加一个星号或下划线。要斜体突出单词的中间部分,请在字母周围添加一个星号,中间不要带空格。 ```markdown This text is *italicized*. This text is _italicized_. ``` This text is *italicized*. This text is _italicized_. ##### 3. 粗体和斜体 要同时突出显示带有粗体和斜体的文本,请在单词或短语的前后添加三个星号或下划线。 ```markdown This text is ***bold and italicized***. This text is ___bold and italicized___. This text is __*bold and italicized*__. This text is **_bold and italicized_**. ``` This text is ***bold and italicized***. This text is ___bold and italicized___. This text is __*bold and italicized*__. This text is **_bold and italicized_**. ##### 4. 删除线 您可以通过在单词中心放置一条水平线来“删除”单词。结果看起来像这样。此功能使您可以指示某些单词是一个错误,并不表示要包含在文档中。若要删除单词,请\~\~在单词前后使用两个波浪号。 ```markdown ~~This text is delete line~~. ``` ~~This text is delete line~~ ### 块引用 要创建blockquote,请在段落前面添加一个\>。 块引用可以包含多个段落。在段落之间的空白行上添加一个\> 块引用可以嵌套。在要嵌套的段落前面添加一个\>\>。 块引用可以包含其他Markdown格式的元素。并非所有元素都可以使用-您需要进行实验以查看哪些元素有效。 ```markdown > This is a blockquote to the text. > > \~\~Everything\~\~ is going according to \*\*plan\*\*. > Enjoy! ``` ***呈现的输出如下所示:*** This is a blockquote to the text. ~~Everything~~ is going according to **plan**. Enjoy! ### 表格 要添加表,请使用三个或多个连字符(\-\-\-)创建每列的标题,并使用管道(\|)分隔每列。您可以选择在表的任一端添加管道 ```markdown | Syntax | Description | | ----- | ----- | | Header | Title | | Paragraph | Text | ``` ***对齐*** 在标题行内的连字符的左侧,右侧或两侧添加一个冒号,以使列中的文本左,右或居中对齐。 ```markdown | Left Text | Center Text | Right Text | | :--- | :----: | ---: | | Header | Title | Here's this | | Paragraph | Text | And more | ``` ### 任务清单 任务列表使您可以创建带有复选框的项目列表。在支持任务列表的Markdown应用程序中,复选框将显示在内容旁边。 请在任务列表项之前添\[ \]在其前面加上一个空格。要选择一个复选框,请在方括号(\[x\])之间添加。 ```markdown [x] Write the press release [ ] Update the website [ ] Contact the media ``` [x] Write the press release [ ] Update the website [ ] Contact the media ### 有序列表 要创建有序列表,请在订单项中添加数字和句点。数字不必按数字顺序排列,但列表应以数字开头。 ```markdown 1. First item 2. Second item 3. Third item 4. Fourth item 1. First item 2. Second item 5. Third item 1. Indented item 1. Indented item 1. Fourth item ``` ***呈现的输出如下所示:*** 1. First item 2. Second item 3. Third item 4. Fourth item ## 1. First item 2. Second item 5. Third item 1. Indented item 1. Indented item 1. Fourth item ### 无序列表 ```markdown - First item - Second item - Third item - Fourth item - First item - Second item - Third item - Indented item - Indented item - Fourth item ``` ***呈现的输出如下所示:*** - First item - Second item - Third item - Fourth item - First item - Second item - Third item - Indented item - Indented item - Fourth item ### 代码块 语法高亮 许多Markdown处理器都支持围栏代码块的语法突出显示。此功能使您可以为代码编写时使用的任何语言添加颜色突出显示。要添加语法突出显示,请在受防护的代码块之前的对号旁指定一种语言。 ```markdown <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title></title> </head> <body> </body> </html> ``` ###### HTML ```html <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title></title> </head> <body> </body> </html> ``` ###### C/C++ ```c printf("%s\n","Hello,word!"); ``` ###### JSON ```JSON { "firstName": "John", "lastName": "Smith", "age": 25 } ```