Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
423 views
in Technique[技术] by (71.8m points)

restructuredtext - Sphinx: Resume list numbering after a note section

Consider the following list in ReStructuredText:

Broken list example
-------------------

#. First do spam
#. Then do ``eggs``

  .. note::

    Nobody expects the Spanish Inquisistion

#. The list restarts after the note

When the list is compiled in Sphinx, the number after the note are reset to 1:

List number restart result screenshot

Any idea how to continue the numbered list after a note section?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

The discontinuity of the list is caused by the note being a standalone element, not a child of the second numbered list element. To prevent the discontinuity of the list, start the note directive at the same indentation (in this case, 3 spaces) as the the text of the intended parent numbered list element. So instead of your sample reStructuredText, try this:

Fixed list example
------------------

#. First do spam
#. Then do ``eggs``

   .. note::

      Nobody expects the Spanish Inquisistion

#. Then do spam and ``eggs``.

This is one of those things about reStructuredText that's neither easy to spot, nor particularly well documented; see this question on nested lists for a closely-related problem.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...