Search code examples
restructuredtext

I want to create an image in reStructuredText, which will have an alternative (<alt>) in html and still work in pdf


So I'm writing reStructuredText which creates an HTML page and a PDF at the same time. I'd like to add alternative text for the image in HTML, but when I add it in my code the image doesn't work in the PDF!

My code without alternative text (which work in both case):

.. image:: https://********.jpg

My code that doesn't work in PDF:

|alternative en plusieurs mots|

.. |alternative en plusieurs mots| image:: https://*********.jpg

Solution

  • From the documentation of the docutils image directive, the following should work:

    .. image:: https://********.jpg
        :alt: alternative en plusieurs mots