Search code examples
listpython-sphinxrestructuredtext

RestructuredText lists wrap unexpectedly


I'm trying to make lists in Sphinx. However, they end up broken like so here: where the input code is: broken list

#. Set the :guilabel:`Output extent [optional] to
   :menuselection:`... --> Calculate from Layer --> Reprojected`
#. for :guilabel:`Cellsize` enter :file:`1970`

However, on other occasions it just works normally. Just to be sure:

This is unrelated text that needs a full line after

#. Then now we start a numbered list
#. If you have a line that is really long and
   needs to be split over different lines, you
   can do that by indenting
#. You can also have different paragraphs

   like this inside a list. Be aware that it should be 
   indented and there should be a whitespace after

#. Then this item will render correctly

An unindented paragraph will re-set the list

#. this item starts at 1 again

It seems really random to me. Maybe something with the type of line ending (CRLF/LF) number of spaces in indents?


Solution

  • It turns out to be the number of spaces. Very confusingly, this is also different for a numbered (3: #. /1. ) or bullet (2:* ) list. For example this is correct:

    This is unrelated text that needs a full line after
    
    #. Then now we start a numbered list
    #. If you have a line that is really long and
       needs to be split over different lines, you
       can do that by indenting
    #. You can also have different paragraphs
    
       like this inside a list. Be aware that it should be 
       indented and there should be a whitespace after
    
       * You need whitespace for a bulletlist
       * and then if you have a really long item, that
         is split along multiple lines, make sure that in 
         this case you have 2 (two) spaces
    
       #. But, then again if you would have a numbered list
          that is split over multiple lines, you need to enter
          3 (three) spaces.
       #. and it continues to the next point
       #. but this is confusing
       #. also logical in another way
    
    #. Then this item will render correctly
    
    an unindented parargaph in between will terminate the list
    

    This finally renders correctly:

    success!