A problem with marking up languages in titles for screen readers

A problem with marking up languages in titles for screen readers

by Tim Hunt -
Number of replies: 2
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

I have just run up against a problem and I cannot yet think of any way to solve it, so I am asking here because you are all very clever.

Consider this situation: Suppose you have a course that is written in English, but is about the French languages. In that case, you might want a page with Title: 'Conjugation of the verb Être'.

Now, if you care about accessiblity, then for screen readers that needs to be marked up as 'Conjugation of the verb <span lang="fr">Être</span>'. (Because the course is in Engllish, there will be a lang="en" attribute on the <html> tag.)

The other use-case we have to remember (so we don't break it) is the Moodle multi-lang filter. If you had a course bilingual in English and Russion, then you might have a page titled '<span lang="en" class="multilang">cat</span><span lang="ru" class="multilang">кошка</span>', and that works becuase all headings are fed through format_string, which applied the multilang filter, and so that will end up as either 'cat' or 'кошка', and the screen-reader will prounouce that correctly because that language selected will match the overall language of the page. This is all good.

But, unfortunately one part of the format_string code is to always call strip_tags - $CFG->formatstringstriptags is true by default. This is quite sensible from a security / preventing XSS attacked point-of-view. Unfortunately, it means that the mixed language in headings case cannot possibly work - unless we can think of something very clever.

Please apply your genius.

Average of ratings: Useful (1)
In reply to Tim Hunt

Re: A problem with marking up languages in titles for screen readers

by Iñaki Arenaza -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

I don't think you can make it work, unless you change format_string (assuming that $CFG->formatstringstriptags is true). The call to strip_tags is performed after all filtering is done. So no matter what you could do with a hypothetical filter that produced the HTML tags needed by screen readers, they would be removed by strip_tags.

If tag stripping was performed before running the filters[1] , you could use a special syntax (not removed by strip_tags) for the screen reader language. And use a (new) filter to produce the HTML tags needed.

[1] I haven't thouroughly analysed the consequences of this with respect to XSS and such.

Saludos.

Iñaki.

In reply to Iñaki Arenaza

Re: A problem with marking up languages in titles for screen readers

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

Thank you for backing up my conclusion that this can't be fixed without changing format_string. And as you say, that is something that could only be done with very careful analysis.