Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Nested sub-list in reStructuredText with code blocks not working

I'm using sphinx to try and create HTML documents from .rst files. I'm attempting to create a document that has a numbered list (1., 2., ...) , with a nested sub-list (a., b, c., ...) that shows example code. But I'm having trouble teasing out the syntax to get the nested sub-list to work. Here's an example .rst file of what I've tried:

===========
Tester Page
===========

Below are some test paragraphs.

1. This is a paragraph detailing a higher level step, with 3 sub-steps.
 a. This is a sub-bullet, with an example:
::

    ls -l foo.txt

 b. I can't get this line to not display as part of the code block! This is another sub-bullet, with an example:
::

    git add bar.txt

2. This is step 2.

This is the end of the document.

The above gives me a result similar to this (hard to reproduce exactly in Markdown, but hopefully you get the idea):

Tester Page

Below are some test paragraphs.

  1. This is some text.

    a. This is a sub-bullet, with an example:

  ls -l foo.txt

b. This is another sub-bullet, with an example:
  git add bar.txt
  1. This is step 2.

This is the end of the document.

I've been tweaking double-colons, white-space, and back-quotes for at least an hour, and can't figure out how to get it to format correctly. Perhaps reStructuredText is just not quite versatile enough to handle the nested list with embedded code blocks?

like image 900
Ogre Psalm33 Avatar asked Dec 24 '22 10:12

Ogre Psalm33


1 Answers

You have to be very careful with both vertical and horizontal whitespace. Nested lists must be separated from the parent list items by a blank line. Code examples in literal blocks must be indented properly.

Below are some test paragraphs.

1. This is a paragraph detailing a higher level step, with 3 sub-steps.

   a. This is a sub-bullet, with an example::

         ls -l foo.txt

   b. I can get this line to display as part of the code block!
      This is another sub-bullet, with an example::

         git add bar.txt

2. This is step 2.
like image 143
mzjn Avatar answered Dec 28 '22 08:12

mzjn