24

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?

mzjn
  • 48,958
  • 13
  • 128
  • 248
davidrmcharles
  • 1,923
  • 2
  • 20
  • 33
  • 4
    I can't think of a way to solve this. Nested inline markup is a problem. See http://docutils.sourceforge.net/FAQ.html#is-nested-inline-markup-possible. – mzjn Dec 29 '15 at 20:06

2 Answers2

8

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.

jdknight
  • 1,801
  • 32
  • 52
0

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`.
dan1st
  • 12,568
  • 8
  • 34
  • 67
DalyaG
  • 2,979
  • 2
  • 16
  • 19