Markdown: Basics (快速入门)

Markdown现在作为写blog的标记语言越来越流行,github和oschina都支持,于是也学习一下。

#段落、标题、区块代码

一个段落是由一个以上的连接的行句组成,而一个以上的空行则会划分出不同的段落(空行的定义是显示上看起来像是空行,就被视为空行,例如有一行只有空白和 tab,那该行也会被视为空行),一般的段落不需要用空白或换行缩进。

Markdown 支持两种标题的语法,Setextatx 形式。Setext 形式是用底线的形式,利用 = (最高阶标题)和 - (第二阶标题),Atx 形式在行首插入 1 到 6 个 # ,对应到标题 1 到 6 阶。

区块引用则使用 email 形式的 '>' 角括号。

Markdown 语法:

A First Level Header
====================
A Second Level Header
---------------------

Now is the time for all good men to come to
the aid of their country. This is just a
regular paragraph.

The quick brown fox jumped over the lazy
dog's back.
### Header 3

> This is a blockquote.
> 
> This is the second paragraph in the blockquote.
>
> ## This is an H2 in a blockquote

显示效果为:

A First Level Header

A Second Level Header

Now is the time for all good men to come to the aid of their country. This is just a regular paragraph.

The quick brown fox jumped over the lazy dog's back.

Header 3

This is a blockquote.

This is the second paragraph in the blockquote.

This is an H2 in a blockquote

#修辞和强调

Markdown 使用星号和底线来标记需要强调的区段。

Markdown 语法:

Some of these words *are emphasized*.
Some of these words _are emphasized also_.
Use two asterisks for **strong emphasis**.
Or, if you prefer, __use two underscores instead__.

显示效果为:

Some of these words are emphasized. Some of these words are emphasized also. Use two asterisks for strong emphasis. Or, if you prefer, use two underscores instead.

#列表

无序列表使用星号、加号和减号来做为列表的项目标记,这些符号是都可以使用的,使用星号:

* Candy.
* Gum.
* Booze.

显示效果为:

  • Candy.
  • Gum.
  • Booze.

有序的列表则是使用一般的数字接着一个英文句点作为项目标记:

1. Red
2. Green
3. Blue

显示效果为:

  1. Red
  2. Green
  3. Blue

#链接

Markdown 支援两种形式的链接语法: 行内 和 参考 两种形式,两种都是使用角括号来把文字转成连结。

行内形式是直接在后面用括号直接接上链接:

