Markdown常用语法

介绍

MarkDown原理:一个文档语言,使用性比较强
从后台解释语言到html。下面是使用方法。

标题

通过‘#’个数 区分h1-6(标题大小)

1
2
3
# This is an h1 tag
## This is an h2 tag
###### This is an h6 tag

效果:

This is an h1 tag

This is an h2 tag

This is an h6 tag

列表

无序代码:

1
2
3
4
- 文本1
* 二级文本
- 文本2
- 文本3

  • 文本1
    • 二级文本
  • 文本2
  • 文本3

有序代码

1
2
3
4
5
1. 文本1
1. 2121
2. 电影
2. 文本2
3. 文本3

  1. 文本1
    1. 2121
    2. 电影
  2. 文本2
  3. 文本3

换行

空格和回车都可以

1
2
3
Here's a line for us to start with.

This line is separated from the one above by two newlines, so it will be a *separate paragraph*.

重点

1
2
3
4
5
6
7
8
9
*This text will be italic*
_This will also be italic_

**This text will be bold**
__This will also be bold__

~~This text will be crossed out.~~

_You **can** combine them_

This text will be italic
This will also be italic

This text will be bold
This will also be bold

This text will be crossed out.

You can combine them

链接

1
2
3
This is [an example](http://example.com/) inline link with a title.

[This link](http://example.net/) has no title attribute.

This is an example inline link with a title.

This link has no title attribute.

参考文献

这个没弄明白

1
This is [an example][id] reference-style link.

图片

1
2
An image: ![gras](img/image.jpg)
An image: ![gras](https://www.google.com/images/branding/googlelogo/2x/googlelogo_color_272x92dp.png)

An image: gras

模块引用

1
2
3
4
As Kanye West said:

> We're living the future so
> the present is our past.

As Kanye West said:

We’re living the future so

the present is our past.

1
2
3
4
| First Header  | Second Header |
| ------------- | ------------- |
| Content Cell | Content Cell |
| Content Cell | Content Cell |
First Header Second Header
Content Cell Content Cell
Content Cell Content Cell

输入代码块

前后加(三个点点点)
```
这儿放你的代码
```

1
2
3
function test() {
console.log("notice the blank line before this function?");
}

行内代码

1
2
Use `gitbook` to convert the `text` in markdown
syntax to HTML.

Use gitbook to convert the text in markdown
syntax to HTML.

语法高亮显示

1
2
3
4
5
```ruby
require 'redcarpet'
markdown = Redcarpet.new("Hello World!")
puts markdown.to_html
\``` //这儿的\为了防止被转义,编辑时不需要

效果:

1
2
3
require 'redcarpet'
markdown = Redcarpet.new("Hello World!")
puts markdown.to_html

脚注

GitBook支持这种脚注的简单语法。脚注是相对于每个页面。

1
2
3
Text prior to footnote reference.[^2]

[^2]: Comment to include in footnote.

Text prior to footnote reference.[^2]

[^2]: Comment to include in footnote.

前端语言

GitBook支持在您的文本中使用原始HTML,不处理HTML中的Markdown语法:

1
2
3
<div>
Markdown here will not be **parsed**
</div>

Markdown here will not be parsed

水平规则

1
2
3
4
5
6
7
8
9
Three or more...

---

Hyphens

***

Asterisks

Three or more…


Hyphens


Asterisks

忽略

1
Let's rename \*our-new-project\* to \*our-old-project\*.

这个意思就是转义*不让其成为加粗的标记。
Let’s rename *our-new-project* to *our-old-project*.

如果对您有帮助,请我喝杯咖啡?