python-sphinxrestructuredtexttargeting

How to include space in a hyperlink target using reStructuredText?


I can do this:

For more info, see Target_.

.. _Target: http://google.com

This correctly generates documentation that links Target to "http://google.com".

I want to replace Target with text that has spaces:

For more info, see Text With Space_.

.. _Text With Space: http://google.com

The above example generates documentation that incorrectly links "Space" to an unknown location. I want it to link "Text With Space" to "http://google.com".

How can I achieve this?


Solution

  • From the Sphinx documentation for Hyperlinks, External links.

    Use Link text <http://example.com/>_ for inline web links.

    `Link text <http://example.com/>`_
    

    You can also separate the link and the target definition (ref), like this:

    This is a paragraph that contains `a link`_.
    
    .. _a link: http://example.com/