How to create a nested list in reStructuredText?

眉间皱痕 提交于 2019-12-31 10:57:46

问题


I am trying to create a properly nested list using the following code (following Sphinx and docutils docs):

1. X

  a. U
  b. V
  c. W

2. Y
3. Z

I expect this to result in two OLs but I get the following output instead:

<ol class="arabic simple"> 
  <li>X</li> 
</ol> 

<blockquote> 
  <div>
    <ol class="loweralpha simple"> 
      <li>U</li> 
      <li>V</li> 
      <li>W</li> 
    </ol> 
  </div>
</blockquote> 

<ol class="arabic simple" start="2"> 
  <li>Y</li> 
  <li>Z</li> 
</ol> 

What am I doing wrong? Is it not possible to get the following result?

<ol class="arabic simple"> 
  <li>X
    <ol class="loweralpha simple"> 
      <li>U</li> 
      <li>V</li> 
      <li>W</li> 
    </ol> 
  </li>
  <li>Y</li> 
  <li>Z</li> 
</ol> 

回答1:


Make sure the nested list is indented to the same level as the text of the parent list (or three characters, whichever is greater), like this:

1. X

   a. U
   b. V
   c. W

2. Y
3. Z

Then you'll get the output you expected.




回答2:


If you want Sphinx to take care of the numbering for you, do this.

#. X
#. Y

   #. u 
   #. v 

#. Z


来源:https://stackoverflow.com/questions/5550089/how-to-create-a-nested-list-in-restructuredtext

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!