reStructuredText换行符会破坏代码块

gh4*_*h4x 5 restructuredtext python-sphinx

嗨,谢谢你看我的问题!所以我使用reStructuredText和Sphinx来生成一组文档.每个页面必须符合PEP8,因此每行最多80个字符.这是一项新要求,打破了几个页面.

我们曾经有过:

.. code-block:: bash
    really really long line of code that I would want a new user to copy and paste into a terminal
Run Code Online (Sandbox Code Playgroud)

我们现在有:

.. code-block:: bash
    really really long line of code that
    I would want a new user to copy and
    paste into a terminal
Run Code Online (Sandbox Code Playgroud)

这是一个问题,因为每个行在粘贴到终端时都被视为单独的命令.阅读文档,我看到我可以做类似的事情:

| really really long line of code that I 
  would want a new user to copy and paste
  into a terminal
Run Code Online (Sandbox Code Playgroud)

使我的文本适合1行,但这不会保持我想要的块样式或语法高亮.有谁知道如何实现我想要的东西?在此先感谢您的反馈!

mzj*_*zjn 5

您应该能够使用反斜杠来指示该行继续.它逃脱了换行符.

.. code-block:: bash

   really really long line of code that \
   I would want a new user to copy and \
   paste into a terminal
Run Code Online (Sandbox Code Playgroud)

粘贴到终端时,该命令被解释为一条长行.

请参阅http://www.gnu.org/software/bash/manual/bashref.html#Escape-Character.