In reST syntax currently sections and subsections are closed implicitly by the opening of the next section. This is fine for plain documents, but applications building on top of reST extend it with directives that might insert additional content. There is currently no syntax to tell reST that this directive belongs in a parent section instead of the current section. (You can create a new section at any level, but often the user wants the directive to belong to the existing parent section.)
See https://github.com/sphinx-doc/sphinx/issues/8518 for a concrete use-case.
Ticket moved from /p/docutils/bugs/411/
Can't be converted:
While it bites at times, this restriction is not a bug but a feature it shares with printed text and markup formats like LaTeX.
In your use case, the first included file should start with a section heading of the same level as "Intro" or you should insert a heading for the "a/* pages" before the Sphinx ".. toctree::" directive.
This feature would be useful for LaTeX as well as a parsed-printed-text format that expands directives.
In my sphinx example, I do not want to have to artifically add extra sections, since that is not what I want the structure to be. Telling the user to do something different from what they originally want, is not a "feature", it's the absence of a feature. In particular, the autogenerated TOC entries in other parts of the output, will look weird and artificial, which it is.
I would like the structure to be:
** Intro
** A/subpage 1
** A/subpage 2
where the subpage sections are generated automatically by the directive.
There is no syntax at the moment to do this, because there is no way to tell docutils the structure should be:
** Intro
instead of:
** Intro
** (content inserted by directive, belonging to "Intro")
What actually is the technical challenge in supporting this? It is possible in all other parsers that I can think of.
On Tue, 8 Dec 2020 at 06:01, Ximin Luo infinity0x@users.sourceforge.net
wrote:
is there a construct in typesetting (as there is none in LaTeX i assume
there isn't)
restructred text is a (to me) not a markup but a presentation format (it is
really close
to old RFC textformats) and typewriter letters, so how to present this
going up the toc-level
maybe use a tool like longtables in LaTeX, you have a table-head and a
table-head-continued and
a table-foot-tobecontinued and a table-foot,
table::
"col1" | "col2" | ...
rows | ...
"table continued on next page" <-- the table-foot for but the last one
-- page break
" continued from previous page"
"col1" | "col2" | ...
rows | ...
----------- <--- table end
assuming i write for a human reader i would put a line like "(end of
Intro)" or "(back to ...)" into the text
it helps understanding.
all the best
Thank you for the clarification. The special case you mention may be catered for.
RestructuredText has no generic markup construct for
and the Docutils doctree specification defines:
because this would not make sense in printed output --- there is no typographical convention to signify to the reader that a section is closed (other than starting the next section).
Your particular use case is a bit different:
Appending
<section>nodes as children to the "Chapter A"<section>after the "Intro"<section>would generate a valid document tree.As everything except a section header or a
<section>-generating directive willresult in an invalid document tree, I do not support some a new syntax construct for ending a section.
Instead, the
<section>-generating directive could define a directive optionthat can be used to specify whether the generated
<section>node should be nested in the current section (becoming a sub-section) or appended to the current section (becoming the next section of the same level).This is something that must be handled by the downstream application (Sphinx or Sphinx extension) that defines this directive -- maybe via a pending node and a transform.
If there is no need to have "Intro" in the ToC, you may use an "abstract" or "topic" directive instead of a section for the Introduction.
Thanks for the detailed explanation! The validity rule makes sense now and I can understand why you don't wish to add this feature. I will pass this onto the sphinx developers in that ticket.