修改理由:

Markdown格式文档重新编写。

详细描述:

重构 Markdown 格式文档重新编写。

相关信息:


此投稿已在 4年前 合并。

内容修改:

红色背景 为原始内容

绿色背景 为新增或者修改的内容

OldNewDifferences
1 ## 说明
2 
3 如果你觉得语法太多太难记,可以先从 https://learnku.com/docs/writing-docs/markdown-guide/6442 学起。
4 
5 ## 概述
6 
7 ### 宗旨
8 
9 Markdown 的目标是实现「易读易写」。
10 
11 可读性,无论如何,都是最重要的。一份使用 Markdown 格式撰写的文件应该可以直接以纯文本发布,并且看起来不会像是由许多标签或是格式指令所构成。Markdown 语法受到一些既有 text-to-HTML 格式的影响,包括 [Setext] [1](http://docutils.sourceforge.net/mirror/setext.html)、[atx] [2](http://www.aaronsw.com/2002/atx/)、[Textile] [3](http://textism.com/tools/textile/)、[reStructuredText] [4](http://docutils.sourceforge.net/rst.html)、[Grutatext] [5](http://www.triptico.com/software/grutatxt.html) 和 [EtText] [6](http://ettext.taint.org/doc/),而最大灵感来源其实是纯文本电子邮件的格式。
12 
13 总之, Markdown 的语法全由一些符号所组成,这些符号经过精挑细选,其作用一目了然。比如:在文字两旁加上星号,看起来就像*强调*。Markdown 的列表看起来,嗯,就是列表。Markdown 的区块引用看起来就真的像是引用一段文字,就像你曾在电子邮件中见过的那样。
14 
15 ### 兼容 HTML
16 
17 Markdown 语法的目标是:成为一种适用于网络的*书写*语言。
18 
19 Markdown 不是想要取代 HTML,甚至也没有要和它相近,它的语法种类很少,只对应 HTML 标记的一小部分。Markdown 的构想*不是*要使得 HTML 文档更容易书写。在我看来, HTML 已经很容易写了。Markdown 的理念是,能让文档更容易读、写和随意改。HTML 是一种*发布*的格式,Markdown 是一种*书写*的格式。就这样,Markdown 的格式语法只涵盖纯文本可以涵盖的范围。
20 
21 不在 Markdown 涵盖范围之内的标签,都可以直接在文档里面用 HTML 撰写。不需要额外标注这是 HTML 或是 Markdown;只要直接加标签就可以了。
22 
23 要制约的只有一些 HTML 区块元素――比如 `<div>`、`<table>`、`<pre>`、`<p>` 等标签,必须在前后加上空行与其它内容区隔开,还要求它们的开始标签与结尾标签不能用制表符或空格来缩进。Markdown 的生成器有足够智能,不会在 HTML 区块标签外加上不必要的 `<p>` 标签。
24 
25 例子如下,在 Markdown 文件里加上一段 HTML 表格:
26 
27 ```
28 这是一个普通段落。
29 
30 <table>
31    <tr>
32        <td>Foo</td>
33    </tr>
34 </table>
35 
36 这是另一个普通段落。
37 
38 ```
39 
40 请注意,在 HTML 区块标签间的 Markdown 格式语法将不会被处理。比如,你在 HTML 区块内使用 Markdown 样式的`*强调*`会没有效果。
41 
42 HTML 的区段(行内)标签如 `<span>`、`<cite>`、`<del>` 可以在 Markdown 的段落、列表或是标题里随意使用。依照个人习惯,甚至可以不用 Markdown 格式,而直接采用 HTML 标签来格式化。举例说明:如果比较喜欢 HTML 的 `<a>` 或 `<img>` 标签,可以直接使用这些标签,而不用 Markdown 提供的链接或是图像标签语法。
43 
44 和处在 HTML 区块标签间不同,Markdown 语法在 HTML 区段标签间是有效的。
45 
46 ### 特殊字符自动转换
47 
48 在 HTML 文件中,有两个字符需要特殊处理: `<` 和 `&` 。 `<` 符号用于起始标签,`&` 符号则用于标记 HTML 实体,如果你只是想要显示这些字符的原型,你必须要使用实体的形式,像是 `&lt;` 和 `&amp;`。
49 
50 `&` 字符尤其让网络文档编写者受折磨,如果你要打「`AT&T`」 ,你必须要写成「`AT&amp;T`」。而网址中的 `&` 字符也要转换。比如你要链接到:
51 
52 ```
53 http://images.google.com/images?num=30&q=larry+bird
54 
55 ```
56 
57 你必须要把网址转换写为:
58 
59 ```
60 http://images.google.com/images?num=30&amp;q=larry+bird
61 
62 ```
63 
64 才能放到链接标签的 `href` 属性里。不用说也知道这很容易忽略,这也可能是 HTML 标准检验所检查到的错误中,数量最多的。
65 
66 Markdown 让你可以自然地书写字符,需要转换的由它来处理好了。如果你使用的 `&` 字符是 HTML 字符实体的一部分,它会保留原状,否则它会被转换成 `&amp`;。
67 
68 所以你如果要在文档中插入一个版权符号 `©`,你可以这样写:
69 
70 ```
71 &copy;
72 
73 ```
74 
75 Markdown 会保留它不动。而若你写:
76 
77 ```
78 AT&T
79 
80 ```
81 
82 Markdown 就会将它转为:
83 
84 ```
85 AT&amp;T
86 
87 ```
88 
89 类似的状况也会发生在 `<` 符号上,因为 Markdown 允许 [兼容 HTML](https://github.com/riku/Markdown-Syntax-CN/blob/master/syntax.md#html) ,如果你是把 `<` 符号作为 HTML 标签的定界符使用,那 Markdown 也不会对它做任何转换,但是如果你写:
90 
91 ```
92 4 < 5
93 
94 ```
95 
96 Markdown 将会把它转换为:
97 
98 ```
99 4 &lt; 5
100 
101 ```
102 
103 不过需要注意的是,code 范围内,不论是行内还是区块, `<` 和 `&` 两个符号都*一定*会被转换成 HTML 实体,这项特性让你可以很容易地用 Markdown 写 HTML code (和 HTML 相对而言, HTML 语法中,你要把所有的 `<` 和 `&` 都转换为 HTML 实体,才能在 HTML 文件里面写出 HTML code。)
104 
105 * * * * *
106 
107 ## 区块元素
108 
109 ### 段落和换行
110 
111 一个 Markdown 段落是由一个或多个连续的文本行组成,它的前后要有一个以上的空行(空行的定义是显示上看起来像是空的,便会被视为空行。比方说,若某一行只包含空格和制表符,则该行也会被视为空行)。普通段落不该用空格或制表符来缩进。
112 
113 「由一个或多个连续的文本行组成」这句话其实暗示了 Markdown 允许段落内的强迫换行(插入换行符),这个特性和其他大部分的 text-to-HTML 格式不一样(包括 Movable Type 的「Convert Line Breaks」选项),其它的格式会把每个换行符都转成 `<br />` 标签。
114 
115 如果你*确实*想要依赖 Markdown 来插入 `<br />` 标签的话,在插入处先按入两个以上的空格然后回车。
116 
117 的确,需要多费点事(多加空格)来产生 `<br />` ,但是简单地「每个换行都转换为 `<br />`」的方法在 Markdown 中并不适合, Markdown 中 email 式的 [区块引用](https://github.com/riku/Markdown-Syntax-CN/blob/master/syntax.md#blockquote) 和多段落的 [列表](https://github.com/riku/Markdown-Syntax-CN/blob/master/syntax.md#list) 在使用换行来排版的时候,不但更好用,还更方便阅读。
118 
119 ### 标题
120 
121 Markdown 支持两种标题的语法,类 [Setext] [1](http://docutils.sourceforge.net/mirror/setext.html) 和类 [atx] [2](http://www.aaronsw.com/2002/atx/) 形式。
122 
123 类 Setext 形式是用底线的形式,利用 `=` (最高阶标题)和 `-` (第二阶标题),例如:
124 
125 ```
126 This is an H1
 1>如果你觉得语法太多太难记,可以先从 https://learnku.com/docs/writing-docs/markdown-guide/6442 学起。
 2
 3### 主要特性
 4
 5- 支持“标准”Markdown / CommonMark和Github风格的语法,也可变身为代码编辑器;
 6- 支持实时预览、图片(跨域)上传、预格式文本/代码/表格插入、代码折叠、搜索替换、只读模式、自定义样式主题和多语言语法高亮等功能;
 7- 支持 Emoji表情、Task lists、@链接等Markdown扩展语法;
 8- 支持识别和解析HTML标签,并且支持自定义过滤标签解析,具有可靠的安全性和几乎无限的扩展性;
 9- 支持 AMD / CMD 模块化加载(支持 Require.js & Sea.js),并且支持自定义扩展插件;
 10- 兼容主流的浏览器(IE8+)和Zepto.js,且支持iPad等平板设备;
 11
 12**目录 (Table of Contents)**
 13
 14# Heading 1
 15
 16## Heading 2
 17
 18### Heading 3
 19
 20#### Heading 4
 21
 22##### Heading 5
 23
 24###### Heading 6
 25
 26# Heading 1 link [Heading link](https://learnku.com/python "Heading link")
 27
 28## Heading 2 link [Heading link](https://learnku.com/python "Heading link")
 29
 30### Heading 3 link [Heading link](https://learnku.com/python "Heading link")
 31
 32#### Heading 4 link [Heading link](https://learnku.com/python "Heading link") Heading link [Heading link](https://learnku.com/python "Heading link")
 33
 34##### Heading 5 link [Heading link](https://learnku.com/python "Heading link")
 35
 36###### Heading 6 link [Heading link](https://learnku.com/python "Heading link")
 37
 38#### 标题(用底线的形式)Heading (underline)
 39**代码展示:**
 40```
 41This is an H1
12742=============
12843
129 This is an H2
 44This is an H2
 45
13046-------------
131 
132 ```
133 
134 任何数量的 `=` 和 `-` 都可以有效果。
135 
136 类 Atx 形式则是在行首插入 1 到 6 个 `#` ,对应到标题 1 到 6 阶,例如:
137 
138 ```
139 # 这是 H1
140 
141 ## 这是 H2
142 
143 ###### 这是 H6
144 
145 ```
146 
147 你可以选择性地「闭合」类 atx 样式的标题,这纯粹只是美观用的,若是觉得这样看起来比较舒适,你就可以在行尾加上 `#`,而行尾的 `#` 数量也不用和开头一样(行首的井字符数量决定标题的阶数):
148 
149 ```
150 # 这是 H1 #
151 
152 ## 这是 H2 ##
153 
154 ### 这是 H3 ######
155 
156 ```
157 
158 ### 区块引用 Blockquotes
159 
160 Markdown 标记区块引用是使用类似 email 中用 `>` 的引用方式。如果你还熟悉在 email 信件中的引言部分,你就知道怎么在 Markdown 文件中建立一个区块引用,那会看起来像是你自己先断好行,然后在每行的最前面加上 `>` :
161 
162 ```
163 > This is a blockquote with two paragraphs. Lorem ipsum dolor sit amet,
164 > consectetuer adipiscing elit. Aliquam hendrerit mi posuere lectus.
165 > Vestibulum enim wisi, viverra nec, fringilla in, laoreet vitae, risus.
166 >
167 > Donec sit amet nisl. Aliquam semper ipsum sit amet velit. Suspendisse
168 > id sem consectetuer libero luctus adipiscing.
169 
170 ```
171 
172 Markdown 也允许你偷懒只在整个段落的第一行最前面加上 `>` :
173 
174 ```
175 > This is a blockquote with two paragraphs. Lorem ipsum dolor sit amet,
176 consectetuer adipiscing elit. Aliquam hendrerit mi posuere lectus.
177 Vestibulum enim wisi, viverra nec, fringilla in, laoreet vitae, risus.
178 
179 > Donec sit amet nisl. Aliquam semper ipsum sit amet velit. Suspendisse
180 id sem consectetuer libero luctus adipiscing.
181 
182 ```
183 
184 区块引用可以嵌套(例如:引用内的引用),只要根据层次加上不同数量的 `>` :
185 
186 ```
187 > This is the first level of quoting.
188 >
189 > > This is nested blockquote.
190 >
191 > Back to the first level.
192 
193 ```
194 
195 引用的区块内也可以使用其他的 Markdown 语法,包括标题、列表、代码区块等:
196 
197 ```
198 > ## 这是一个标题。
199 >
200 > 1.  这是第一行列表项。
201 > 2.  这是第二行列表项。
202 >
203 > 给出一些例子代码:
204 >
205 >    return shell_exec("echo $input | $markdown_script");
206 
207 ```
208 
209 任何像样的文本编辑器都能轻松地建立 email 型的引用。例如在 BBEdit 中,你可以选取文字后然后从选单中选择*增加引用阶层*。
210 
211 ### 列表
212 
213 Markdown 支持有序列表和无序列表。
214 
215 无序列表使用星号、加号或是减号作为列表标记:
216 
217 ```
218 *  Red
219 *  Green
220 *  Blue
221 
222 ```
223 
224 等同于:
225 
226 ```
227 +  Red
228 +  Green
229 +  Blue
230 
231 ```
232 
233 也等同于:
234 
235 ```
236 -  Red
237 -  Green
238 -  Blue
239 
240 ```
241 
242 有序列表则使用数字接着一个英文句点:
243 
244 ```
245 1. Bird
246 2. McHale
247 3. Parish
248 
249 ```
250 
251 很重要的一点是,你在列表标记上使用的数字并不会影响输出的 HTML 结果,上面的列表所产生的 HTML 标记为:
252 
253 ```
254 <ol>
255 <li>Bird</li>
256 <li>McHale</li>
257 <li>Parish</li>
258 </ol>
259 
260 ```
261 
262 如果你的列表标记写成:
263 
264 ```
265 1. Bird
266 1. McHale
267 1. Parish
268 
269 ```
270 
271 或甚至是:
272 
273 ```
274 3. Bird
275 1. McHale
276 8. Parish
277 
278 ```
279 
280 你都会得到完全相同的 HTML 输出。重点在于,你可以让 Markdown 文件的列表数字和输出的结果相同,或是你懒一点,你可以完全不用在意数字的正确性。
281 
282 如果你使用懒惰的写法,建议第一个项目最好还是从 1. 开始,因为 Markdown 未来可能会支持有序列表的 start 属性。
283 
284 列表项目标记通常是放在最左边,但是其实也可以缩进,最多 3 个空格,项目标记后面则一定要接着至少一个空格或制表符。
285 
286 要让列表看起来更漂亮,你可以把内容用固定的缩进整理好:
287 
288 ```
289 *  Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
290    Aliquam hendrerit mi posuere lectus. Vestibulum enim wisi,
291    viverra nec, fringilla in, laoreet vitae, risus.
292 *  Donec sit amet nisl. Aliquam semper ipsum sit amet velit.
293    Suspendisse id sem consectetuer libero luctus adipiscing.
294 
295 ```
296 
297 但是如果你懒,那也行:
298 
299 ```
300 *  Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
301 Aliquam hendrerit mi posuere lectus. Vestibulum enim wisi,
302 viverra nec, fringilla in, laoreet vitae, risus.
303 *  Donec sit amet nisl. Aliquam semper ipsum sit amet velit.
304 Suspendisse id sem consectetuer libero luctus adipiscing.
305 
306 ```
307 
308 如果列表项目间用空行分开,在输出 HTML 时 Markdown 就会将项目内容用 `<p>` 标签包起来,举例来说:
309 
310 ```
311 *  Bird
312 *  Magic
313 
314 ```
315 
316 会被转换为:
317 
318 ```
319 <ul>
320 <li>Bird</li>
321 <li>Magic</li>
322 </ul>
323 
324 ```
325 
326 但是这个:
327 
328 ```
329 *  Bird
330 
331 *  Magic
332 
333 ```
334 
335 会被转换为:
336 
337 ```
338 <ul>
339 <li><p>Bird</p></li>
340 <li><p>Magic</p></li>
341 </ul>
342 
343 ```
344 
345 列表项目可以包含多个段落,每个项目下的段落都必须缩进 4 个空格或是 1 个制表符:
346 
347 ```
348 1. This is a list item with two paragraphs. Lorem ipsum dolor
349    sit amet, consectetuer adipiscing elit. Aliquam hendrerit
350    mi posuere lectus.
351 
352    Vestibulum enim wisi, viverra nec, fringilla in, laoreet
353    vitae, risus. Donec sit amet nisl. Aliquam semper ipsum
354    sit amet velit.
355 
356 2. Suspendisse id sem consectetuer libero luctus adipiscing.
357 
358 ```
359 
360 如果你每行都有缩进,看起来会看好很多,当然,再次地,如果你很懒惰,Markdown 也允许:
361 
362 ```
363 *  This is a list item with two paragraphs.
364 
365    This is the second paragraph in the list item. You're
366 only required to indent the first line. Lorem ipsum dolor
367 sit amet, consectetuer adipiscing elit.
368 
369 *  Another item in the same list.
370 
371 ```
372 
373 如果要在列表项目内放进引用,那 `>` 就需要缩进:
374 
375 ```
376 *  A list item with a blockquote:
377 
378    > This is a blockquote
379    > inside a list item.
380 
381 ```
382 
383 如果要放代码区块的话,该区块就需要缩进*两次*,也就是 8 个空格或是 2 个制表符:
384 
385 ```
386 *  一列表项包含一个列表区块:
387 
388        <代码写在这>
389 
390 ```
391 
392 当然,项目列表很可能会不小心产生,像是下面这样的写法:
393 
394 ```
395 1986. What a great season.
396 
397 ```
398 
399 换句话说,也就是在行首出现*数字-句点-空白*,要避免这样的状况,你可以在句点前面加上反斜杠。
400 
401 ```
402 1986. What a great season.
403 
404 ```
405 
406 ### 代码区块
407 
408 和程序相关的写作或是标签语言原始码通常会有已经排版好的代码区块,通常这些区块我们并不希望它以一般段落文件的方式去排版,而是照原来的样子显示,Markdown 会用 `<pre>` 和 `<code>` 标签来把代码区块包起来。
409 
410 要在 Markdown 中建立代码区块很简单,只要简单地缩进 4 个空格或是 1 个制表符就可以,例如,下面的输入:
411 
412 ```
413 这是一个普通段落:
414 
415    这是一个代码区块。
416 
417 ```
418 
419 Markdown 会转换成:
420 
421 ```
422 <p>这是一个普通段落:</p>
423 
424 <pre><code>这是一个代码区块。
425 </code></pre>
426 
427 ```
428 
429 这个每行一阶的缩进(4 个空格或是 1 个制表符),都会被移除,例如:
430 
431 ```
432 Here is an example of AppleScript:
433 
434    tell application "Foo"
435        beep
436    end tell
437 
438 ```
439 
440 会被转换为:
441 
442 ```
443 <p>Here is an example of AppleScript:</p>
444 
445 <pre><code>tell application "Foo"
446    beep
447 end tell
448 </code></pre>
449 
450 ```
451 
452 一个代码区块会一直持续到没有缩进的那一行(或是文件结尾)。
453 
454 在代码区块里面, `&` 、 `<` 和 `>` 会自动转成 HTML 实体,这样的方式让你非常容易使用 Markdown 插入范例用的 HTML 原始码,只需要复制贴上,再加上缩进就可以了,剩下的 Markdown 都会帮你处理,例如:
455 
456 ```
457    <div class="footer">
458        &copy; 2004 Foo Corporation
459    </div>
460 
461 ```
462 
463 会被转换为:
464 
465 ```
466 <pre><code>&lt;div class="footer"&gt;
467    &amp;copy; 2004 Foo Corporation
468 &lt;/div&gt;
469 </code></pre>
470 
471 ```
472 
473 代码区块中,一般的 Markdown 语法不会被转换,像是星号便只是星号,这表示你可以很容易地以 Markdown 语法撰写 Markdown 语法相关的文件。
474 
475 ### 分隔线
476 
477 你可以在一行中用三个以上的星号、减号、底线来建立一个分隔线,行内不能有其他东西。你也可以在星号或是减号中间插入空格。下面每种写法都可以建立分隔线:
478 
479 ```
480 * * *
481 
482 ***
483 
484 *****
485 
486 - - -
487 
488 ---------------------------------------
489 
490 ```
491 
492 * * * * *
493 
494 ## 区段元素
495 
496 ### 链接
497 
498 Markdown 支持两种形式的链接语法: *行内式*和*参考式*两种形式。
499 
500 不管是哪一种,链接文字都是用 [方括号] 来标记。
501 
502 要建立一个*行内式*的链接,只要在方块括号后面紧接着圆括号并插入网址链接即可,如果你还想要加上链接的 title 文字,只要在网址后面,用双引号把 title 文字包起来即可,例如:
503 
504 ```
505 This is [an example](http://example.com/ "Title") inline link.
506 
507 [This link](http://example.net/) has no title attribute.
508 
509 ```
510 
511 会产生:
512 
513 ```
514 <p>This is <a href="http://example.com/" title="Title">
515 an example</a> inline link.</p>
516 
517 <p><a href="http://example.net/">This link</a> has no
518 title attribute.</p>
519 
520 ```
521 
522 如果你是要链接到同样主机的资源,你可以使用相对路径:
523 
524 ```
525 See my [About](/about/) page for details. 
526 
527 ```
528 
529 *参考式*的链接是在链接文字的括号后面再接上另一个方括号,而在第二个方括号里面要填入用以辨识链接的标记:
530 
531 ```
532 This is [an example][id] reference-style link.
533 
534 ```
535 
536 你也可以选择性地在两个方括号中间加上一个空格:
537 
538 ```
539 This is [an example] [id] reference-style link.
540 
541 ```
542 
543 接着,在文件的任意处,你可以把这个标记的链接内容定义出来:
544 
545 ```
546 [id]: http://example.com/ "Optional Title Here"
547 
548 ```
549 
550 链接内容定义的形式为:
551 
552 -  方括号(前面可以选择性地加上至多三个空格来缩进),里面输入链接文字
553 -  接着一个冒号
554 -  接着一个以上的空格或制表符
555 -  接着链接的网址
556 -  选择性地接着 title 内容,可以用单引号、双引号或是括弧包着
557 
558 下面这三种链接的定义都是相同:
559 
560 ```
561 [foo]: http://example.com/ "Optional Title Here"
562 [foo]: http://example.com/ 'Optional Title Here'
563 [foo]: http://example.com/ (Optional Title Here)
564 
565 ```
566 
567 **请注意:** 有一个已知的问题是 Markdown.pl 1.0.1 会忽略单引号包起来的链接 title。
568 
569 链接网址也可以用尖括号包起来:
570 
571 ```
572 [id]: <http://example.com/> "Optional Title Here"
573 
574 ```
575 
576 你也可以把 title 属性放到下一行,也可以加一些缩进,若网址太长的话,这样会比较好看:
577 
578 ```
579 [id]: http://example.com/longish/path/to/resource/here
580    "Optional Title Here"
581 
582 ```
583 
584 网址定义只有在产生链接的时候用到,并不会直接出现在文件之中。
585 
586 链接辨别标签可以有字母、数字、空白和标点符号,但是并*不*区分大小写,因此下面两个链接是一样的:
587 
588 ```
589 [link text][a]
590 [link text][A]
591 
592 ```
593 
594 *隐式链接标记*功能让你可以省略指定链接标记,这种情形下,链接标记会视为等同于链接文字,要用隐式链接标记只要在链接文字后面加上一个空的方括号,如果你要让 "Google" 链接到 google.com,你可以简化成:
595 
596 ```
597 [Google][]
598 
599 ```
600 
601 然后定义链接内容:
602 
603 ```
604 [Google]: http://google.com/
605 
606 ```
607 
608 由于链接文字可能包含空白,所以这种简化型的标记内也许包含多个单词:
609 
610 ```
611 Visit [Daring Fireball][] for more information.
612 
613 ```
614 
615 然后接着定义链接:
616 
617 ```
618 [Daring Fireball]: http://daringfireball.net/
619 
620 ```
621 
622 链接的定义可以放在文件中的任何一个地方,我比较偏好直接放在链接出现段落的后面,你也可以把它放在文件最后面,就像是注解一样。
623 
624 下面是一个参考式链接的范例:
625 
626 ```
627 I get 10 times more traffic from [Google] [1] than from
628 [Yahoo] [2] or [MSN] [3].
629 
630  [1]: http://google.com/       "Google"
631  [2]: http://search.yahoo.com/ "Yahoo Search"
632  [3]: http://search.msn.com/   "MSN Search"
633 
634 ```
635 
636 如果改成用链接名称的方式写:
637 
638 ```
639 I get 10 times more traffic from [Google][] than from
640 [Yahoo][] or [MSN][].
641 
642  [google]: http://google.com/       "Google"
643  [yahoo]: http://search.yahoo.com/ "Yahoo Search"
644  [msn]:   http://search.msn.com/   "MSN Search"
645 
646 ```
647 
648 上面两种写法都会产生下面的 HTML。
649 
650 ```
651 <p>I get 10 times more traffic from <a href="http://google.com/"
652 title="Google">Google</a> than from
653 <a href="http://search.yahoo.com/" title="Yahoo Search">Yahoo</a>
654 or <a href="http://search.msn.com/" title="MSN Search">MSN</a>.</p>
655 
656 ```
657 
658 下面是用行内式写的同样一段内容的 Markdown 文件,提供作为比较之用:
659 
660 ```
661 I get 10 times more traffic from [Google](http://google.com/ "Google")
662 than from [Yahoo](http://search.yahoo.com/ "Yahoo Search") or
663 [MSN](http://search.msn.com/ "MSN Search").
664 
665 ```
666 
667 参考式的链接其实重点不在于它比较好写,而是它比较好读,比较一下上面的范例,使用参考式的文章本身只有 81 个字符,但是用行内形式的却会增加到 176 个字元,如果是用纯 HTML 格式来写,会有 234 个字元,在 HTML 格式中,标签比文本还要多。
668 
669 使用 Markdown 的参考式链接,可以让文件更像是浏览器最后产生的结果,让你可以把一些标记相关的元数据移到段落文字之外,你就可以增加链接而不让文章的阅读感觉被打断。
670 
671 ### 强调
672 
673 Markdown 使用星号(`*`)和底线(`_`)作为标记强调字词的符号,被 `*` 或 `_` 包围的字词会被转成用 `<em>` 标签包围,用两个 `*` 或 `_` 包起来的话,则会被转成 `<strong>`,例如:
674 
675 ```
676 *single asterisks*
677 
678 _single underscores_
679 
680 **double asterisks**
681 
682 __double underscores__
683 
684 ```
685 
686 会转成:
687 
688 ```
689 <em>single asterisks</em>
690 
691 <em>single underscores</em>
692 
693 <strong>double asterisks</strong>
694 
695 <strong>double underscores</strong>
696 
697 ```
698 
699 你可以随便用你喜欢的样式,唯一的限制是,你用什么符号开启标签,就要用什么符号结束。
700 
701 强调也可以直接插在文字中间:
702 
703 ```
704 un*frigging*believable
705 
706 ```
707 
708 但是**如果你的 `*` 和 `_` 两边都有空白的话,它们就只会被当成普通的符号**。
709 
710 如果要在文字前后直接插入普通的星号或底线,你可以用反斜线:
711 
712 ```
713 .this text is surrounded by literal asterisks.
714 
715 ```
716 
717 ### 代码
718 
719 如果要标记一小段行内代码,你可以用反引号把它包起来(```),例如:
720 
721 ```
722 Use the `printf()` function.
723 
724 ```
725 
726 会产生:
727 
728 ```
729 <p>Use the <code>printf()</code> function.</p>
730 
731 ```
732 
733 如果要在代码区段内插入反引号,你可以用多个反引号来开启和结束代码区段:
734 
735 ```
736 ``There is a literal backtick (`) here.``
737 
738 ```
739 
740 这段语法会产生:
741 
742 ```
743 <p><code>There is a literal backtick (`) here.</code></p>
744 
745 ```
746 
747 代码区段的起始和结束端都可以放入一个空白,起始端后面一个,结束端前面一个,这样你就可以在区段的一开始就插入反引号:
748 
749 ```
750 A single backtick in a code span: `` ` ``
751 
752 A backtick-delimited string in a code span: `` `foo` ``
753 
754 ```
755 
756 会产生:
757 
758 ```
759 <p>A single backtick in a code span: <code>`</code></p>
760 
761 <p>A backtick-delimited string in a code span: <code>`foo`</code></p>
762 
763 ```
764 
765 在代码区段内,`&` 和尖括号**都**会被自动地转成 HTML 实体,这使得插入 HTML 原始码变得很容易,Markdown 会把下面这段:
766 
767 ```
768 Please don't use any `<blink>` tags.
769 
770 ```
771 
772 转为:
773 
774 ```
775 <p>Please don't use any <code>&lt;blink&gt;</code> tags.</p>
776 
777 ```
778 
779 你也可以这样写:
780 
781 ```
782 `&#8212;` is the decimal-encoded equivalent of `&mdash;`.
783 
784 ```
785 
786 以产生:
787 
788 ```
789 <p><code>&amp;#8212;</code> is the decimal-encoded
790 equivalent of <code>&amp;mdash;</code>.</p>
791 
792 ```
793 
794 ### 图片
795 
796 很明显地,要在纯文字应用中设计一个「自然」的语法来插入图片是有一定难度的。
797 
798 Markdown 使用一种和链接很相似的语法来标记图片,同样也允许两种样式: *行内式*和*参考式*。
799 
800 行内式的图片语法看起来像是:
801 
802 ```
803 ![Alt text](/path/to/img.jpg)
804 
805 ![Alt text](/path/to/img.jpg "Optional title")
806 
807 ```
808 
809 详细叙述如下:
810 
811 -  一个惊叹号 `!`
812 -  接着一个方括号,里面放上图片的替代文字
813 -  接着一个普通括号,里面放上图片的网址,最后还可以用引号包住并加上 选择性的 'title' 文字。
814 
815 参考式的图片语法则长得像这样:
816 
817 ```
818 ![Alt text][id]
819 
820 ```
821 
822 「id」是图片参考的名称,图片参考的定义方式则和连结参考一样:
823 
824 ```
825 [id]: url/to/image "Optional title attribute"
826 
827 ```
828 
829 到目前为止, Markdown 还没有办法指定图片的宽高,如果你需要的话,你可以使用普通的 `<img>` 标签。
830 
831 * * * * *
832 
833 ## 其它
834 
835 ### 自动链接
836 
837 Markdown 支持以比较简短的自动链接形式来处理网址和电子邮件信箱,只要是用尖括号包起来, Markdown 就会自动把它转成链接。一般网址的链接文字就和链接地址一样,例如:
838 
839 ```
840 <http://example.com/>
841 
842 ```
843 
844 Markdown 会转为:
845 
846 ```
847 <a href="http://example.com/">http://example.com/</a>
848 
849 ```
850 
851 邮址的自动链接也很类似,只是 Markdown 会先做一个编码转换的过程,把文字字符转成 16 进位码的 HTML 实体,这样的格式可以糊弄一些不好的邮址收集机器人,例如:
852 
853 ```
854 <address@example.com>
855 
856 ```
857 
858 Markdown 会转成:
859 
860 ```
861 <a href="&#x6D;&#x61;i&#x6C;&#x74;&#x6F;:&#x61;&#x64;&#x64;&#x72;&#x65;
862 &#115;&#115;&#64;&#101;&#120;&#x61;&#109;&#x70;&#x6C;e&#x2E;&#99;&#111;
863 &#109;">&#x61;&#x64;&#x64;&#x72;&#x65;&#115;&#115;&#64;&#101;&#120;&#x61;
864 &#109;&#x70;&#x6C;e&#x2E;&#99;&#111;&#109;</a>
865 
866 ```
867 
868 在浏览器里面,这段字串(其实是 `<a href="mailto:address@example.com">address@example.com</a>`)会变成一个可以点击的「<address@example.com>」链接。
869 
870 (这种作法虽然可以糊弄不少的机器人,但并不能全部挡下来,不过总比什么都不做好些。不管怎样,公开你的信箱终究会引来广告信件的。)
871 
872 ### 反斜杠
873 
874 Markdown 可以利用反斜杠来插入一些在语法中有其它意义的符号,例如:如果你想要用星号加在文字旁边的方式来做出强调效果(但不用 `<em>` 标签),你可以在星号的前面加上反斜杠:
875 
876 ```
877 .literal asterisks.
878 
879 ```
880 
881 Markdown 支持以下这些符号前面加上反斜杠来帮助插入普通的符号:
882 
883 ```
884 . 反斜线
885 `  反引号
886 *  星号
887 _  底线
888 {} 花括号
889 [] 方括号
890 () 括弧
891 #  井字号
892 +  加号
893 -  减号
894 .  英文句点
895 !  惊叹号
896 ```
 47```
 48**效果演示:**
 49
 50This is an H1
 51=============
 52
 53This is an H2
 54
 55-------------
 56
 57### 字符效果和横线等
 58
 59----
 60
 61~~删除线~~ <s>删除线(开启识别HTML标签时)</s> `~~删除线~~ <s>删除线(开启识别HTML标签时)</s>`
 62
 63*斜体字*      _斜体字_ `*斜体字*      _斜体字_`
 64
 65**粗体**  __粗体__ `**粗体**  __粗体__`
 66
 67***粗斜体*** ___粗斜体___ `***粗斜体*** ___粗斜体___`
 68
 69上标:X<sub>2</sub>,下标:O<sup>2</sup> `上标:X<sub>2</sub>,下标:O<sup>2</sup>`
 70
 71**缩写(同HTML的abbr标签)**
 72```
 73> 即更长的单词或短语的缩写形式,前提是开启识别HTML标签时,已默认开启
 74```
 75> 即更长的单词或短语的缩写形式,前提是开启识别HTML标签时,已默认开启
 76
 77```
 78The <abbr title="Hyper Text Markup Language">HTML</abbr> specification is maintained by the <abbr title="World Wide Web Consortium">W3C</abbr>.
 79```
 80The <abbr title="Hyper Text Markup Language">HTML</abbr> specification is maintained by the <abbr title="World Wide Web Consortium">W3C</abbr>.
 81
 82### 引用 Blockquotes
 83```
 84> 引用文本 Blockquotes
 85```
 86**效果演示:**
 87> 引用文本 Blockquotes
 88
 89引用的行内混合 Blockquotes
 90```
 91> 引用:如果想要插入空白换行`即<br />标签`,在插入处先键入两个以上的空格然后回车即可,[普通链接](http://localhost/)。
 92```
 93**效果演示:**
 94> 引用:如果想要插入空白换行`即<br />标签`,在插入处先键入两个以上的空格然后回车即可,[普通链接](http://localhost/)。
 95
 96### 锚点与链接 Links
 97
 98[普通链接](http://localhost/) `[普通链接](http://localhost/)`
 99
 100[普通链接带标题](http://localhost/ "普通链接带标题") `[普通链接带标题](http://localhost/ "普通链接带标题")`
 101
 102直接链接:<https://github.com> `<https://github.com>`
 103
 104[锚点链接][anchor-id]  `[锚点链接][anchor-id] `
 105
 106[anchor-id]: http://www.this-anchor-link.com/
 107
 108GFM a-tail link @pandao
 109
 110> @pandao
 111
 112### 多语言代码高亮 Codes
 113
 114#### 行内代码 Inline code
 115```
 116执行命令:`npm install marked`
 117```
 118执行命令:`npm install marked`
 119
 120#### 缩进风格
 121
 122即缩进四个空格,也做为实现类似`<pre>`预格式化文本(Preformatted Text)的功能。
 123也就是说可以不用` ``` ``` `或者` `` `来格式化代码可以对代码进行table(四格缩进)同样可以又格式化代码的作用:
 124
 125**我按照短横`-`来表示一个空格:**
 126例子:
 127```
 128----<?php
 129----    echo "Hello world!";
 130----?>
 131```
 132    <?php
 133
 134        echo "Hello world!";
 135
 136    ?>
 137
 138
 139#### JS代码 
 140```
 141```javascript 代码
 142```
 143```javascript
 144function test(){
 145
 146    console.log("Hello world!");
 147
 148}
 149```
 150
 151#### HTML代码 HTML codes
 152
 153```html
 154
 155<!DOCTYPE html>
 156
 157<html>
 158
 159    <head>
 160
 161        <mate charest="utf-8" />
 162
 163        <title>Hello world!</title>
 164
 165    </head>
 166
 167    <body>
 168
 169        <h1>Hello world!</h1>
 170
 171    </body>
 172
 173</html>
 174
 175```
 176
 177### 图片 Images
 178
 179Image:
 180```
 181![](https://cdn.learnku.com/uploads/images/201903/04/32489/SzyzqNHEu9.jpeg!large)
 182```
 183![](https://cdn.learnku.com/uploads/images/201903/04/32489/SzyzqNHEu9.jpeg!large)
 184
 185> 图为:厦门白城沙滩
 186
 187图片加链接 (Image + Link):
 188```
 189[![]https://cdn.learnku.com/uploads/images/201806/21/1/gH3fzveyW3.jpg!/both/400x400)](https://learnku.com/python)
 190```
 191[![](https://cdn.learnku.com//uploads/communities/mTBLIP7o0gVGn3ZCphpN.png!/both/44x44)](https://learnku.com/python)
 192
 193> 图为:https://learnku.com/python logo
 194
 195----
 196
 197### 列表 Lists
 198
 199#### 无序列表(减号)Unordered Lists (-)
 200```
 201- 列表一
 202
 203- 列表二
 204
 205- 列表三
 206```
 207- 列表一
 208
 209- 列表二
 210
 211- 列表三
 212
 213#### 无序列表(星号)Unordered Lists (*)
 214
 215* 列表一
 216
 217* 列表二
 218
 219* 列表三
 220
 221#### 无序列表(加号和嵌套)Unordered Lists (+)
 222```
 223+ 列表一
 224
 225+ 列表二
 226
 227    + 列表二-1
 228
 229    + 列表二-2
 230
 231    + 列表二-3
 232
 233+ 列表三
 234
 235    * 列表一
 236
 237    * 列表二
 238
 239    * 列表三
 240```
 241+ 列表一
 242
 243+ 列表二
 244
 245    + 列表二-1
 246
 247    + 列表二-2
 248
 249    + 列表二-3
 250
 251+ 列表三
 252
 253    * 列表一
 254
 255    * 列表二
 256
 257    * 列表三
 258
 259#### 有序列表 Ordered Lists (-)
 260```
 2611. 第一行
 262
 2632. 第二行
 264
 2653. 第三行
 266```
 2671. 第一行
 268
 2692. 第二行
 270
 2713. 第三行
 272
 273#### GFM task list
 274```
 275- [x] GFM task list 1
 276
 277- [x] GFM task list 2
 278
 279- [ ] GFM task list 3
 280
 281    - [ ] GFM task list 3-1
 282
 283    - [ ] GFM task list 3-2
 284
 285    - [ ] GFM task list 3-3
 286
 287- [ ] GFM task list 4
 288
 289    - [ ] GFM task list 4-1
 290
 291    - [ ] GFM task list 4-2
 292```
 293- [x] GFM task list 1
 294
 295- [x] GFM task list 2
 296
 297- [ ] GFM task list 3
 298
 299    - [ ] GFM task list 3-1
 300
 301    - [ ] GFM task list 3-2
 302
 303    - [ ] GFM task list 3-3
 304
 305- [ ] GFM task list 4
 306
 307    - [ ] GFM task list 4-1
 308
 309    - [ ] GFM task list 4-2
 310
 311----
 312
 313### 绘制表格 Tables
 314```
 315| 项目        | 价格   |  数量  |
 316| --------   | -----:  | :----:  |
 317| 计算机      | $1600   |   5     |
 318| 手机        |   $12   |   12   |
 319| 管线        |    $1    |  234  |
 320
 321```
 322| 项目        | 价格   |  数量  |
 323| --------   | -----:  | :----:  |
 324| 计算机      | $1600   |   5     |
 325| 手机        |   $12   |   12   |
 326| 管线        |    $1    |  234  |
 327
 328```
 329First Header  | Second Header
 330------------- | -------------
 331Content Cell  | Content Cell
 332Content Cell  | Content Cell 
 333```
 334First Header  | Second Header
 335------------- | -------------
 336Content Cell  | Content Cell
 337Content Cell  | Content Cell 
 338
 339```
 340| First Header  | Second Header |
 341| ------------- | ------------- |
 342| Content Cell  | Content Cell  |
 343| Content Cell  | Content Cell  |
 344
 345```
 346
 347| First Header  | Second Header |
 348| ------------- | ------------- |
 349| Content Cell  | Content Cell  |
 350| Content Cell  | Content Cell  |
 351
 352```
 353| Function name | Description                    |
 354| ------------- | ------------------------------ |
 355| `help()`      | Display the help window.       |
 356| `destroy()`   | **Destroy your computer!**     |
 357| Left-Aligned  | Center Aligned  | Right Aligned |
 358```
 359| Function name | Description                    |
 360| ------------- | ------------------------------ |
 361| `help()`      | Display the help window.       |
 362| `destroy()`   | **Destroy your computer!**     |
 363
 364```
 365| Left-Aligned  | Center Aligned  | Right Aligned |
 366| :------------ |:---------------:| -----:|
 367| col 3 is      | some wordy text | $1600 |
 368| col 2 is      | centered        |   $12 |
 369| zebra stripes | are neat        |    $1 |
 370```
 371| Left-Aligned  | Center Aligned  | Right Aligned |
 372| :------------ |:---------------:| -----:|
 373| col 3 is      | some wordy text | $1600 |
 374| col 2 is      | centered        |   $12 |
 375| zebra stripes | are neat        |    $1 |
 376
 377```
 378| Item      | Value |
 379| --------- | -----: |
 380| Computer  | $1600 |
 381| Phone     |   $12 |
 382| Pipe      |    $1 |
 383```
 384| Item      | Value |
 385| --------- | -----: |
 386| Computer  | $1600 |
 387| Phone     |   $12 |
 388| Pipe      |    $1 |
 389
 390----
 391
 392#### 特殊符号 HTML Entities Codes
 393
 394&copy; &  &uml; &trade; &iexcl; &pound;
 395
 396&amp; &lt; &gt; &yen; &euro; &reg; &plusmn; &para; &sect; &brvbar; &macr; &laquo; &middot; 
 397
 398X&sup2; Y&sup3; &frac34; &frac14;  &times;  &divide;   &raquo;
 399
 40018&ordm;C  &quot;  &apos;
 401
 402&copy; &  &uml; &trade; &iexcl; &pound;
 403
 404&amp; &lt; &gt; &yen; &euro; &reg; &plusmn; &para; &sect; &brvbar; &macr; &laquo; &middot; 
 405
 406X&sup2; Y&sup3; &frac34; &frac14;  &times;  &divide;   &raquo;
 407
 40818&ordm;C  &quot;  &apos;
 409
 410### Emoji表情 :smiley:
 411
 412```
 413> Blockquotes \:star\:
 414```
 415> Blockquotes :star:
 416
 417### End