Skip to content

rst figure options are applied to image only #7473

Closed
@quytelda

Description

@quytelda

Explain the problem.
When converting a reStructuredText figure directive to HTML, options like figclass and align are only applied to the image and not the entire figure in the output. Based on the reference documentation for figure, I think these options are intended to apply to the entire figure.

For example, if I run the following command:

$ pandoc --from=rst --to=html5 <<EOF
.. figure:: example.img
   :figclass: foobar

   This is a caption.
EOF

I would expect the output to be:

<figure class="foobar">
<img src="example.img" alt="This is a caption." /><figcaption aria-hidden="true">This is a caption.</figcaption>
</figure>

Instead, I get the following, where the class=foobar attribute is part of the img tag.

<figure>
<img src="example.img" class="foobar" alt="This is a caption." /><figcaption aria-hidden="true">This is a caption.</figcaption>
</figure>

This issue causes the image and caption to get separated if the CSS stylesheet tries using something like float to align the figure.

Pandoc version?
I can reproduce this issue with the current development version (git) and pandoc 2.14.0.2 (pacman version: 2.14.0.2-2).
My OS is Arch Linux.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions