user2662404
user2662404

Reputation: 59

Can the extlinks extension to Sphinx be configured to show the url?

I really like the fact that I can shorten URLs in the text using the Sphinx extlinks extension. Here and there I'd like to be able to display the full URL in the rendered document too, without having to hard-code it in the text and risk a mismatch between what's displayed and what the link points to. How can I do this while still using the extlinks extension to list my external links? ie: I know I can do it outside of extlinks, but having that block in the conf.py file helps to manage external stuff.

Inside conf.py:

extlinks = {
    'mySite': ('https://example.com/%s', ''),
}

Inside page.rst:

You can click :mySite:`here <>` to go to my site, <<< This bit is fine, shows a clickable "here"
which has this address: ???                       <<< How do I do this bit?
                                                  <<< I'd like to see: https://example.com/ 

Upvotes: 1

Views: 1262

Answers (1)

Andrea Giudiceandrea
Andrea Giudiceandrea

Reputation: 255

With

extlinks = {
    'mySite': ('https://example.com/%s', None),
}

in conf.py

and

You can click :mySite:`\ `

in page.rst

should do the trick and you will display

You can click https://example.com/

with a link to https://example.com/

while

You can click :mySite:`here <>`

will display

You can click here

with 'here' linked to https://example.com/

Upvotes: 1

Related Questions