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

Insert SVG file as <object> instead of <img> in HTML (better for accessibility) #6581

Open
Tracked by #8706
cderv opened this issue Aug 22, 2023 · 2 comments
Open
Tracked by #8706
Labels
accessibility enhancement New feature or request
Milestone

Comments

@cderv
Copy link
Collaborator

cderv commented Aug 22, 2023

This is possible in knitr following discussion at yihui/knitr#2152 by opting in using option options(knitr.svg.object = TRUE). Unfortunately, this does not work in Quarto because we don't use knitr plot hooks.

This is important for accessibility as explained by @jooyoungseo at yihui/knitr#2152 (comment).

When embed-resources: true, <svg> will be included but when embed-resources: false, <img> will be used.

Since svg is embedded via tag, there is no way to access the svg DOM tree within the generated html output. In order to let assistive technology agents, such as screen readers, interact with the svg, we may want to take different approaches.

This treatment for SVG file was discussed in Pandoc at

but solution recommended there was too use a Lua filter to create the <object> when this is a svg file.

I suggest we do the same in our Lua filter in Quarto.

cc @jooyoungseo

@jimjam-slam
Copy link

jimjam-slam commented Aug 24, 2023

While I would love to see SVGs embedded in a way that surfaces their DOM (and therefore makes them more accessible), I would also note alternative solutions to <object> or <embed>. SVGs operate like <iframe>s but without the ability to impose any security sandbox.

There was some talk about either:

  1. deprecating <object> and <embed> and bringing their auto-sizing capability to <iframe> for SVGs, or
  2. adding the sandbox attribute to <object> or <embed>.

I don't know that it's gone anywhere since last November, though.

Maybe you could write a Lua filter that uses an <object> and <embed> for a local SVG or an <img> for a remote one as a rough trust heuristic?

@nichtich
Copy link

nichtich commented Nov 6, 2023

A use cases for <object> instead of <iframe> is to allow links in images pointing to other parts of the publication.

@dragonstyle dragonstyle added this to the v1.5 milestone Nov 28, 2023
@cscheid cscheid mentioned this issue Feb 12, 2024
13 tasks
@cscheid cscheid modified the milestones: v1.5, Future Feb 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
accessibility enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

5 participants