2

I am using Sphinx with reStructuredText, and I’d like to include a hyperlink inside an inline literal. However, predictably, if I write

The result has type ``Foo_ -> Bar_``.

.. _Foo:

Information about ``Foo``.

.. _Bar:

Information about ``Bar``.

then Foo_ and Bar_ are not turned into hyperlinks. If I change my document to use a parsed-literal block, instead

The result has type:

.. parsed-literal::

    Foo_ -> Bar_

then I get the hyperlinks I want. However, I don’t want a separate block—I want the code to be inline. Is there any way to do that?

mzjn
  • 48,958
  • 13
  • 128
  • 248
Alexis King
  • 43,109
  • 15
  • 131
  • 205

1 Answers1

4

You can get pretty close with substitutions.

.. |Foo| replace:: ``Foo``
.. |Bar| replace:: ``Bar`` 

The result has type |Foo|_ ``->`` |Bar|_.

.. _Foo:

Information about ``Foo``.

.. _Bar:

Information about ``Bar``.

This was inspired by the workaround for nested inline markup described here: http://docutils.sourceforge.net/FAQ.html#is-nested-inline-markup-possible.

See also Format text in a link in reStructuredText.

mzjn
  • 48,958
  • 13
  • 128
  • 248