Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create a nested list in reStructuredText?

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>  
like image 719
muhuk Avatar asked Apr 05 '11 09:04

muhuk


People also ask

How do I create a nested list in markdown?

To nest one list within another, indent each item in the sublist by four spaces. You can also nest other elements like paragraphs, blockquotes or code blocks. You can mix ordered and unordered lists. To nest a paragraph or blockquote, indent by either 4 spaces or one tab.

What is nested list with example?

A nested list is a list that appears as an element in another list. In this list, the element with index 3 is a nested list. If we print( nested[3] ), we get [10, 20] .

Can lists be nested?

Theoretically you can nest as many lists as you like, although in practice it can become confusing to nest lists too deeply. For very large lists, you may be better off splitting the content up into several lists with headings instead, or even splitting it up into separate pages.


2 Answers

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.

like image 150
ddbeck Avatar answered Sep 25 '22 17:09

ddbeck


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

#. X #. Y     #. u     #. v   #. Z 
like image 26
zsoobhan Avatar answered Sep 23 '22 17:09

zsoobhan