在第一个文件中显示两个破折号

Display two dashes in rst file

我写了第一个文件,打算显示以下内容:

命令-abc --efg

当两个破折号在一起时,我尝试了几种方法来转义破折号,但我无法在编译的文档中获得我想要的内容。以下是我尝试过的一些方法:

command -abc --efg
command -abc \--efg
command -abc -\-efg
command -abc \-\-efg
command -abc \--\--efg

有什么建议吗?

根据您的 Sphinx 版本,所有转化次数都为 html_use_smartypants=True (Sphinx < 1.6.6) or smartquotes=True (Sphinx ≥ 1.6.6). If you omit either setting from your conf.py or when invoking sphinx-build, then the default value of True will be in effect, converting a double-dash "--" into a typographical en-dash "–". See Smart Quotes for Docutils, Description

您可以转义双破折号中的每个字符,但这是丑陋的标记,并且显示与内联文本无法区分。

command -abc \-\-efg

要内联显示命令,请用双勾将其括起来。显示可区分为命令。

Enter the command ``command -abc --efg`` to do stuff.

要在单独的文本块中显示命令,请使用 .. code-block::

.. code-block:: bash

    command -abc --efg

以上示例的渲染显示: