考虑ReStructuredText中的以下列表:
Broken list example
-------------------
#. First do spam
#. Then do ``eggs``
.. note::
Nobody expects the Spanish Inquisistion
#. The list restarts after the note
在Sphinx中编译列表时,注释后面的数字将重置为
1
:知道如何在
note
部分后继续编号列表吗?
最佳答案
列表的不连续性是由于note
是一个独立元素,而不是第二个编号列表元素的子元素。为防止列表不连续,请在与预期父编号列表元素的文本相同的缩进处(本例中为3个空格)开始note
指令。因此,请尝试执行以下操作,而不是使用示例reStructuredText:
Fixed list example
------------------
#. First do spam
#. Then do ``eggs``
.. note::
Nobody expects the Spanish Inquisistion
#. Then do spam and ``eggs``.
这是关于reStructuredText的事情之一,既不容易发现,也没有特别好的文档记录;参见this question on nested lists for a closely-related problem。
关于python-sphinx - Sphinx:在笔记部分之后恢复列表编号,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29354305/