我一直在尝试创建一个如下所示的嵌套列表(使用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>
我尝试更改缩进甚至删除项目之间的空白行,但无法使其按预期运行。
更换所有列表&#39;子弹&#39;使用1.
而非实际数字确实会生成正确结构化的HTML(感谢Scroog1离线提供的建议);然后可以使用CSS使输出HTML列表具有所需的list-style-type
。但是,这感觉与Markdown的"it should be readable as plain text" philosophy相反,所以我想知道是否有任何方法可以使它和在降价版本中看起来像预期一样?
(我想可以说,在这种特殊情况下,HTML是人们阅读的文档的唯一格式,让机器进行编号会更好,而且它的编号也是如此。更清洁地使用CSS而不是由降价处理器生成的内联样式来实现所需的列表格式,但我很好奇上面的失败可能是我的误用,也可能是错误或设计决定,kramdown 。)
答案 0 :(得分:3)
将它们全部列入有序列表
assert()
然后应用样式
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.
请参阅MDN on CSS
答案 1 :(得分:0)
Kramdown documentation没有显示支持除数字1,2,3 ......之外的有序列表的任何示例。
它使用第一个列表指示符的值来确定列表是有序还是无序,并且您可以将样式类与列表一起内联应用:
1. {:.cls} This item has the class "cls".
2. {:.cls} This item also as the class "cls".
这仍然可以作为明文阅读,并且可以使您的CSS更易于管理(数字2-x上的样式类可能没有必要,我从未尝试过这样做。)