kramdown 中的三级嵌套列表

Three-level nested list in kramdown

我一直在尝试创建一个如下所示的嵌套列表(使用 kramdown,用于 GitHub 页面),但是 HTML 输出不是语义的;二级列表使用段落代替列表元素,三级列表项使用代码块。

1. Do something.

2. Do something else.

    a. If the reverse-Pi separation gauge is set to `OFF` you can follow
       the following procedure.

        i. Use the flux capacitor on Mondays, Tuesdays and Thursdays, but
           only if you have not done so already.

        ii. Do not use the flux capacitor if it's raining, because the
            universe will implode.

    b. If the reverse-Pi separation gauge is set to `ON` then you
       should follow Procedure 42.

3. Go back to doing things.

上面的结果如下 HTML...

<ol>
  <li>
    <p>Do something.</p>
  </li>
  <li>
    <p>Do something else.</p>

    <p>a. If the reverse-Pi separation gauge is set to <code>OFF</code> you can follow
    the following procedure.</p>

    <pre><code> i. Use the flux capacitor on Mondays, Tuesdays and Thursdays, but
    only if you have not done so already.

 ii. Do not use the flux capacitor if it's raining, because the
     universe will implode.
</code></pre>

    <p>b. If the reverse-Pi separation gauge is set to <code>ON</code> then you
    should follow Procedure 42.</p>
  </li>
  <li>
    <p>Go back to doing things.</p>
  </li>
</ol>

我试过更改缩进,甚至删除项目之间的空行,但无法使其按预期运行。

将所有列表 'bullets' 替换为 1. 而不是它们的实际数字确实会生成结构正确的 HTML(感谢 Scroog1 for that suggestion offline); then one can use CSS to make the output HTML lists have the desired list-style-type. However, this feels contrary to Markdown's "it should be readable as plain text" philosophy,所以我想知道是否有任何方法可以使它 在降价版本中看起来像预期的那样?

(我想有人会争辩说,在这种特殊情况下,HTML 是我的文档中人们会阅读的唯一格式,最好让机器进行编号,而且更清晰使用 CSS 而不是降价处理器生成的内联样式来实现所需的列表格式,但我很好奇上面的失败是否可能是我误用,或者可能是 kramdown 中的错误或设计决定.)

Kramdown documentation 除了数字 1,2,3....

没有显示任何支持有序列表的例子

它使用第一个列表指示符的值来确定列表是有序的还是无序的,您可以应用样式 class 与列表内联,如下所示:

1. {:.cls} This item has the class "cls".
2. {:.cls} This item also as the class "cls".

这仍然大部分是明文可读的,并且将使您的 CSS 更易于管理(数字 2-x 上的样式 class 可能不是必需的,我从未尝试过) .

将它们全部设为有序列表

1. Do something.

2. Do something else.

    1. If the reverse-Pi separation gauge is set to `OFF` you can follow
       the following procedure.

        1. Use the flux capacitor on Mondays, Tuesdays and Thursdays, but
           only if you have not done so already.

        2. Do not use the flux capacitor if it's raining, because the
            universe will implode.

    2 If the reverse-Pi separation gauge is set to `ON` then you
       should follow Procedure 42.

3. Go back to doing things.

然后应用样式

li li{
    list-style-type: lower-alpha;
}

li li li{
    list-style-type: lower-roman;
}

MDN on CSS