Markdown 是一种轻量级标记语言,创始人为约翰·格鲁伯(John Gruber)。它允许人们“使用易读易写的纯文本格式编写文档,然后转换成有效的XHTML(或者HTML)文档”。
—— 维基百科
很早就接触到Markdown,但投入使用是从用Github和Stack Overflow开始的。使用Markdown,你不用再和难用的编辑器纠缠,手也不用离开键盘,这让你更专注于内容本身。
基本用法
Phrase Emphasis
1 2 3 |
*italic* **bold** _italic_ __bold__ |
Links
Inline:
1 2 |
An [example](http://url.com/ "Title") |
Reference-style labels (titles are optional):
1 2 3 4 5 |
An [example][id]. Then, anywhere else in the doc, define the link: [id]: http://example.com/ "Title" |
Images
Inline (titles are optional):
1 2 |
 |
Reference-style:
1 2 3 4 |
![alt text][id] [id]: /url/to/img.jpg "Title" |
Headers
Setext-style:
1 2 3 4 5 6 |
Header 1 ======== Header 2 -------- |
atx-style (closing #’s are optional):
1 2 3 4 5 6 |
# Header 1 # ## Header 2 ## ###### Header 6 |
Lists
Ordered, without paragraphs:
1 2 3 |
1. Foo 2. Bar |
Unordered, with paragraphs:
1 2 3 4 5 6 |
* A list item. With multiple paragraphs. * Bar |
You can nest them:
1 2 3 4 5 6 7 8 9 |
* Abacus * answer * Bubbles 1. bunk 2. bupkis * BELITTLER 3. burper * Cunning |
Blockquotes
1 2 3 4 5 6 7 8 9 10 |
> Email-style angle brackets > are used for blockquotes. > > And, they can be nested. > #### Headers in blockquotes > > * You can quote a list. > * Etc. |
Code Spans
1 2 3 4 5 6 |
`<code>` spans are delimited by backticks. You can include literal backticks like `` `this` ``. |
Preformatted Code Blocks
Indent every line of a code block by at least 4 spaces or 1 tab.
1 2 3 4 5 |
This is a normal paragraph. This is a preformatted code block. |
Horizontal Rules
Three or more dashes or asterisks:
1 2 3 4 5 6 |
--- * * * - - - - |
Manual Line Breaks
End a line with two or more spaces:
1 2 |
Roses are red, Violets are blue. |
其他规则
- 支持HTML标签,可以自由的插入HTML。
- 自动转义特殊字符:“&”和“<”。
- 如果你想显示一个被用作标记的符号,使用反斜线进行转义。比如下面这行将不会加粗文本,而只是显示出两个星号。
1 |
\*literal asterisks\* |
- 可以被转义的符号:
1 2 3 4 5 6 7 8 9 10 11 12 |
\ backslash ` backtick * asterisk _ underscore {} curly braces [] square brackets () parentheses # hash mark + plus sign - minus sign (hyphen) . dot ! exclamation mark |
编辑器
大部分编辑器都能实现即时预览和PDF、HTML文件输出。下面的推荐来自维基百科的Markdown词条页面。
- Cmd Markdown Cmd Markdown 编辑阅读器,支持实时同步预览,区分写作和阅读模式,支持在线存储,分享文稿网址。
- Dillinger.io 一个在线Markdown编辑器,提供实时预览以及到 GitHub 和 Dropbox 的拓展连接。
- notepag 另一个在线Markdown编辑器,支持实时预览,提供临时网址和和密码,可以分享给其他人。
- 简书 一个在线Markdown编辑器与阅读社区,支持实时预览,提供分享网址。
- Mou 一个Mac OS X上的Markdown编辑器。
- MacDown OS X 上的 Markdown 开源编辑器,作者称其深受 Mou 启发。
- MarkdownPad Windows上的全功能Markdown编辑器。
- WMD a Javascript “WYSIWYM” editor for Markdown (from AttackLab)
- PageDown 一个Javascript写的 “WYSIWYM”(所见即所得)Markdown编辑器 (来自 StackOverflow)
- IPython Notebook 以IPython为后台,利用浏览器做IDE,支持Markdown与LaTex公式。