DIV CSS 佈局教程網

 DIV+CSS佈局教程網 >> 網頁腳本 >> WEB網站前端 >> WEB前端代碼 >> Markdown 簡明語法手冊
Markdown 簡明語法手冊
編輯:WEB前端代碼     

Markdown 簡明語法手冊

根據個人使用情況有所修改。

Markdown是一種輕量級標記語言,簡稱md。創始人為約翰·格魯伯(John Gruber)。它允許人們“使用易讀易寫的純文本格式編寫文檔,然後轉換成有效的XHTML(或者HTML)文檔”。這種語言吸收了很多在電子郵件中已有的純文本標記的特性。——維基百科

1. 標題

# 一級標題
## 二級標題
...
###### 六級標題

一級標題,一個#號

二級標題

三級標題

......

六級標題,六個#號

2. 列表

- 無序列表

1. 有序列表
  • 我是無序列表:減號加空格
  1. 我是有序列表:直接數字加點句號。

3. 引用

> 引用內容

引用內容

4. 粗體和斜體

**兩個星號是粗體**
*一個星號是斜體*

Hello World!

Hello World!

5.鏈接與圖片

<http://hovertree.com/>
 <[email protected]>

http://hovertree.com/
[email protected]

鏈接直接輸入,網址,郵箱用尖括號包著自動就有了。

插入鏈接有兩種方法:一種是行間文字鏈接,一種是行外文字鏈接。

 [link text](http://hovertree.com/ "optional title")

 [link text][id]
 [id]: http://hovertree.com/  "optional title here"

鏈接文字內容

[鏈接文字內容][id]
[id]: http://hovertree.com/ "optional title here"

插入圖片

 ![](/path/to/img.jpg "optional title")

023b5bb5c9ea15ce21039443b6003af33b87b28e

 [![][jane-eyre-pic]{ImgCap}{/ImgCap}][jane-eyre-douban]

 [jane-eyre-pic]: http://hovertree.com/hvtimg/bjafaj/9h2t2lm5.jpg
 [jane-eyre-douban]: http://hovertree.com/jq/hovertreeimg/

6. 插入代碼

? 如果段落開頭使用了tab,會被認為是代碼塊。

  <php>
       echo “hello world";
  </php>

簡單地說是用三個“ ` ”加上語言表示,比如javascript,phphtml等等。

行內代碼:用點號`引起來就好

 Use the `printf()` function.

7. 分割線和刪除線

在一行之內用三個以上的星號,減號,下劃線建立分割線,用2個~建立刪除線。

8. 代碼塊和語法高亮

 ```ruby
 require 'redcarpet'
 markdown = Redcarpet.new("Hello World!")
 puts markdown.to_html
 ```
function(){
  alert('hello world!')
}

語法詳解

段落、標題、區塊代碼

區塊引用則使用 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

一串文字在下面加上一串等號也是一級標題

一串文字加上一串減號就是二級標題

換行可以直接用回車鍵

換行可以直接用回車鍵

三級標題:好像只能用三個#了

這是一段引用.

此乃引用中的第二行,需要回車後另起一行寫個>

在引用裡面寫兩個#就成了引用中的二級標題

修辭和強調

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.
  • 前面加一個+號也是無序列表

和減號

- Candy.
- Gum.
- Booze.
  • 前面加一個減號還是無序列表

有序的列表則是使用一般的數字接著一個英文句點作為項目標記:

1\. Red
2\. Green
3\. Blue

注意. 本文檔的序號都是使用數字\.的方式寫就的。

鏈接

Markdown 支援兩種形式的鏈接語法: 行內參考 兩種形式,兩種都是使用角括號來把文字轉成連結。

行內形式是直接在後面用括號直接接上鏈接:

This is an [hovertree link](http://hovertree.com/).

This is an hovertree link.

你也可以選擇性的加上 title 屬性:

This is an [hovertree link](http://hovertree.com/ "With a Title").

This is an hovertree link.(懸停會有提示,看編輯器而定)

參考形式的鏈接讓你可以為鏈接定一個名稱,之後你可以在文件的其他地方定義該鏈接的內容:

I get 10 times more traffic from [HoverTree][1] than from
[Keleyi][2] or [HoverClock][3].

[1]: http://hovertree.com/ "HoverTree"
[2]: http:/// "Keleyi"
[3]: http://hovertree.com/texiao/hoverclock/ "HoverClock"

圖片

圖片的語法和鏈接很像。

行內形式(title 是選擇性的):

![](圖片路徑 "Title"){ImgCap}alt text{/ImgCap}

行外注腳形式:

![][id]{ImgCap}alt text{/ImgCap}

[id]: /path/to/img.jpg "Title"

代碼

在一般的段落文字中,你可以使用反引號 ``來標記代碼區段,區段內的&<>` 都會被自動的轉換成 HTML 實體,這項特性讓你可以很容易的在代碼區段內插入 HTML 碼:

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

I wish SmartyPants used named entities like `—`
instead of decimal-encoded entites like `—`.

如果要建立一個已經格式化好的代碼區塊,只要每行都縮進 4 個空格或是一個 tab 就可以了,而 &<> 也一樣會自動轉成 HTML 實體。

XML學習教程| jQuery入門知識| AJAX入門| Dreamweaver教程| Fireworks入門知識| SEO技巧| SEO優化集錦|
Copyright © DIV+CSS佈局教程網 All Rights Reserved