1

I have lots of clickable images in my documentation. And most of them have the same base URL.

base-url = "https://github.com/username/repository/tree/master".

In Sphinx, we can add links(target-url) to the image as below:

.. image:: <image-url>
    :target: <target-url>

I want this target-url to be substituted by a global variable defined in conf.py, so that I can substitute it like:

.. image:: <image-url>
    :target: <base-url>/<relative-path>

I know that links can be substituted with the help of sphinx.ext.extlinks extension. But it is not working for above said purpose. I don't know if this is possible or not. Any alternatives are welcome too.

bad_coder
  • 11,289
  • 20
  • 44
  • 72
Avinal
  • 184
  • 4
  • 11

1 Answers1

1

This question seems related to this discussion.

Apparently, even with extlinks it is not feasible for image targets, but someone proposed a workaround. Heavy, but might work for you.

smarie
  • 4,568
  • 24
  • 39
  • I used the tips shown in that discussion but that didn't work for image targets. However, the other workaround seems promising. I will try it and update it here. Thanks :) – Avinal Jun 16 '21 at 05:37