reStructuredText 换行符中断代码块
reStructuredText newline character breaks code blocks
我正在使用 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
我们现在有:
.. code-block:: bash
really really long line of code that
I would want a new user to copy and
paste into a terminal
这是个问题,因为在粘贴到终端时,每一行都被视为单独的命令。阅读我看到的文档,我可以做类似的事情:
| really really long line of code that I
would want a new user to copy and paste
into a terminal
使我的文本适合 1 行,但这不会保留我想要的块样式或语法突出显示。有谁知道实现我想要的东西的方法?提前感谢所有反馈!
您应该能够使用反斜杠来表示该行继续。它转义了换行符。
.. code-block:: bash
really really long line of code that \
I would want a new user to copy and \
paste into a terminal
粘贴到终端时,该命令被解释为一长行。
参见http://www.gnu.org/software/bash/manual/bashref.html#Escape-Character。
我正在使用 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
我们现在有:
.. code-block:: bash
really really long line of code that
I would want a new user to copy and
paste into a terminal
这是个问题,因为在粘贴到终端时,每一行都被视为单独的命令。阅读我看到的文档,我可以做类似的事情:
| really really long line of code that I
would want a new user to copy and paste
into a terminal
使我的文本适合 1 行,但这不会保留我想要的块样式或语法突出显示。有谁知道实现我想要的东西的方法?提前感谢所有反馈!
您应该能够使用反斜杠来表示该行继续。它转义了换行符。
.. code-block:: bash
really really long line of code that \
I would want a new user to copy and \
paste into a terminal
粘贴到终端时,该命令被解释为一长行。
参见http://www.gnu.org/software/bash/manual/bashref.html#Escape-Character。