MarkDown基本語法
Markdown
Markdown 是一種輕量級標記語言,創始人為約翰·格魯伯(John Gruber)。 它允許人們“使用易讀易寫的純文本格式編寫文檔,然後轉換成有效的XHTML(或者HTML)文檔”。
John Gruber 在 2004 年創造了 Markdown 語言,在語法上有很大一部分是跟 Aaron Swartz 共同合作的。這個語言的目的是希望大家使用“易於閱讀、易於撰寫的純文字格式,並選擇性的轉換成有效的 XHTML (或是HTML)”。 其中最重要的設計是可讀性,也就是說這個語言應該要能直接在字面上的被閱讀,而不用被一些格式化指令標記 (像是 RTF 與 HTML)。 因此,它是現行電子郵件標記格式的慣例,雖然它也借鏡了很多早期的標記語言,如:setext、Texile、reStructuredText。 許多網站都使用 Markdown 或是其變種,例如:GitHub、reddit、Diaspora、Stack Exchange、OpenStreetMap 與 SourceForge 讓用戶更利於討論。
Github MarkDown
Markdown 標記轉成HTML的樣式每個網站有自己的風格, 但整體的標記格式是統一的. 我們以github來保存相關的文檔, 所以我們以github的為樣式為標準.
以下的風格是以github的markdown的風格標準.
* 具體請參考: github的文檔
標題
使用#
,可表示1-6級標題。
# 一級標題
## 二級標題
### 三級標題
#### 四級標題
##### 五級標題
###### 六級標題
效果:
一級標題
二級標題
三級標題
四級標題
五級標題
六級標題
文字修飾符
看一下粗體字, 斜體字的標記.
1 *This text will be italic* 2_This will also be italic_ 3 4 **This text will be bold** 5 __This will also be bold__ 6 7 ~~This text will be delete~~ 8 _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 delete
You can combine them
列表
無序列表
主要使用-
和*
來標記無序列表
1 - George Washington 2 - John Adams 3 * Thomas Jefferson
效果:
- George Washington
- John Adams
- Thomas Jefferson
有序列表
1 1. James Madison 2 2. James Monroe 3 3. John Quincy Adams
效果:
- James Madison
- James Monroe
- John Quincy Adams
1 1. James Madison 2 1. James Monroe 3 1. John Quincy Adams
效果:
- James Madison
- James Monroe
- John Quincy Adams
1 1. Make my changes 2 1. Fix bug 3 2. Improve formatting 4 * Make the headings bigger 5 2. Push my commits to GitHub 6 3. Open a pull request 7 * Describe my changes 8 * Mention all the members of my team 9 * Ask for feedback
效果:
- Make my changes
- Fix bug
- Improve formatting
- Make the headings bigger
- Push my commits to GitHub
- Open a pull request
- Describe my changes
- Mention all the members of my team
- Ask for feedback
任務列表
1 - [x] Finish my changes 2 - [ ] Push my commits to GitHub 3 - [ ] Open a pull request
效果:
- [x] Finish my changes
- [ ] Push my commits to GitHub
- [ ] Open a pull request
段落
段落的前後要有空行,所謂的空行是指沒有文字內容。若想在段內強制換行的方式是使用兩個以上空格
加上回車(引用中換行省略回車)。
區塊引用
在段落的每行或者只在第一行使用符號>
,還可使用多個嵌套引用,如:
> 區塊引用
>> 嵌套引用
效果:
區塊引用
嵌套引用
鏈接
1 [github](http://github.com)
效果:
github
圖片
1 If you want to embed images, this is how you do it: 2 3 ![Image of Yaktocat](https://octodex.github.com/images/yaktocat.png)
效果:
If you want to embed images, this is how you do it:
整體樣式
1 ## Structured documents 2 3 Sometimes it‘s useful to have different levels of headings to structure your documents. Start lines with a `#` to create headings. Multiple `##` in a row denote smaller heading sizes. 4 5 #### This is a third-tier heading 6 7 You can use one `#` all the way up to `######` six for different heading sizes. 8 9 If you‘d like to quote someone, use the > character before the line: 10 11 > Coffee. The finest organic suspension ever devised... I beat the Borg with it. 12 > - Captain Janeway
效果:
Structured documents
Sometimes it’s useful to have different levels of headings to structure your documents. Start lines with a #
to create headings. Multiple ##
in a row denote smaller heading sizes.
This is a third-tier heading
You can use one #
all the way up to ######
six for different heading sizes.
If you’d like to quote someone, use the > character before the line:
Coffee. The finest organic suspension ever devised… I beat the Borg with it.
- Captain Janeway
代碼塊
```c
#include <stdio.h>
int main(void){
printf(“hello world!”);
return 0;
}
```
效果:
1 #include <stdio.h> 2 int main(void){ 3 printf("hello world!"); 4 return 0; 5 }
支持Emoji表情
1 @octocat :+1: This PR looks great - it‘s ready to merge! :shipit:
效果:
1 @octocat :+1: This PR looks great - it’s ready to merge! :shipit:
- Emoji表情
表格
1 標題 | 內容 | 備註 2 -----|------|----- 3 今天 | 很熱 | 少穿 4 昨天 | 下雨 | 打傘
效果:
標題 | 內容 | 備註 |
---|---|---|
今天 | 很熱 | 少穿 |
昨天 | 下雨 | 打傘 |
常用
一張圖說明, 所有的一切.
參考文檔
- 維基百科,自由的百科全書 - Markdown
- Mastering Markdown
- Markdown Cheatsheet
MarkDown基本語法