Prevent section heading to subtitle transformation in reStructuredText

社会主义新天地 提交于 2020-01-25 07:12:24

问题


In reStructuredText, a heading followed by a lower-level heading is read as a subtitle:

Section 1
=========

Subtitle
--------

However, what if I actually want a subsection heading to follow immediately after a section heading? According to the the docs, an empty comment "serves to terminate a preceding construct", but this doesn't seem to apply here, as

Section 1
=========

..

Section 2
---------

still gets turned into a heading for Section 1, followed by a subtitle Section 2 by, for example, rst2latex and pandoc.

Is there another way to prevent "subtitlisation" without writing any actual text between the section and subsection headings?


回答1:


Nevermind, I figured it out. A backslash followed by a space will work:

Section 1
=========

\ 

Section 2
--------

I got the idea from a tip on Simple Tables in the spec:

To start a new row in a simple table without text in the first column in the processed output, use one of these:

  • an empty comment (".."), which may be omitted from the processed output (see Comments below)
  • a backslash escape ("\") followed by a space (see Escaping Mechanism above)

IMHO this isn't very consistent: The second method works for breaking up title and subtitle, whereas the first one doesn't, as I stated in my question.



来源:https://stackoverflow.com/questions/23936768/prevent-section-heading-to-subtitle-transformation-in-restructuredtext

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