This is [github](http://github.com/ "github").

显示效果为:

This is github.

参考形式的链接让你可以为链接定一个名称,之后你可以在文件的其他地方定义该链接的内容:

I get 10 times more traffic from [Google][1] than from
[Yahoo][2] or [MSN][3].

[1]: http://google.com/ "Google"
[2]: http://search.yahoo.com/ "Yahoo Search"
[msn]: http://search.msn.com/ "MSN Search"

显示效果为:

I get 10 times more traffic from Google than from Yahoo or MSN.

title 属性是选择性的,链接名称可以用字母、数字和空格,但是不分大小写:

#图片

图片的语法和链接很像。

行内形式(title 是选择性的):

![我的头像](http://static.oschina.net/uploads/user/53/106378_50.jpg "Title")

显示效果为:

我的头像

#代码

在一般的段落文字中,你可以使用反引号 ` 来标记代码区段,区段内的 &、< 和 > 都会被自动的转换成 HTML 实体,这项特性让你可以很容易的在代码区段内插入 HTML 码:

I strongly recommend against using any `<blink>` tags.

I wish SmartyPants used named entities like `&mdash;`
instead of decimal-encoded entites like `&#8212;`.

显示效果为:

I strongly recommend against using any <blink> tags.

I wish SmartyPants used named entities like &mdash; instead of decimal-encoded entites like &#8212;.

如果要建立一个已经格式化好的代码区块,只要每行都缩进 4 个空格或是一个 tab 就可以了,而 &、< 和 > 也一样会自动转成 HTML 实体。

Markdown 语法:

If you want your page to validate under XHTML 1.0 Strict,
you've got to put paragraph tags in your blockquotes:

<blockquote>
<p>For example.</p>
</blockquote>

显示效果为:

If you want your page to validate under XHTML 1.0 Strict, you've got to put paragraph tags in your blockquotes:

<blockquote> <p>For example.</p> </blockquote>

Refers:

  1. http://wowubuntu.com/markdown/basic.html
  2. http://jianshu.io/p/q81RER
  3. http://www.ituring.com.cn/article/23
  4. http://www.oschina.net/question/100267_75314

本文的Markdown如下:

Markdown现在作为写blog的标记语言越来越流行,[github][github]和oschina都支持,于是也学习一下。

#段落、标题、区块代码

一个段落是由一个以上的连接的行句组成,而一个以上的空行则会划分出不同的段落(空行的定义是显示上看起来像是空行,就被视为空行,例如有一行只有空白和 tab,那该行也会被视为空行),一般的段落不需要用空白或换行缩进。

Markdown 支持两种标题的语法,[Setext][Setext] 和 [atx][atx] 形式。Setext 形式是用底线的形式,利用 = (最高阶标题)和 - (第二阶标题),Atx 形式在行首插入 1 到 6 个 # ,对应到标题 1 到 6 阶。

区块引用则使用 email 形式的 '>' 角括号。

Markdown 语法:

	A First Level Header
	====================
	A Second Level Header
	---------------------
	
	Now is the time for all good men to come to
	the aid of their country. This is just a
	regular paragraph.
	
	The quick brown fox jumped over the lazy
	dog's back.
	### Header 3
	
	> This is a blockquote.
	> 
	> This is the second paragraph in the blockquote.
	>
	> ## This is an H2 in a blockquote

显示效果为:

A First Level Header
====================
A Second Level Header
---------------------

Now is the time for all good men to come to
the aid of their country. This is just a
regular paragraph.

The quick brown fox jumped over the lazy
dog's back.
### Header 3

> This is a blockquote.
> 
> This is the second paragraph in the blockquote.
>
> ## This is an H2 in a blockquote

#修辞和强调

Markdown 使用星号和底线来标记需要强调的区段。

Markdown 语法:

	Some of these words *are emphasized*.
	Some of these words _are emphasized also_.
	Use two asterisks for **strong emphasis**.
	Or, if you prefer, __use two underscores instead__.

显示效果为:

Some of these words *are emphasized*.
Some of these words _are emphasized also_.
Use two asterisks for **strong emphasis**.
Or, if you prefer, __use two underscores instead__.

#列表

无序列表使用星号、加号和减号来做为列表的项目标记,这些符号是都可以使用的,使用星号:

	* Candy.
	* Gum.
	* Booze.

显示效果为:

* Candy.
* Gum.
* Booze.

有序的列表则是使用一般的数字接着一个英文句点作为项目标记:

	1. Red
	2. Green
	3. Blue

显示效果为:

1. Red
2. Green
3. Blue

#链接

Markdown 支援两种形式的链接语法: 行内 和 参考 两种形式,两种都是使用角括号来把文字转成连结。

行内形式是直接在后面用括号直接接上链接:

	This is [github](http://github.com/ "github").

显示效果为:

This is [github](http://github.com/ "github").

参考形式的链接让你可以为链接定一个名称,之后你可以在文件的其他地方定义该链接的内容:

	I get 10 times more traffic from [Google][1] than from
	[Yahoo][2] or [MSN][3].
	
	[1]: http://google.com/ "Google"
	[2]: http://search.yahoo.com/ "Yahoo Search"
	[msn]: http://search.msn.com/ "MSN Search"

显示效果为:

I get 10 times more traffic from [Google][1] than from
[Yahoo][2] or [MSN][3].

[1]: http://google.com/ "Google"
[2]: http://search.yahoo.com/ "Yahoo Search"
[msn]: http://search.msn.com/ "MSN Search"

title 属性是选择性的,链接名称可以用字母、数字和空格,但是不分大小写:

#图片

图片的语法和链接很像。

行内形式(title 是选择性的):

	![我的头像](http://static.oschina.net/uploads/user/53/106378_50.jpg "Title")

显示效果为:

![我的头像](http://static.oschina.net/uploads/user/53/106378_50.jpg "Title")


#代码

在一般的段落文字中,你可以使用反引号 ` 来标记代码区段,区段内的 &、< 和 > 都会被自动的转换成 HTML 实体,这项特性让你可以很容易的在代码区段内插入 HTML 码:

	I strongly recommend against using any `<blink>` tags.
	
	I wish SmartyPants used named entities like `&mdash;`
	instead of decimal-encoded entites like `&#8212;`.

显示效果为:

I strongly recommend against using any `<blink>` tags.

I wish SmartyPants used named entities like `&mdash;`
instead of decimal-encoded entites like `&#8212;`.

如果要建立一个已经格式化好的代码区块,只要每行都缩进 4 个空格或是一个 tab 就可以了,而 &、< 和 > 也一样会自动转成 HTML 实体。

Markdown 语法:

	If you want your page to validate under XHTML 1.0 Strict,
	you've got to put paragraph tags in your blockquotes:
	
	<blockquote>
	<p>For example.</p>
	</blockquote>

显示效果为:

If you want your page to validate under XHTML 1.0 Strict,
you've got to put paragraph tags in your blockquotes:

<blockquote>
<p>For example.</p>
</blockquote>



Refers:
1. [http://wowubuntu.com/markdown/basic.html](http://wowubuntu.com/markdown/basic.html)
2. [http://jianshu.io/p/q81RER](http://jianshu.io/p/q81RER)
3. [http://www.ituring.com.cn/article/23](http://www.ituring.com.cn/article/23)
4. [http://www.oschina.net/question/100267_75314](http://www.oschina.net/question/100267_75314)


[github]: http://github.com
[Setext]: http://docutils.sourceforge.net/mirror/setext.html
[atx]: http://www.aaronsw.com/2002/atx/

转载于:https://my.oschina.net/magicly007/blog/210376

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值