Search code examples
restructuredtext

After creating a subsection, how to make a paragraph part of the parent section?


The following is a block of reStructuredText that defines a "Main Section" and two subsections, each with a sentence of content.

Main Section
============

This is some main section content.

Subsection 1
------------

This is the content of subsection 1.

Subsection 2
------------

This is the content of subsection 2.

Having created subsections, is there a way to add subsequent paragraphs that are part of "Main Section"? E.g.: The following is a block of reStructuredText that defines a "Main Section" and two subsections, each with a sentence of content.

Main Section
============

This is some main section content.

Subsection 1
------------

This is the content of subsection 1.

Subsection 2
------------

This is the content of subsection 2.

This is some more main section content -- I want this sentence to be "part of" "Main Section", not "Subsection 2".

Is there a way to do this? Or is it required that all of a section/subsection's content must appear prior to the addition of a subsection?


Solution

  • No, similar to sections in a typical printed book, this is not possible in reStructuredText. Neither the rST syntax nor the Dotutils document model provide for main section content after a subsection.

    The "topic" and "sidebar" directives provide for nested text parts with a title. They are intended for parts outside the main flow of the document and the title does not appear in the table of contents.

    A transition may be used to denote a break after one or more paragraphs, although technically the part after a transition is at the same section level as before.