Skip to content

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

@cderv

Description

@cderv

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions