降价反向排序列表?
Markdown reverse ordered list?
有没有办法在普通 Markdown 中显示倒序列表?
我读到了 HTML "reverse" 选项 here and here,但如果存在的话,我更喜欢 Markdown 解决方案。
澄清一下,有没有办法这样写:
0. Coffee
0. Tea
0. Milk
并将其呈现为
3. Coffee
2. Tea
1. Milk
而不是常规的
1. Coffee
2. Tea
3. Milk
documentation 状态(部分):
It’s important to note that the actual numbers you use to mark the list have no effect on the HTML output Markdown produces. ... [examples excluded for clarity and brevity] ...
The point is, if you want to, you can use ordinal numbers in your ordered Markdown lists, so that the numbers in your source match the numbers in your published HTML. But if you want to be lazy, you don’t have to.
If you do use lazy list numbering, however, you should still start the list with the number 1. At some point in the future, Markdown may support starting ordered lists at an arbitrary number.
事实上,一些实现已经开始支持 start attribute (one example);然而,这种情况很少见。即便如此,也只引用了第一项的编号。给其余项目的编号仍然被忽略。
我不知道有任何支持 reverse
属性的实现。此外,解析器将如何检测到它?解析器是否需要检查所有数字?或者只是前两个?
由于 HTML 并没有真正提供手动定义每个列表项的编号的方法,因此 Markdown 解析器没有理由关心为每个单独的项目分配了哪些编号。因此大多数(全部?)不会。
当然,Markdown 确实支持raw HTML。正如语法规则所述:
For any markup that is not covered by Markdown’s syntax, you simply use HTML itself.
因此,您可以在 Markdown 文档中以原始 HTML 手动定义列表:
A paragraph of Markdown text
<ol reversed>
<li>Coffee</li>
<li>Tea</li>
<li>Milk</li>
</ol>
More Markdown text.
为什么这是正确的做法背后的哲学是这样解释的:
Markdown is not a replacement for HTML, or even close to it. Its syntax is very small, corresponding only to a very small subset of HTML tags. The idea is not to create a syntax that makes it easier to insert HTML tags. In my opinion, HTML tags are already easy to insert.
我不知道有什么简单的 Markdown 解决方案,但是对于那些愿意考虑非常常见的 Markdown 扩展的人来说,您可以使用 kramdown 来实现。在 Kramdown 中,您可以将任何属性添加到任何 HTML 块。所以,您需要做的就是:
0. first item
0. second item
0. another item
{: reversed="reversed"}
这会将 reversed
属性添加到您的 <ol>
块中,并将产生所需的效果。
有关语法,请参阅 the kramdown documentation。
有没有办法在普通 Markdown 中显示倒序列表?
我读到了 HTML "reverse" 选项 here and here,但如果存在的话,我更喜欢 Markdown 解决方案。
澄清一下,有没有办法这样写:
0. Coffee
0. Tea
0. Milk
并将其呈现为
3. Coffee
2. Tea
1. Milk
而不是常规的
1. Coffee
2. Tea
3. Milk
documentation 状态(部分):
It’s important to note that the actual numbers you use to mark the list have no effect on the HTML output Markdown produces. ... [examples excluded for clarity and brevity] ...
The point is, if you want to, you can use ordinal numbers in your ordered Markdown lists, so that the numbers in your source match the numbers in your published HTML. But if you want to be lazy, you don’t have to.
If you do use lazy list numbering, however, you should still start the list with the number 1. At some point in the future, Markdown may support starting ordered lists at an arbitrary number.
事实上,一些实现已经开始支持 start attribute (one example);然而,这种情况很少见。即便如此,也只引用了第一项的编号。给其余项目的编号仍然被忽略。
我不知道有任何支持 reverse
属性的实现。此外,解析器将如何检测到它?解析器是否需要检查所有数字?或者只是前两个?
由于 HTML 并没有真正提供手动定义每个列表项的编号的方法,因此 Markdown 解析器没有理由关心为每个单独的项目分配了哪些编号。因此大多数(全部?)不会。
当然,Markdown 确实支持raw HTML。正如语法规则所述:
For any markup that is not covered by Markdown’s syntax, you simply use HTML itself.
因此,您可以在 Markdown 文档中以原始 HTML 手动定义列表:
A paragraph of Markdown text
<ol reversed>
<li>Coffee</li>
<li>Tea</li>
<li>Milk</li>
</ol>
More Markdown text.
为什么这是正确的做法背后的哲学是这样解释的:
Markdown is not a replacement for HTML, or even close to it. Its syntax is very small, corresponding only to a very small subset of HTML tags. The idea is not to create a syntax that makes it easier to insert HTML tags. In my opinion, HTML tags are already easy to insert.
我不知道有什么简单的 Markdown 解决方案,但是对于那些愿意考虑非常常见的 Markdown 扩展的人来说,您可以使用 kramdown 来实现。在 Kramdown 中,您可以将任何属性添加到任何 HTML 块。所以,您需要做的就是:
0. first item
0. second item
0. another item
{: reversed="reversed"}
这会将 reversed
属性添加到您的 <ol>
块中,并将产生所需的效果。
有关语法,请参阅 the kramdown documentation。