Menu

#274 :name: in figure adds an id to the <img> rather than the <div>

closed-invalid
nobody
None
5
2020-03-03
2015-03-10
Jellby
No

A named figure like this:

.. figure:: myfile.png
   :name: label

   Figure caption.

creates a <div> with an <img> in HTML, and assigns the id="label" to the <img>. I think this is undesired, especially if the output is modified to write the caption above the figure (then a link to the figure would not display the caption). I understand the options to figure are "image options", but I'd say a :name: in this case is probably intended to be applied to the figure rather than the image.

I reported this for sphinx (https://github.com/sphinx-doc/sphinx/issues/1742) but they don't want to change docutils' behaviour, so I ask for it to be changed here.

Discussion

  • Günter Milde

    Günter Milde - 2015-03-11

    This is the documented behaviour:

    The "figure" directive supports all of the options of the "image" directive (see image options above). These options (except "align") are passed on to the contained image.

    http://docutils.sourceforge.net/docs/ref/rst/directives.html#figure

    If you want a name for the containing figure element, you can write

    .. _figure-name:
    
    .. figure:: myfile.png
       :name: imagelabel
    
       Figure caption.
    

    or file an enhancment request for a "figname" option to go alongside "figclass".

     
  • Günter Milde

    Günter Milde - 2015-03-11
    • status: open --> closed-invalid
     

Log in to post a comment.

MongoDB Logo MongoDB