modified: diffout.py
[GalaxyCodeBases.git] / pubdoc / Markdown-Syntax-CN / basics.md
blob58a1e7a57e018af1bd169f7ca1c45c7411d68cc7
1 << [访问 Wow!Ubuntu](http://wowubuntu.com)
3 **声明:** 这份文档派生(fork)于[繁体中文版](http://markdown.tw/),在此基础上进行了繁体转简体工作,并进行了适当的润色。此文档用 Markdown 语法编写,你可以到这里[查看它的源文件][src1]。「繁体中文版的原始文件可以[查看这里][src]」--By @[riku][t]
5 **注:** 本项目托管于 [GitCafe][]上,请通过"派生"和"合并请求"来帮忙改进本项目。
7 [src1]:http://gitcafe.com/riku/Markdown-Syntax-CN/blob/master/basics.md
8 [src]: https://github.com/othree/markdown-syntax-zhtw/blob/master/basics.md
9 [t]: http://twitter.com/riku
10 [g]: http://gitcafe.com/riku/Markdown-Syntax-CN
11 [GitCafe]: http://gitcafe.com/riku/Markdown-Syntax-CN/
13 Markdown: Basics (快速入门) / ([点击查看完整语法说明](./index.html))
14 ================
16 Getting the Gist of Markdown's Formatting Syntax
17 ------------------------------------------------
19 此页提供了 Markdown 的简单概念, [语法说明][s] 页提供了完整详细的文档,说明了每项功能。但是 Markdown 其实很简单就可以上手,此页文档提供了一些范例,并且每个范例都会提供输出的 HTML 结果。
21 [s]: http://gitcafe.com/riku/Markdown-Syntax-CN/blob/master/syntax.md "Markdown Syntax"
22 [d]: http://daringfireball.net/projects/markdown/dingus "Markdown Dingus"
24 其实直接试试看也是一个很不错的方法, [Dingus][d] 是一个网页应用程序,你可以把自已编写的 Markdown 文档转成 XHTML。
26 ## 段落、标题、区块代码 ##
28 一个段落是由一个以上的连接的行句组成,而一个以上的空行则会划分出不同的段落(空行的定义是显示上看起来像是空行,就被视为空行,例如有一行只有空白和 tab,那该行也会被视为空行),一般的段落不需要用空白或换行缩进。
30 Markdown 支持两种标题的语法,[Setext] [1] 和 [atx] [2] 形式。Setext 形式是用底线的形式,利用 `=` (最高阶标题)和 `-` (第二阶标题),Atx 形式在行首插入 1 到 6 个 `#` ,对应到标题 1 到 6 阶。
32 [1]: http://docutils.sourceforge.net/mirror/setext.html
33 [2]: http://www.aaronsw.com/2002/atx/
35 区块引用则使用 email 形式的 '`>`' 角括号。
37 Markdown 语法:
39         A First Level Header
40         ====================
41         A Second Level Header
42         ---------------------
44         Now is the time for all good men to come to
45         the aid of their country. This is just a
46         regular paragraph.
48         The quick brown fox jumped over the lazy
49         dog's back.
50         ### Header 3
52         > This is a blockquote.
53         > 
54         > This is the second paragraph in the blockquote.
55         >
56         > ## This is an H2 in a blockquote
58 输出 HTML 为:
60         <h1>A First Level Header</h1>
61         <h2>A Second Level Header</h2>
62         <p>Now is the time for all good men to come to
63         the aid of their country. This is just a
64         regular paragraph.</p>
65         <p>The quick brown fox jumped over the lazy
66         dog's back.</p>
67         <h3>Header 3</h3>
68         <blockquote>
69         <p>This is a blockquote.</p>
70         <p>This is the second paragraph in the blockquote.</p>
71         <h2>This is an H2 in a blockquote</h2>
72         </blockquote>
74 ### 修辞和强调 ###
76 Markdown 使用星号和底线来标记需要强调的区段。
78 Markdown 语法:
80         Some of these words *are emphasized*.
81         Some of these words _are emphasized also_.
82         Use two asterisks for **strong emphasis**.
83         Or, if you prefer, __use two underscores instead__.
85 输出 HTML 为:
87         <p>Some of these words <em>are emphasized</em>.
88         Some of these words <em>are emphasized also</em>.</p>
89         <p>Use two asterisks for <strong>strong emphasis</strong>.
90         Or, if you prefer, <strong>use two underscores instead</strong>.</p>
92 ## 列表 ##
94 无序列表使用星号、加号和减号来做为列表的项目标记,这些符号是都可以使用的,使用星号:
96         * Candy.
97         * Gum.
98         * Booze.
100 加号:
102         + Candy.
103         + Gum.
104         + Booze.
106 和减号
108         - Candy.
109         - Gum.
110         - Booze.
112 都会输出 HTML 为:
114         <ul>
115         <li>Candy.</li>
116         <li>Gum.</li>
117         <li>Booze.</li>
118         </ul>
120 有序的列表则是使用一般的数字接着一个英文句点作为项目标记:
122         1. Red
123         2. Green
124         3. Blue
126 输出 HTML 为:
128         <ol>
129         <li>Red</li>
130         <li>Green</li>
131         <li>Blue</li>
132         </ol>
134 如果你在项目之间插入空行,那项目的内容会用 `<p>` 包起来,你也可以在一个项目内放上多个段落,只要在它前面缩排 4 个空白或 1 个 tab 。
136         * A list item.
137         
138                 With multiple paragraphs.
140         * Another item in the list.
142 输出 HTML 为:
144         <ul>
145         <li><p>A list item.</p>
146         <p>With multiple paragraphs.</p></li>
147         <li><p>Another item in the list.</p></li>
148         </ul>
149 ### 链接 ###
151 Markdown 支援两种形式的链接语法: *行内* 和 *参考* 两种形式,两种都是使用角括号来把文字转成连结。
153 行内形式是直接在后面用括号直接接上链接:
155         This is an [example link](http://example.com/).
157 输出 HTML 为:
159         <p>This is an <a href="http://example.com/">
160         example link</a>.</p>
162 你也可以选择性的加上 title 属性:
164         This is an [example link](http://example.com/ "With a Title").
166 输出 HTML 为:
168         <p>This is an <a href="http://example.com/" title="With a Title">
169         example link</a>.</p>
171 参考形式的链接让你可以为链接定一个名称,之后你可以在文件的其他地方定义该链接的内容:
173         I get 10 times more traffic from [Google][1] than from
174         [Yahoo][2] or [MSN][3].
175         
176         [1]: http://google.com/ "Google"
177         [2]: http://search.yahoo.com/ "Yahoo Search"
178         [3]: http://search.msn.com/ "MSN Search"
180 输出 HTML 为:
182         <p>I get 10 times more traffic from <a href="http://google.com/"
183         title="Google">Google</a> than from <a href="http://search.yahoo.com/"
184         title="Yahoo Search">Yahoo</a> or <a href="http://search.msn.com/"
185         title="MSN Search">MSN</a>.</p>
187 title 属性是选择性的,链接名称可以用字母、数字和空格,但是不分大小写:
189         I start my morning with a cup of coffee and
190         [The New York Times][NY Times].
192         [ny times]: http://www.nytimes.com/
194 输出 HTML 为:
196         <p>I start my morning with a cup of coffee and
197         <a href="http://www.nytimes.com/">The New York Times</a>.</p>
200 ### 图片 ###
202 图片的语法和链接很像。
204 行内形式(title 是选择性的):
206         ![alt text](/path/to/img.jpg "Title")
208 参考形式:
210         ![alt text][id]
212         [id]: /path/to/img.jpg "Title"
214 上面两种方法都会输出 HTML 为:
216         <img src="/path/to/img.jpg" alt="alt text" title="Title" />
218 ### 代码 ###
219 在一般的段落文字中,你可以使用反引号 `` ` `` 来标记代码区段,区段内的 `&`、`<` 和 `>` 都会被自动的转换成 HTML 实体,这项特性让你可以很容易的在代码区段内插入 HTML 码:
221         I strongly recommend against using any `<blink>` tags.
223         I wish SmartyPants used named entities like `&mdash;`
224         instead of decimal-encoded entites like `&#8212;`.
226 输出 HTML 为:
228         <p>I strongly recommend against using any
229         <code>&lt;blink&gt;</code> tags.</p>
230         <p>I wish SmartyPants used named entities like
231         <code>&amp;mdash;</code> instead of decimal-encoded
232         entites like <code>&amp;#8212;</code>.</p>
234 如果要建立一个已经格式化好的代码区块,只要每行都缩进 4 个空格或是一个 tab 就可以了,而 `&`、`<` 和 `>` 也一样会自动转成 HTML 实体。
236 Markdown 语法:
238         If you want your page to validate under XHTML 1.0 Strict,
239         you've got to put paragraph tags in your blockquotes:
241         <blockquote>
242         <p>For example.</p>
243         </blockquote>
245 输出 HTML 为:
247         <p>If you want your page to validate under XHTML 1.0 Strict,
248         you've got to put paragraph tags in your blockquotes:</p>
249         <pre><code>&lt;blockquote&gt;
250         &lt;p&gt;For example.&lt;/p&gt;
251         &lt;/blockquote&gt;
252         </code></pre>