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

xhtml validation error - alt attribute missing from html image tag of svg format #2763

Closed
mixmastamyk opened this issue Jul 8, 2016 · 2 comments

Comments

@mixmastamyk
Copy link
Contributor

mixmastamyk commented Jul 8, 2016

With html output of images or figures (only in .svg format), the attribute alt of the img tag is missing, which is required under xhtml; causing validation errors. The same did not happen under the parent docutils html writer, from which it is derived from. The problem class is HTMLTranslator:

Docutils, (and Sphinx with other img formats) adds the alt attribute with a default value of the source path, which looks like a decent fallback. I've copied that behavior in my fix.

@mixmastamyk mixmastamyk changed the title xhtml validation error - alt attribute missing from svg image tags xhtml validation error - alt attribute missing from html image tag of svg format Jul 8, 2016
@mixmastamyk
Copy link
Contributor Author

mixmastamyk commented Jul 8, 2016

In short it goes from this:

<img src="../_images/spiral_model.svg" />

to this:

<img alt="../_images/spiral_model.svg" src="../_images/spiral_model.svg" />

In order to validate properly, and be consistent with other formats, such as .png images.

mixmastamyk added a commit to mixmastamyk/sphinx that referenced this issue Jul 9, 2016
Add uri as default alt attribute to images in svg format
mixmastamyk added a commit to mixmastamyk/sphinx that referenced this issue Jul 9, 2016
@mixmastamyk
Copy link
Contributor Author

Looks good.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 6, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant