在reStructuredText中,如何将内联文字放在超链接中?

dav*_*les 12 restructuredtext python-sphinx

在我的reStructuredText文档中,我有一个像这样定义的部分:

Update the ``PATH`` Environment Variable
----------------------------------------
Run Code Online (Sandbox Code Playgroud)

我想像这样链接到这一部分:

* `Update the ``PATH`` Environment Variable`_
Run Code Online (Sandbox Code Playgroud)

但是,当此代码呈现为HTML时,它看起来像这样:

  • 更新``PATH`环境变量`

我真的很喜欢环境变量PATH以字面样式出现,但我对此很新.谁能帮我吗?

jdk*_*ght 8

有了解决方法,是的——这是可能的(@mzjn 的评论暗示)。

例如:

.. |dummy| replace:: Update the ``PATH`` Environment Variable
.. _dummy:

Update the ``PATH`` Environment Variable
----------------------------------------

* |dummy|_
Run Code Online (Sandbox Code Playgroud)

这是通过利用替换指令来实现的。


Dal*_*yaG 0

摘自Sphinx 文档

如果将标签直接放置在节标题之前,则可以使用 引用它:ref:`label-name`

例子:

.. _my-reference-label:

Section to cross-reference
--------------------------

This is the text of the section.

It refers to the section itself, see :ref:`my-reference-label`.
Run Code Online (Sandbox Code Playgroud)