Skipping heading levels in reStructuredText

[亡魂溺海] 提交于 2019-12-10 18:20:41

问题


Is it possible in some way to skip heading levels in RestructuredText? For example, given

####
PART
####

*******
Chapter
*******

Section
=======

Subsection
----------

Subsubsection
^^^^^^^^^^^^

Paragraph
"""""""""

Another section
===============

Another Paragraph
"""""""""""""""""
The above heading seems to be rendered as a subsection-level heading...

The last paragraph gets rendered as a subsection instead of as a paragraph. (I am using Sphinx as a renderer.) So it seems section-level detecting is local, although the RestructuredText documentation says it should be consistent:

All section title styles need not be used, nor need any specific section title style be used. However, a document must be consistent in its use of section titles: once a hierarchy of title styles is established, sections must use that hierarchy.


回答1:


When running Sphinx 1.3 on the document in the question, a warning is emitted:

C:\path\to\test.rst:24: SEVERE: Title level inconsistent:

"Another Paragraph" is on line 24 and it gets rendered as a subsection heading because that is what Sphinx expects at that position.

So no, you cannot skip heading levels. That is also how I interpret the meaning of the passage about consistency quoted in the question.



来源:https://stackoverflow.com/questions/33149169/skipping-heading-levels-in-restructuredtext

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!