How to Write Documents with Markdown

/ ,
Simplified ChineseEnglish

Markdown

Markdown is a lightweight markup language created by John Gruber in 2004. It allows people to write documents in an easy-to-read and easy-to-write plain text format.
With a suitable converter, documents written in Markdown can be exported to HTML, Word, images, PDF, EPUB, and other formats.
Markdown documents usually use the extensions .md or .markdown.

Markdown Applications

Markdown can be used to write e-books with tools such as GitBook.

Many websites use Markdown for documentation or forum posts, including GitHub, Jianshu, Reddit, Diaspora, Stack Exchange, OpenStreetMap, and SourceForge.

Markdown Basics

Headings

Markdown headings have two formats.

1. Use = and - to mark first-level and second-level headings

Markdown
这是H1的标题
===========

这是H2的标题
-----------
markdown_title1.png

2. Use # as a marker

Use # to represent headings of levels 1-6, where a level-one heading corresponds to one # and a level-two heading corresponds to two # and so on.

Markdown
# 一级标题

## 二级标题

### 三级标题

#### 四级标题

##### 五级标题

###### 六级标题
markdown_title2.png

Paragraphs

Markdown paragraphs need no special formatting; just write your text. To insert a line break within a paragraph, end the line with two or more spaces and press Enter.

markdown_paragraph1.png

A blank line separates two paragraphs.

markdown_paragraph2.png

Italics and Bold

Markdown uses *text* or _text_ for italic text, and **text** or __text__ for bold text.

Usage

Result

*italic text*

italic text

_italic text_

italic text

**bold text**

bold text

__bold text__

bold text

***bold italic text***

bold italic text

___bold italic text___

bold italic text


Lists

Markdown supports unordered and ordered lists.

Unordered List

Unordered lists use an asterisk * or a plus + or a minus - as a list marker. Add a space after the marker, then the list item text:

Markdown
* 第一项
* 第二项
* 第三项

+ 第一项
+ 第二项
+ 第三项

- 第一项
- 第二项
- 第三项
markdown_list1.png

Ordered List

Ordered lists are represented by numbers followed by a period, for example:

Markdown
1. 第一项
2. 第二项
3. 第三项
markdown_list2.png

Nested Lists

To nest lists, simply add four spaces before the items in the sublist:

Markdown
1. 第一项:
    - 第一项嵌套的第一个元素
    - 第一项嵌套的第二个元素
2. 第二项:
    - 第二项嵌套的第一个元素
    - 第二项嵌套的第二个元素
markdown_list3.png

Blockquotes

Markdown blockquotes use the > marker at the beginning of a paragraph, followed by a space:

Markdown
>Hi, this is xxxbrian.
>Brian's Blog
>等青春轻飘的烟雾把少年的欢乐袅袅曳去,之后,我们就能取得一切值得吸取的东西。 ——普希金

In addition, blockquotes can be nested. One > symbol is the outermost level, two > symbols are the first level of nesting, and so on:

Markdown
> 最外层
> > 第一层嵌套
> > > 第二层嵌套

Using Lists in Blockquotes

Markdown
> 区块中使用列表
> 1. 第一项
> 2. 第二项
> + 第一项
> + 第二项
> + 第三项

Using Blockquotes in Lists

Markdown
+ 第一项
    > Brian's Blog
    > Hi, this is xxxbrian.
+ 第二项
markdown_blockquotes.png

Code

Wrap a function name or code fragment in backticks `, for example `code`. To display the function name printf(), write:

Markdown
`printf()`函数

Code Blocks

Indent a code block with four spaces or one tab.

Markdown
$(document).ready(function () {
    alert('RUNOOB');
});

The result is displayed as follows:

$(document).ready(function () {
alert('RUNOOB');
});

You can also use ``` around a code block, with an optional language identifier:

JavaScript
$(document).ready(function () {
    alert('RUNOOB');
});

The result is displayed as follows:

JavaScript
$(document).ready(function () {
    alert('RUNOOB');
});

Links are used as follows:

Markdown
[链接名称](链接地址)

或者

<链接地址>

For example:

Markdown
这是一个链接 [Brian's Blog](https://xxxbrian.me)

This is a link Brian's Blog

Using a Link Address Directly

Markdown
链接 <https://xxxbrian.me>

Link <https://xxxbrian.me>

Advanced Links

Reference-style links let you define a URL separately, usually at the end of the document:

Markdown
这个链接用 1 作为网址变量 [Google][1]
这个链接用 Brian's Blog 作为网址变量 [xxxbrian][xxxbrian]

[1]: http://www.google.com/
[xxxbrian]: https://xxxbrian.me

markdown_link.png

Images

The Markdown image syntax is as follows:

Markdown
![alt 属性文本](图片地址)

![alt 属性文本](图片地址 "可选标题")
  • Start with an exclamation mark !
  • Follow it with square brackets containing the image's alt text.
  • Then use parentheses containing the image URL and, optionally, a quoted 'title'.

Usage example:

Markdown
![xxxbrian 图标](https://raw.githubusercontent.com/xxxbrian/xxxbrian.github.io/master/img/xxxbrian-192x192.png "xxxbrian")

Tables

To create a table in Markdown, use | to separate different cells, and use - to separate the header from other rows.

Markdown
|  表头   | 表头  |
|  ----  | ----  |
| 单元格  | 单元格 |
| 单元格  | 单元格 |

Table Alignment

  • -: Align content and header cells to the right.
  • :- Align content and header cells to the left.
  • :-: Align content and header cells in the center.
Markdown
| 左对齐 | 右对齐 | 居中对齐 |
| :-----| ----: | :----: |
| 单元格 | 单元格 | 单元格 |
| 单元格 | 单元格 | 单元格 |
markdown_sheet.png

Escaping Special Characters

Markdown uses many special symbols to represent specific meanings. If you need to display a specific symbol, you must use an escape character. Markdown uses a backslash to escape special characters:

Markdown
**文本加粗** 
\*\* 正常显示星号 \*\*

Markdown supports adding a backslash before the following symbols to help insert ordinary symbols:

TEXT
\   反斜线
`   反引号
*   星号
_   下划线
{}  花括号
[]  方括号
()  小括号
#   井字号
+   加号
-   减号
.   英文句点
!   感叹号
  • Loading...
  • Loading...
  • Loading...
  • Loading...
  • Loading...