You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

GitHub Flavored Markdown同一列表项嵌套多个独立无序列表的写法

要实现你需要的嵌套列表效果,只需要调整缩进规则即可:
GitHub Flavored Markdown 规定,所有归属到同一个父列表项的内容(子列表、段落、代码块等),都需要和该父列表项的第一个文本字符保持相同的缩进量,推荐统一给嵌套内容加4个空格的缩进,兼容性最强。

你之前的写法有两个问题:

  1. 第三个父列表项This is a third list item多了前置缩进,被识别成了第二个列表项的附属内容
  2. 嵌套内容的缩进可以统一对齐,避免解析异常

正确的Markdown写法如下:

- This is a list item
- This is also a list item
    - ...containing a sublist
    - with two items.

    and then...

    - another sublist
    - which also has two items
- This is a third list item

上述写法在GitHub中渲染后,and then...会被识别为第二个列表项内部的普通段落,前后两个子列表都会归属到第二个父列表项下,最终效果和你给出的HTML完全一致。

内容的提问来源于stack exchange,提问作者Rounin

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.09.25 06:06:03