Markdown 子列表位于项目符号点的中间而不是末尾
Markdown sublist in the middle of, rather than the end of, a bullet point
以下 HTML 的 Markdown 等价物是什么?
<ul><li>Here is a bullet point</li>
<li>Here is another bullet point; it has sub-points:
<ul><li>subpoint 1</li>
<li>subpoint 2</li>
<li>subpoint 3</li></ul>
but then continues with the original bullet point</li>
<li>and here's one more point just to drive it home</li>
</ul>
我似乎无法让“...但随后继续...”位保留在封装子列表的同一个要点中。我已经尝试了几种变体:
* Here is a bullet point
* Here is another bullet point; it has sub-points:
* subpoint 1
* subpoint 2
* subpoint 3
but then continues with the original bullet point
* and here's one more point just to drive it home
“but then
”具有不同的缩进级别,但无论它是与“subpoint 3
”连接还是成为项目符号下的另一个子缩进。特定行为也因我使用的 Markdown 风格而异。
这是否太复杂而无法封装在 Markdown 中,在这种情况下我应该只使用内联 HTML 来代替吗?
你需要包含一些空行来告诉 Markdown 什么时候开始列表,什么时候结束列表,什么时候开始一个段落(不在列表中)等等...
* Here is a bullet point
* Here is another bullet point; it has sub-points:
* subpoint 1
* subpoint 2
* subpoint 3
but then continues with the original bullet point
* and here's one more point just to drive it home
呈现为:
<ul>
<li>Here is a bullet point</li>
<li>
<p>Here is another bullet point; it has sub-points:</p>
<ul>
<li>subpoint 1</li>
<li>subpoint 2</li>
<li>subpoint 3</li>
</ul>
<p>but then continues with the original bullet point</p>
</li>
<li>
<p>and here's one more point just to drive it home</p>
</li>
</ul>
关键是要将嵌套在列表项中的所有内容视为其自己的独立 Markdown 文档,该文档从文档的其余部分缩进四个空格。在这种情况下,您需要在最后一个列表项和后面的段落之间添加一个空行,因此您也可以在此处这样做。
需要注意的一件事是,此生成的输出包括您现在拥有的 "lazy list" 的 side-effect。也就是说,列表项的内容现在包含在 <p>
标记中。这在 rules:
中严格执行
If list items are separated by blank lines, Markdown will wrap the items in <p>
tags in the HTML output.
如果您不想要额外的 <p>
标签,那么在一个列表项中嵌套的块级元素不能超过一个。
最后,我会注意到在上面的示例中,第一个列表项没有获得 <p>
标记。虽然在规则中没有以某种方式记录,但这是原始参考实现的行为(仅列出与空行相邻的项目(空行前后的项目)获得 <p>
标记)。虽然一些实现复制了这种行为,但并非所有实现都复制了这种行为,并且它们之间存在各种不同的边缘情况。为了实现跨实施的一致性,如果我需要在列表中的任何位置使用空行,我发现在每个列表项之间包含一个空行是一个很好的做法。因此我会这样做:
* Here is a bullet point
* Here is another bullet point; it has sub-points:
* subpoint 1
* subpoint 2
* subpoint 3
but then continues with the original bullet point
* and here's one more point just to drive it home
哪个应该更一致地呈现为:
<ul>
<li>
<p>Here is a bullet point</p>
</li>
<li>
<p>Here is another bullet point; it has sub-points:</p>
<ul>
<li>subpoint 1</li>
<li>subpoint 2</li>
<li>subpoint 3</li>
</ul>
<p>but then continues with the original bullet point</p>
</li>
<li>
<p>and here's one more point just to drive it home</p>
</li>
</ul>
以下 HTML 的 Markdown 等价物是什么?
<ul><li>Here is a bullet point</li>
<li>Here is another bullet point; it has sub-points:
<ul><li>subpoint 1</li>
<li>subpoint 2</li>
<li>subpoint 3</li></ul>
but then continues with the original bullet point</li>
<li>and here's one more point just to drive it home</li>
</ul>
我似乎无法让“...但随后继续...”位保留在封装子列表的同一个要点中。我已经尝试了几种变体:
* Here is a bullet point
* Here is another bullet point; it has sub-points:
* subpoint 1
* subpoint 2
* subpoint 3
but then continues with the original bullet point
* and here's one more point just to drive it home
“but then
”具有不同的缩进级别,但无论它是与“subpoint 3
”连接还是成为项目符号下的另一个子缩进。特定行为也因我使用的 Markdown 风格而异。
这是否太复杂而无法封装在 Markdown 中,在这种情况下我应该只使用内联 HTML 来代替吗?
你需要包含一些空行来告诉 Markdown 什么时候开始列表,什么时候结束列表,什么时候开始一个段落(不在列表中)等等...
* Here is a bullet point
* Here is another bullet point; it has sub-points:
* subpoint 1
* subpoint 2
* subpoint 3
but then continues with the original bullet point
* and here's one more point just to drive it home
呈现为:
<ul>
<li>Here is a bullet point</li>
<li>
<p>Here is another bullet point; it has sub-points:</p>
<ul>
<li>subpoint 1</li>
<li>subpoint 2</li>
<li>subpoint 3</li>
</ul>
<p>but then continues with the original bullet point</p>
</li>
<li>
<p>and here's one more point just to drive it home</p>
</li>
</ul>
关键是要将嵌套在列表项中的所有内容视为其自己的独立 Markdown 文档,该文档从文档的其余部分缩进四个空格。在这种情况下,您需要在最后一个列表项和后面的段落之间添加一个空行,因此您也可以在此处这样做。
需要注意的一件事是,此生成的输出包括您现在拥有的 "lazy list" 的 side-effect。也就是说,列表项的内容现在包含在 <p>
标记中。这在 rules:
If list items are separated by blank lines, Markdown will wrap the items in
<p>
tags in the HTML output.
如果您不想要额外的 <p>
标签,那么在一个列表项中嵌套的块级元素不能超过一个。
最后,我会注意到在上面的示例中,第一个列表项没有获得 <p>
标记。虽然在规则中没有以某种方式记录,但这是原始参考实现的行为(仅列出与空行相邻的项目(空行前后的项目)获得 <p>
标记)。虽然一些实现复制了这种行为,但并非所有实现都复制了这种行为,并且它们之间存在各种不同的边缘情况。为了实现跨实施的一致性,如果我需要在列表中的任何位置使用空行,我发现在每个列表项之间包含一个空行是一个很好的做法。因此我会这样做:
* Here is a bullet point
* Here is another bullet point; it has sub-points:
* subpoint 1
* subpoint 2
* subpoint 3
but then continues with the original bullet point
* and here's one more point just to drive it home
哪个应该更一致地呈现为:
<ul>
<li>
<p>Here is a bullet point</p>
</li>
<li>
<p>Here is another bullet point; it has sub-points:</p>
<ul>
<li>subpoint 1</li>
<li>subpoint 2</li>
<li>subpoint 3</li>
</ul>
<p>but then continues with the original bullet point</p>
</li>
<li>
<p>and here's one more point just to drive it home</p>
</li>
</ul>