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

Why is id on img instead of containing figure #65

Closed
vincerubinetti opened this issue Feb 15, 2019 · 3 comments
Closed

Why is id on img instead of containing figure #65

vincerubinetti opened this issue Feb 15, 2019 · 3 comments
Labels

Comments

@vincerubinetti
Copy link

vincerubinetti commented Feb 15, 2019

The output of fignos seems to put the id/anchor to the image in the <img> tag itself instead of in the containing <figure> element. It might seem sensible to put it on the <img>, however there may be cases where it causes inconvenience.

For example, I'm working on a project called manubot where we take the html output from pandoc, using tablenos and fignos, and insert javascript "plugins" to add certain handy functionality to the manuscript. One of the plugins briefly highlights/glows an element when a user clicks a relative (eg href="#introduction") link to it. In the case of a figure, I want to highlight both the <img> and its associated <figcaption> - in other words, everything contained in the <figure>. It is the same issue with #11 on tablenos.

It's a minor grievance, but I think it's most sensible to put the id on the thing that is actually being referenced, which is the whole figure object. Same thing with the tables, having the id right on the table.

@tomduck
Copy link
Owner

tomduck commented May 8, 2019

Thanks for your question, and sorry for the delay.

The choice of where to put the id (either in the <figure> or <img> tag) is actually made by pandoc. You can see this by disabling pandoc-fignos and looking at the output.

I don't see a way for pandoc-fignos (as a filter) to overcome this. The fundamental problem is that while pandoc's abstract syntax has an Image type, it does not have a Figure type. So an id is necessarily associated with an Image at the filter stage . The conversion to an html <figure> occurs at pandoc's html writer stage; i.e., after filters are applied.

Maybe file an issue with pandoc?

I see that you have submitted an issue to pandoc-tablenos about this, and will address tables separately there.

@vincerubinetti
Copy link
Author

vincerubinetti commented May 8, 2019

Hi Tom, thanks for the response. No need to reply to the tables one too. You can just reference this response.

I think in the time since I asked this question, I noticed that it was actually a problem with pandoc. As I recall, and as you mentioned above, a limitation of its internal abstract syntax tree.

Feel free to close the issue.

@tomduck
Copy link
Owner

tomduck commented May 8, 2019

Yes, that is exactly what I see: a limitation of pandoc's internal abstract syntax tree.

I will have a separate look at the tables issue. There is a Table type in pandoc's AST, so it may be possible to move the id there. I'm not sure, but I will check.

Cheers,
Tom

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants