Like image
’s :alt:
directive, allow :title:
for creating titles on pointer hover. The use case here is different from alt as alt is for assistive technologies & titles are more to give a labels for images for those with pointer cursors.
Expected input
.. image:: /house.jxl
:alt: Home
:title: Navigate home
:target: /
.. image:: /cat.jxl
:alt: A Siamese cat on a chair
:title: Chula says, “meow”
Expected HTML output
<a href="/"><img src="/house.jxl" alt="Home" title="Navigate home"></a>
<img src="/cat.jxl" alt="A Siamese cat on a chair" title="Chula says, “meow”">
~~~
Thank you for the suggestion.
Support for the
<img>
"title" attribute in HTML output would require a means to store thetitle in the
<image>
document tree element, e.g. a new attribute.Before an implementation, we would have to consider how an image "title" option/attribute should be handled in other output formats like LaTeX/PDF or OpenDocument text.
Alternatively, a figure with approbiately styled caption might suit your needs:
For the rST source
a possible styling of HTML5 writer output would be
Last edit: Günter Milde 2024-10-01
I would say the title is strictly for HTML output. In the way that touch pointers often can’t read the
title
, it is left for cursor pointer & screen readers. Thinking about it in this sense tho, I think even if the HTML attribute is calledtitle
the name is probably easily confused with something visible. HTML spec says to not ‘rely’ on it, but it makes a good place for Easter eggs or other flavor commentary.For context, my existing workaround is, as you noted, using a
.. figure
& post-processing based on a specific CSS class to 1) move<figcaption>
contents totitle
, 2) ‘unwrap’ the parentfigure
node to just leave the<img>
behind, but this feels like a hack/abuse, especially since the flavor text isn’t meant to be visible for PDFs which the.. figure
would show.More info: https://html.spec.whatwg.org/multipage/dom.html#the-title-attribute
If at all, an attribute/option to-be-translated to the HTML "title" attribute would come under a different name ("tooltip" or "annotation", say):
<title>
element.<document>
element for the "metadata title" (which corresponds to the HTML<title>
element) and is, e.g. shown on a browsers toolbar.Where should Docutils/rST support stop?
In HTML, "title" is one of the common attributes, supported by (almost) all elements.
The LaTeX package "pdfcomment" provides a
\pdftooltip
macro that createspop-ups in PDF output. Like the HTML "title" attribute, it can be used on paragraphs, tables, footnote references, and more.
However, whether support for an attribute you may use for easter eggs but must not rely on is a valuable addition for a lightweight markup language remains questionable.
For the rare use cases exist workarounds in form of CSS rules or "raw" HTML.
Commit [r9950] adds support for class values on the figure caption. Now you can write:
and style the resulting HTML5 writer output with
To suppress the tooltip in PDF output, convert with
Related
Commit: [r9950]
Last edit: Günter Milde 2025-04-28
See also the proposal by Roman Suzi in "docutils-users" from 2003-07-07 [1]
and a recent request for a hyperlink with "title" attribute [2].
[1] https://sourceforge.net/p/docutils/mailman/docutils-users/thread/Pine.LNX.4.44.0307070819150.2138-100000%40rnd.onego.ru/#msg4465479
[2] https://sourceforge.net/p/docutils/mailman/docutils-users/thread/20241223165633.348f4e6559e04e9e1afd1c12%40poczta.onet.pl/#msg59108867
Last edit: Günter Milde 2024-12-30
This feature request needs more thought and discussion.
It may be a topic for a new enhancement proposal.
Last edit: Günter Milde 2025-04-29