-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Make KaTeX accessible #38
Comments
Hey! We've been thinking about ways to make KaTeX accessible, and we weren't sure what would be the best way. Is something like adding a tag to the element that lists the TeX expression good enough? Do we need to render to MathML also? I'm not very experienced with this (the other contributor @spicyj is more so), so any advice would be great! |
MathML is definitely the most "future-proof" solution but unfortunately does not work everywhere yet so the answer depends to a large degree on your platform support requirements/desires. Am I correct in assuming that you want to support all platforms? How far back do your for example want to go in supporting IE? |
We go back to IE 8 in our support. We're not planning on supporting any further back. We'll talk about what it would take to support MathML. Would this be something that you would enable only when someone is using a screen reader? |
Absolutely not. Screen reader detection is not reliable, and there are On 9/15/2014 2:46 PM, Emily Eisenberg wrote:
|
More generally, it would be good to expose a MathML output so that users of accessibility tools or of browsers with native MathML support could switch to that mode instead. |
Unfortunately, rendering to MathML all the time is impractical because Chrome seems insistent on not supporting it: https://code.google.com/p/chromium/issues/detail?id=152430 :( |
Yes, we'll definitely look into supporting it as an alternative output. I'm just curious how people with screen readers would enable it. |
If you expose both MathML and your HTML output, then it would be possible to write browser extensions to automatically switch to MathML for people who want that (e.g. https://addons.mozilla.org/en-US/firefox/addon/mathjax-native-mathml/ or https://github.com/fred-wang/mathjax-native-mathml-safari). You could also write some kind of UI like MathJax does (it uses a menu and a preference cookie). |
A browser extension definitely sounds reasonable for exposing that functionality. We're fairly opposed to a MathJax-like UI, because it's annoying and often is not helpful. Another thing to think about is that we currently support a way to render on the server and then serve up plain HTML, with no JS required. Maybe we could render to both on the server, serve up both, and switch between them (with a smaller bit of JS) depending on what's needed? Or we could serve up the HTML and the JS, and then switch to the MathML if you have the extension... |
For server-side, I think the best is to served both markup (MathML and HTML) so that math search, feed reader and other web crawlers could have access to the MathML (cc'ing @brucemiller, @physikerwelt, @kohlhase, @dginev, @huxuan who have done some work on math search). The overhead of the MathML conversion/source should be small compared to the HTML one. |
Oh, lovely, we now have a serious MathJaX-like competitor. While I am extremely happy to see there is effort invested in better math on the web, it also pains me to see projects with a big component dedicated to circumventing the stubbornness of mainstream browsers. I went back and bumped the Chromium issue, has been a while since I talked to that wall: I heartily +1 the suggestion to have a MathML output, as it is the standard markup language for representing mathematics in XML documents, as well as on the web (HTML5). ePub3 is another MathML-enabled format, where this could be really handy. |
+1 for MathML support instead of span elements! |
If you want broad support including IE8, then your only solutions if you do not always want to render MathJAX are:
Independent problems: a) When you have a combination of input fields within the math (for example in an assessment), where do you put these input fields? MathML does not support this. A natural language render could support this. Annotations within MathML (for the MathML approach) have been suggested as a way to deal with this but support for this is untested as far as i know. If you have the resources, I would suggest #3 because if you can make this code as fast as your current code, then you would have made the world of accessible math much better. Biggest problem here is translation. |
What do you mean by "Implement a natural language renderer of math"? Does this mean turning "x^2" into "x squared"? I think that the easiest solution for now will be to implement MathML. In browsers that don't support MathML (like chrome), is the MathML still accessibile even though it isn't rendered correctly, or does the browser need to have support for it in order for screen readers, etc to understand it? Thanks for helping think through this, everyone! |
You should really invest in MathML (content & presentation in parallel markup). You should see MathML as a standardized interface that allows externals tools to do what they do best. A11y is a good example of this, if you have MathML, you can feed it to a Math-aware screen reader. There are multiple examples of this, e.g. formula reader by Design Science that is integrated into Mathplayer. With MathML, a11y tools share a common basis and can compete on merits. A similar case is Math Search, there are various search engines that take MathML (content/presentation) as input and offer different functionalities on this basis (see e.g. http://ntcir-math.nii.ac.jp/ for a Math IR challenge and an overview). |
Yes, with chromevox. I think Design Science is also working on a library that works on various browsers, including Firefox and Chrome.
An additional note: for WebKit Mac, the Accessible tree relies on information from the render tree (so for example this does not work very well if you hide the math with "display: none", even if you use some aria attributes to make the MathML important for accessibility...). |
I was imagining we would mark the MathML with CSS along the following lines:
and mark the presentational HTML with aria-hidden. |
This will certainly work for DOM-based accessibility tools. That might work for Safari+VoiceOver but I can't tell for sure. As I recall, Chris Fleizach (a10y engineer at Apple) suggested something along these lines when we discussed that for MediaWiki. |
I believe I tested a similar setup with VoiceOver a couple months ago and it worked. It's what Facebook uses for some accessibility hints in their interface. |
@xymostech The screen reader support varies and requires additional plugins in order to work on all platforms (MathPlayer is required on Windows machines for example). The bottom line is that you will have to test support on all your platforms. If additional plugins are an acceptable solution for your users, then MathML might be the best approach. @spicyj The clip rect mechanism is one of the offscreen mechanisms that work well with all screen readers because the browser still exposes the HTML structure in the accessibility tree. |
+111111 for using MathML. It is a rather strange situation that accessibility support for MathML is ahead of mainstream rendering support. In Safari, Apple has added accessibility support (speech and navigation) for MathML in connection with VoiceOver. The visual rendering in WebKit is still weak, but it is getting better thanks to Fred Wang and others. In Chrome, ChromeVox can speak and navigate the math even though it is unable to render it. So if you hit a page with MathML, you can turn on ChomeVox to listen to and understand what the browser can't render :-) Of course, most people use MathJax to deal with this problem. IE8 & IE9 have MathPlayer to do the rendering and the speech and most AT software works with it. Sadly, IE stopped support for plug-ins, so MathPlayer doesn't work in the latest versions of IE. However, as someone mentioned, we are (hopefully) close to releasing a replacement that will speak and navigate math in all browsers. With MathJax rendering MathML, you have an accessible solution. Also, IE11 added an "enterprise mode" partly to support legacy plugins. Unfortunately, it's buggy and IE crashes when MathPlayer renders math in some cases. There's an open bug on this and maybe it will get fixed. If so, there's a path to having visual display and accessibility in IE with MathML. With that background, you can see why so many people suggest using MathML for accessibility. The problem that you face, and one that MathJax also faces is what to do when rendering non-MathML input. I see three short term solutions:
The better long term solution is to consider using a shadow DOM assuming it catches on. That way you expose MathML to the world but stick your (ugly) spans in the shadow DOM and no one has to see your implementation. Looking at http://caniuse.com/#feat=shadowdom, Shadow DOM only currently works with Chrome and with Firefox with the dom.webcomponents.enabled flag. There is a polyfill for it though. There is one more associated (maybe hard) problem you should keep in mind: good accessibility of math allows for synchronized highlighting of the math and speech. It's what almost all learning disability tools do with text and what they do when connected to MathPlayer. To do this, KaTeX needs to have a method to map between the MathML and the rendering of that element. I won't extend this lengthy comment even further with details on that, but I would be happy to discuss them when you get to thinking about the problem. I do hope you make accessibility a priority. It's not right that an important learning site such as Khan Academy is at best only partially usable by persons with visual disabilities -- it should work for all people who want to or need to use its great lessons. |
+1 for MathML :-). |
Agreed 👍 |
Since web components were mentioned in this thread, I’ll just leave this here. I’ve made a small vanilla web component wrapper around KaTeX: https://github.com/mathiasbynens/math-tex Demo: https://mathiasbynens.github.io/math-tex/dist/example.html |
@mathiasbynens what problem was this supposed to solve? |
@dylanb It makes it slightly easier to implement KaTeX. It is also a demonstration of using the Shadow DOM to hide the “ugly But any accessibility problems (which is what this issue is about) need to be fixed in KaTeX itself. |
Your only real option is MathML. There are interesting (read: hacky) solutions that I currently use-namely, blocking MathJax from rendering in the first place and reading the LaTeX. This is suboptimal at best, and it's rare to find a blind person who knows it. |
Hello everyone, thanks for all the feedback here. I've been distracted by other projects, but I'm going to be making a pull request soon about making KaTeX accessible, taking a hybrid MathML + aria-hidden HTML approach. I'd love to get some feedback and a hand in testing it out in different environments if anyone would like to help out. |
Summary: This adds support for rendering KaTeX to both HTML and MathML with the intent of improving accessibility. To accomplish this, both MathML and HTML are rendered, but with the MathML visually hidden and the HTML spans aria-hidden. Hopefully, this should produce much better accessibility for KaTeX. Should fix/improve KaTeX#38 Test plan: - Ensure all the tests, and the new tests, still pass. - Ensure that for each of the group types in `buildHTML.js`, there is a corresponding one in `buildMathML.js`. - Ensure that the huxley screenshots didn't change (except for BinomTest, which changed because I fixed a bug in `buildHTML` where `genfrac` didn't have a `groupToType` mapping). - Run ChromeVox on the test page, render some math. (for example, `\sqrt{x^2}`) - Ensure that a mathy-sounding expression is read. (I hear "group square root of x squared math"). - Ensure that nothing else is read (like no "x" or "2"). - Ensure that MathML markup is generated correctly and is interpreted by the browser correctly by running `document.getElementById("math").innerHTML = katex.renderToString("\\sqrt{x^2}");` and seeing that the same speech is read.
I'm glad to hear you are getting back to this. You probably should take a look at what wikipedia has done to deal with accessible math: if the user has selected the option "MathML with SVG or PNG fallback (recommended for modern browsers and accessibility tools)", they render the TeX on their server and then send down MathML and the fallbacks. To set the options, login, choose appearances, and scroll to the bottom for math options. |
\o/ |
@NSoiffer You can try it on http://katex.xymostech.com/ |
That works with the new MathPlayer+NVDA in both Firefox and IE. ChromeVox didn't work with it, but ChromeVox's math support has been broken for over a month and I can barely get it to read math anywhere, so that doesn't say much. JAWS currently requires MathJax for accessibility, but it should be able to work with the site since it only uses MathJax to get the MathML. I pass along this site to them and hopefully they will add support in a not to distant update. On Wed, Feb 25, 2015 at 11:58 AM, Frédéric Wang notifications@github.com
|
I'm not sure what "works" should mean here: on Firefox it is not using MathML, but span-soup. Ultimately, you'd want to send MathML to browsers that support it, right? It looks OK, though, although it's all quite huge, but I'm guessing from the CSS that that is intentional. |
If you use the develop tools in Firefox to look at the DOM, you'll see As for who/what is doing the rendering, that I'm not sure about. For screen
On Wed, Feb 25, 2015 at 12:55 PM, bruce miller notifications@github.com
|
Yes, the fact that the MathML rendering is hidden is a problem for assistive technologies that rely on the visual rendering such as sync highlighting or, as mentioned by Apple devs, touch screen support. However, the main issue is that KaTeX currently does not generate MathML at all, so Emily's work is already a big progress. This generates MathML + HTML with only CSS selectors to select which one that is visible, so assistive technologies can immediately obtain the MathML DOM and it's easy to write a browser add-on / greasemonkey script to force MathML to be rendered for more advanced assistive technologies or native browser rendering. |
@NSoiffer The display would not update. Is that a serious problem? Are there lots of times when that would happen? I'm not sure if there's a good general way to watch for changes to the DOM to propogate them over to the HTML version. |
If you want the DOM to propagate to the rendering, Shadow DOM seems like On Wed, Feb 25, 2015 at 3:55 PM, Emily Eisenberg notifications@github.com
|
Summary: This adds support for rendering KaTeX to both HTML and MathML with the intent of improving accessibility. To accomplish this, both MathML and HTML are rendered, but with the MathML visually hidden and the HTML spans aria-hidden. Hopefully, this should produce much better accessibility for KaTeX. Should fix/improve #38 Closes #189 Test Plan: - Ensure all the tests, and the new tests, still pass. - Ensure that for each of the group types in `buildHTML.js`, there is a corresponding one in `buildMathML.js`. - Ensure that the huxley screenshots didn't change (except for BinomTest, which changed because I fixed a bug in `buildHTML` where `genfrac` didn't have a `groupToType` mapping). - Run ChromeVox on the test page, render some math. (for example, `\sqrt{x^2}`) - Ensure that a mathy-sounding expression is read. (I hear "group square root of x squared math"). - Ensure that nothing else is read (like no "x" or "2"). - Ensure that MathML markup is generated correctly and is interpreted by the browser correctly by running `document.getElementById("math").innerHTML = katex.renderToString("\\sqrt{x^2}");` and seeing that the same speech is read. Reviewers: john, alpert Reviewed By: john, alpert Subscribers: alpert, john Differential Revision: https://phabricator.khanacademy.org/D16373
The accessibility patches were landed in the new release of KaTeX (v0.2.0). Hopefully the new, accessible version should start appearing around soon. (there isn't a way for developers to disable accessibility, so anywhere that it's used should have the new features) I ran some performance tests on the new version versus the old release. It looks like we took a ~20% speed hit, which is a little sad but not bad for things being screen-readable now: http://jsperf.com/katex-vs-accessible-katex I'm going to close this issue for now. If anyone runs into any serious problems, I'd be happy to re-open or make smaller issues. Thanks for all of the feedback, everyone! |
FYI: I spoke the JAWS developer for math support and he said they expect On Mon, Mar 2, 2015 at 12:06 PM, Emily Eisenberg notifications@github.com
|
For the record, I've updated my mathjax-native-mathml extensions to force KaTeX to display its MathML output too:
|
…couchbaseMigration Dunfalk 22 jun couchbase migration
Make KaTeX accessible to people with disabilities in particular screen reader users as they are most affected by the current limitations
The text was updated successfully, but these errors were encountered: