Granitosaurus
Granitosaurus

Reputation: 21436

Adding title attribute to an image in rst

Seems like restructured text markup is very limited when it comes to image options:

The following options are recognized:
alt : text
height : length
width : length or percentage of the current line width
scale : integer percentage (the "%" symbol is optional)
align : "top", "middle", "bottom", "left", "center", or "right"
target : text (URI or reference name)

Is it possible to set some custom attributes like title via reStructuredText markup?

e.g.

.. image:: foobar.jpg 
    :title: mouse over text, hi!

Would output:

<img src="foobar.jpg" title="mouse over text, hi!"></img>

Upvotes: 6

Views: 3318

Answers (3)

Trevor
Trevor

Reputation: 504

Alternatively you could simply use the "raw" directive and directly use your ideal target html

.. raw:: html

    <img src="foobar.jpg" title="mouse over text, hi!"></img>

Upvotes: 3

simon letort
simon letort

Reputation: 51

You can use figure

.. figure:: picture.png

   This is the caption of the figure.

Upvotes: 5

Steve Piercy
Steve Piercy

Reputation: 15055

According to docutils, the following options are recognized: alt, height, width, scale, align, target, class, and name. No title.

Options include rewriting in the client with JavaScript or work with the docutils team to make a feature request and implement it.

Upvotes: 3

Related Questions