pandoc/test/command/3577.md
Albert Krewinkel b894de6426
HTML writer: improve alt-text/caption handling for HTML5
Screen readers read an image's `alt` attribute and the figure caption,
both of which come from the same source in pandoc. The figure caption is
hidden from screen readers with the `aria-hidden` attribute. This
improves accessibility.

For HTML4, where `aria-hidden` is not allowed, pandoc still uses an
empty `alt` attribute to avoid duplicate contents.

Closes: #6491
2020-07-01 14:54:52 +02:00

855 B

% pandoc -f latex -t html5 --quiet
\begin{figure}[ht]
    \begin{subfigure}{0.45\textwidth}
        \centering
        \includegraphics{img1.jpg}
        \caption{Caption 1}
    \end{subfigure}

    \begin{subfigure}{0.45\textwidth}
        \centering
        \includegraphics{img2.jpg}
        \caption{Caption 2}
    \end{subfigure}
    \caption{Subfigure with Subfloat}
\end{figure}
^D
<figure>
<img src="img1.jpg" alt="Caption 1" /><figcaption aria-hidden="true">Caption 1</figcaption>
</figure>
<figure>
<img src="img2.jpg" alt="Caption 2" /><figcaption aria-hidden="true">Caption 2</figcaption>
</figure>
% pandoc -f latex -t html5
\begin{figure}[ht]
    \includegraphics{img1.jpg}
    \caption{Caption 3}
\end{figure}
^D
<figure>
<img src="img1.jpg" alt="Caption 3" /><figcaption aria-hidden="true">Caption 3</figcaption>
</figure>