Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rst figure options are applied to image only #7473

Closed
quytelda opened this issue Aug 3, 2021 · 4 comments · Fixed by #9744
Closed

rst figure options are applied to image only #7473

quytelda opened this issue Aug 3, 2021 · 4 comments · Fixed by #9744

Comments

@quytelda
Copy link

quytelda commented Aug 3, 2021

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.

@quytelda quytelda added the bug label Aug 3, 2021
@argent0
Copy link
Contributor

argent0 commented Aug 3, 2021

Tangentially I'm working on adding explicit figure representation in pandoc. It doesn't yet work on RST though.

@jgm
Copy link
Owner

jgm commented Aug 3, 2021

Currently figures are just represented as images in a paragraph, so there isn't anywhere else to add the attributes. This will change when Figure gets added with @argent0's work.

@quytelda
Copy link
Author

quytelda commented Aug 5, 2021

Great, that's good to know.

Let me know if there's anything I can do to help with that. I'm not really familiar with this codebase, but I've got some time and I enjoy working with Haskell.

@tarleb
Copy link
Collaborator

tarleb commented Jan 17, 2023

This is now fixed for figclasses, but not for align.

@jgm jgm closed this as completed in #9744 May 10, 2024
jgm pushed a commit that referenced this issue May 10, 2024
Fixes #7473 

Previously, `figclass`es weren't being extracted correctly.

`figclass` and `align` annotations are now implemented following the rst docs: these options apply to the figure while other options are passed onto the underlying image.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants