In reStructuredText, how to put an inline literal inside of a hyperlink?

谁说胖子不能爱 提交于 2019-12-06 18:50:10

问题


In my reStructuredText document, I have a section defined like so:

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

I would like to link to this section like so:

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

But, when this code is rendered to HTML, it comes out looking like this:

  • Update the ``PATH` Environment Variable`

I'd really like the environment variable PATH to appear in the literal style, but I am pretty new to this. Can anyone help me out?


回答1:


With a workaround, yes -- it is possible (hinted from @mzjn's comment).

For example:

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

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

* |dummy|_

This is achieved by taking advantage of the replace directive.




回答2:


Taken from the Sphinx documentation:

If you place a label directly before a section title, you can reference to it with :ref:`label-name`.

Example:

.. _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`.


来源:https://stackoverflow.com/questions/34516306/in-restructuredtext-how-to-put-an-inline-literal-inside-of-a-hyperlink

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!