如何处理 ReST 中的两个破折号 [英] How to handle two dashes in ReST
问题描述
我正在使用 Sphinx 来记录用 Python 编写的命令行实用程序.我希望能够记录命令行选项,例如 --region
像这样:
I'm using Sphinx to document a command line utility written in Python. I want to be able to document a command line option, such as --region
like this:
**--region** <region_name>
在 ReST 中,然后使用 Sphinx 为我生成 HTML 和手册页.
in ReST and then use Sphinx to to generate my HTML and man pages for me.
这在生成手册页时效果很好,但在生成的 HTML 中,--
变成了不正确的 -
.我发现如果我将源 ReST 文档更改为如下所示:
This works great when generating man pages but in the generated HTML, the --
gets turned into -
which is incorrect. I have found that if I change my source ReST document to look like this:
**---region** <region_name>
HTML 生成正确,但现在我的手册页有 ---
而不是 --
.同样不正确.
The HTML generates correctly but now my man pages have ---
instead of --
. Also incorrect.
我试过用反斜杠字符(例如 \-\-
)转义破折号,但没有效果.
I've tried escaping the dashes with a backslash character (e.g. \-\-
) but that had no effect.
任何帮助将不胜感激.
推荐答案
这是 Sphinx 中默认启用的配置选项:html_use_smartypants
选项(http://sphinx-doc.org/config.html?highlight=dash#confval-html_use_smartypants).
This is a configuration option in Sphinx that is on by default: the html_use_smartypants
option (http://sphinx-doc.org/config.html?highlight=dash#confval-html_use_smartypants).
如果您关闭该选项,那么如果您想要一个短划线,则必须使用 Unicode 字符–".
If you turn off the option, then you will have to use the Unicode character '–' if you want an en-dash.
这篇关于如何处理 ReST 中的两个破折号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!