列表
列表分为 有序列表 与 无序列表 ,在 Markdown 下:
无序列表需要在文字前加上“星号“、”加号“、”减号“
+
或
-
或
*
* Red
* Green
* Blue
等同于:
+ Red
+ Green
+ Blue
也等同于:
- Red
- Green
- Blue
有序列表则直接在文字前加
1.
2.
3.
列表项目标记通常是放在最左边,但是其实也可以缩进,最多 3 个空格,项目标记后面则一定要接着至少一个空格或制表符。
列表项目可以包含多个段落,每个项目下的段落都必须缩进 4 个空格或是 1 个制表符:
1. This is a list item with two paragraphs. Lorem ipsum dolor
sit amet, consectetuer adipiscing elit. Aliquam hendrerit
mi posuere lectus.
Vestibulum enim wisi, viverra nec, fringilla in, laoreet
vitae, risus. Donec sit amet nisl. Aliquam semper ipsum
sit amet velit.
2. Suspendisse id sem consectetuer libero luctus adipiscing.
如果你每行都有缩进,看起来会看好很多,当然,再次地,如果你很懒惰,Markdown 也允许:
* This is a list item with two paragraphs.
This is the second paragraph in the list item. You're
only required to indent the first line. Lorem ipsum dolor
sit amet, consectetuer adipiscing elit.
* Another item in the same list.
如果要在列表项目内放进引用,那>
就需要缩进:
* A list item with a blockquote:
> This is a blockquote
> inside a list item.
- A list item with a blockquote:
This is a blockquote
inside a list item
如果要放代码区块的话,该区块就需要缩进两次,也就是 8 个空格或是 2 个制表符:
* 列表项包含一个列表区块:
<代码写在这>
- 列表项包含一个列表区块:
代码写在这
当然,项目列表很可能会不小心产生,像是下面这样的写法:
1986. What a great season.
换句话说,也就是在行首出现数字-句点-空白,要避免这样的状况,你可以在句点前面加上反斜杠。
1986\. What a great season.
如果列表项目间用空行分开,在输出 HTML 时 Markdown 就会将项目内容用<p>
标签包起来,举例来说:
* Bird
* Magic
会被转换为:
<ul>
<li>Bird</li>
<li>Magic</li>
</ul>
但是这个:
* Bird
* Magic
会被转换为:
<ul>
<li><p>Bird</p></li>
<li><p>Magic</p></li>
</ul>