【问题标题】:In reStructuredText, how to put an inline literal inside of a hyperlink?在 reStructuredText 中,如何将内联文字放在超链接内?
【发布时间】:2016-04-03 15:32:48
【问题描述】:

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

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

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

* `Update the ``PATH`` Environment Variable`_

但是,当这段代码被渲染成 HTML 时,它看起来像这样:

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

我真的很希望环境变量PATH 以文字样式出现,但我对此很陌生。谁能帮帮我?

【问题讨论】:

标签: python-sphinx restructuredtext


【解决方案1】:

取自Sphinx documentation

如果您将标签直接放在章节标题之前,您可以使用: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`.

【讨论】:

    【解决方案2】:

    有了workaround,是的——这是可能的(从@mzjn 的comment 暗示)。

    例如:

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

    这是通过利用replace directive 来实现的。

    【讨论】:

      猜你喜欢
      • 2019-11-19
      • 2021-08-01
      • 2018-11-23
      • 2016-08-01
      • 2017-03-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多