w3c / epubcheck

The conformance checker for EPUB publications
https://www.w3.org/publishing/epubcheck/
BSD 3-Clause "New" or "Revised" License
1.49k stars 396 forks source link

role="math" on images #1562

Open gregoriopellegrino opened 1 month ago

gregoriopellegrino commented 1 month ago

When following the WAI ARIA 1.2 example for using role="math" on an image element to indicate that it represents a mathematical expression (https://www.w3.org/TR/wai-aria-1.2/#example-8), EPUBCheck reports an ERROR RSC-005 stating that the value of the "role" attribute is invalid.

From the WAI ARIA 1.2 spec:

While it is not ideal to use an image of a mathematical expression, there exists a significant amount of legacy content where images are used to represent mathematical expressions. Authors SHOULD ensure that images of math are labeled by text that describes the mathematical expression as it might be spoken.

However, EPUBCheck doesn't recognize math as a valid value for the role attribute, resulting in a false positive error.

Here you can find a sample EPUB file exhibiting this issue for testing purposes: quadratic-formula.epub.zip

mattgarrish commented 1 month ago

This doesn't look like a problem to fix in epubcheck. You've put the role on an img tag where it isn't valid per the ARIA in HTML specification.

I think you need to take this to the ARIA group to sort out whether it is allowed on images or not and update the ARIA in HTML document accordingly. Validation of roles normally come from the validator.nu code, so that needs updating to fix the issue here, and they don't usually modify their code until the ARIA in HTML document is updated.

clapierre commented 1 month ago

Sounds like there are some major confusion using role="math"

Look here https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles/math_role they have an example: <img src="pythagorean_theorem.gif" alt="a^{2} + b^{2} = c^{2}" role="math" />

mattgarrish commented 1 month ago

Sounds like there are some major confusion using role="math"

The ARIA spec appears to be the source of this markup (see the section on polyfilling the equation). They show an example of transforming math to an image and the markup also shows the role on the img tag.

If I try it out in a browser and check the accessibility tree, the alt text is correctly associated with the role, so I suspect it's the ARIA in HTML doc that is out-of-date. But fixing it and then the validator is usually what's necessary to get a change into epubcheck.

gregoriopellegrino commented 1 month ago

Okay, so I'll open an issue for ARIA-HTML.