markdown 语法学习

markdown 语法学习

markdown是一种轻量级的标记语言,和html类似,但是易读性比html要好很多。

基本语法:

1.标题和正文分隔线

=== //至少三个连续等号,最高阶标题

--- //或者三个连续的减号,第二高阶标题

2.标题字体大小

用 若干个 # 为前缀 //#的个数对应于html中的 hx, 即 1个# 为h1的大小, 6个# 为h6 的大小

3.生成段落

使用一个或多个空行来分隔内容段,用来生成段落。只使用换行符,但行与行中间没有空行,则这些行的内容在markdown中会被连到一块,但中间会有空格。

4.引用

使用 > 作为段落标记,来表示该段内容为引用,而且引用的内容会在显示的时候显示引用痕迹。

在引用之内可以使用其他标签,也可以使用更深一层的引用。

5.列表

有序列表,使用

1.  xxx

2.  xxx

等用数字加 . 的形式来表示有序列表(. 之后有一个空格)

无序列表,使用 *, +, - 前缀表示无序列表 (*/+/- 之后有一个空格)

6. 换行

如果只是在段落内部换行,可以使用<br> 换行符. 或者可以用两个或两个以上空格加回车来实现换行。

7.支持引用式的链接格式,例如mkd代码:

首先,什么是 markdown?我们可以直接看一下 [WIKI][1]……
另外,markdown 可以被编译为 html,比如使用在线的 [Pandoc][2]

[1]:    http://en.wikipedia.org/wiki/Markdown   "wiki_markdown"
[2]:    http://johnmacfarlane.net/pandoc/try    "pandoc online"

则 在最后的效果中显示为超链接,但是又不出现具体的 http 连接显示。这样在正文中不会出现 链接地址 这种读者不关心的信息,同时也可以作为变量继续在其他地方引用。

8.支持快捷链接

使用 <链接地址> 的形式,如 <www.taobao.com> ,可以避免html的 <a href="http://ued.taobao.org">http://ued.taobao.org</a>的繁琐。

9.强调

*或_ 包围起来,显示为斜体; ** 或 __ 包围起来显示为粗体

10.代码块 (反单引号)

行内一句代码,使用 `codexx` ; 代码段落,使用

```

code block xxxx

```

或者使用两个tab来作为代码块的开始(在代码块的每一行都有两个tab)

11.表格

|item | value | quality|

|:----| ---:|:---:|

|it1 | 1.0 | 5 |

|it2 | 2.0 |10|

 

在mkd代码中,竖杠不需要对齐,只需要在 第二行的 :--- 表示左对齐, ---:表示右对齐, :---: 表示中间对齐

12.分隔线

在一行中可以使用三个以上的 *, -, _ 来作为两行的分隔线。

13. 图片

行内式:

![description](/path/xxx.img)

![description](/path/xxx.img "optional title")

  • 一个惊叹号 !
  • 接着一个方括号,里面放上图片的替代文字
  • 接着一个普通括号,里面放上图片的网址,最后还可以用引号包住并加上 选择性的 'title' 文字。

参考式:

![description][id]

[id]是图片参考的名称,图片参考的定义方式则和连结参考一样:

[id]: url/to/image "optional attribute"

14. 自动链接

markdown支持以简短的自动链接的形式来处理网络和电子邮箱,只要使用尖括号包起来,markdown就会将他们自动转化为链接。(测试发现,对于链接性质的文本,即使使用尖括号括起来,也会被markdown自动转换为链接?)

<xxxx@163.com>

15.反斜杠转义

markdown可以使用来插入一些特殊字符,如* - _等。markdown支持的转义字符:

   反斜线
`   反引号
*   星号
_   底线
{}  花括号
[]  方括号
()  括弧
#   井字号
+   加号
-   减号
.   英文句点
!   惊叹号

示例mkd代码:

##this is a title##

===

hello ,what are you doing ?

 

 

>Action speak louder than words

>>this is a tst

>>>this is a tst

 

###this is a level-3 header

 

1. this is a ordered list 1

2. this is a ordered list 2

3. this is a ordered list 3

 

 

#####this is a level-4 header

 

 

- this is a unordered list4<br>

and this is a newline

- this is a unordered list5<br> this is also a new line

* this is a unordered list6<br> this isa new line too

 

**this is a strong effect**

 

__this is also a strong effect__

 

*this is a italic effect*

 

_this is also a italic effect

this is a newline _

 

this is a `#include<iostream>`

 

```

//this is a code block

#include<iostream>

using namespace std;

int main(){

cout << "hello world" << endl;

return 0;

}

```

 

首先,什么是 markdown?我们可以直接看一下 [WIKI][1]……

另外,markdown 可以被编译为 html,比如使用在线的 [Pandoc][2]

 

<http://www.taobao.com>

[Google](http://www.google.com)

 

|item | value | quality|

|-:| ---:|:---:|

| it1 | 1.0 | 5 |

|it2 | 2.0 |10|

 

[1]: http://en.wikipedia.org/wiki/Markdown "wiki_markdown"

[2]: http://johnmacfarlane.net/pandoc/try "pandoc online"

 

显示效果

this is a title


hello ,what are you doing ?

Action speak louder than words

this is a tst

this is a tst

this is a level-3 header

  1. this is a ordered list 1
  2. this is a ordered list 2
  3. this is a ordered list 3
this is a level-4 header
  • this is a unordered list4
    and this is a newline
  • this is a unordered list5
    this is also a new line
  • this is a unordered list6
    this isa new line too

this is a strong effect

this is also a strong effect

this is a italic effect

_this is also a italic effect
this is a newline _

this is a #include<iostream>

//this is a code block 
#include<iostream>
using namespace std;
int main(){
   cout << "hello world" << endl;
   return 0;
}

首先,什么是 markdown?我们可以直接看一下 WIKI…… 另外,markdown 可以被编译为 html,比如使用在线的 Pandoc

http://www.taobao.com
Google

markdown 语法学习