MathJax icon indicating copy to clipboard operation
MathJax copied to clipboard

MathJax rendering breaks find in page highlight support

Open Jamesernator opened this issue 3 years ago • 3 comments

Issue Summary

Essentially find-in-page (using CTRL+F) can successfully find text in CHTML-rendered MathJax, however this text isn't highlighted in any way as would be expected for regular text.

Steps to Reproduce:

Try this sample in the demo:

<math>
  <mi>test</mi>
</math>

Use the browser's CTRL+F find in page feature to search for "test", notice MathJax text is findable, but isn't highlighted.

Technical details:

  • MathJax Version: Latest
  • Client OS: ChromeOS 99
  • Browser: Chrome 99

Supporting information:

Notice find in page can find the text, but no highlighting is applied:

image

Jamesernator avatar Mar 15 '22 10:03 Jamesernator

Currently expected behavior but about to change, see https://github.com/mathjax/MathJax-src/pull/734

pkra avatar Mar 15 '22 11:03 pkra

Actually, the browser is not finding the typeset output, but rather the assistive MathML that is inserted in the page for those using screen readers and other assistive technology. This MathML is visually hidden, but available to screen readers. It is actually the "test" that is in <mi> in that hidden MathML that the browser is finding, but because it is not visible in the display, you don't see it being highlighted. You can verify that this is true by turning off the assistive MathML in the MathJax contextual menu (under the accessibility submenu); if you do that, the search should only find the on in the input text area.

The current CHTML output is created using CSS content specifiers for ::before selectors on certain elements, and such content is neither selectable nor searchable. As Peter points out, that is going to change in the next release, and it looks like browsers will be able to find the "test" in the output (and show it highlighted), but it will still also find the assistive MathML output, which is not be visible. I don't see any way to have the assistive MathML available to screen readers while not allowing it to be found by the browser search. Sighted users can, of course, turn off assistive MathML to avoid the issue.

dpvc avatar Mar 22 '22 13:03 dpvc

I don't see any way to have the assistive MathML available to screen readers while not allowing it to be found by the browser search.

Well at least Chrome is finally implementing MathML, so in future people probably should just emit native MathML rendering where supported, in which case the accessibility tree and render tree will be able to share the same nodes. Having the extra invisible in just the CHTML output won't matter too much as hopefully people will just use the CHTML output for supporting older browsers without native rendering support.

Jamesernator avatar Mar 27 '22 05:03 Jamesernator