mpenkov
mpenkov

Reputation: 21932

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?

Upvotes: 13

Views: 1987

Answers (2)

Steve Piercy
Steve Piercy

Reputation: 15105

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/

Upvotes: 17

asrjarratt
asrjarratt

Reputation: 314

You can do this:

.. |Target| replace:: Text With Space
.. _Target: http://google.com

For more info, see |Target|_

Upvotes: 6

Related Questions