Page MenuHomePhabricator

alt tag in math environment seems to get ignored
Open, Needs TriagePublic

Description

According to a multitude of help pages, the math environment supports an alt tag that displays alternative text for the use with screen readers. Currently, however, this is not the case:

  • ) The alt attribute is ignored
  • ) The TeX code to create the formula is displayed as the alt text of the resulting image

Example:

<math alt="Square root of pi">\sqrt{\pi}</math>

Should display "Square root of pi" as alt text. However, it displays {\sqrt {\pi }}

Alternatively: The Help and Acessibility Pages may need to be updated to the new preferred screenreader formatting for maths formulae

See also:
https://en.wikipedia.org/wiki/Help:Displaying_a_formula#Rendering (Second paragraph)
https://en.wikipedia.org/wiki/Help_talk:Displaying_a_formula#Alternative_text_does_not_work_as_described
https://phabricator.wikimedia.org/T3962
https://phabricator.wikimedia.org/T136915
https://phabricator.wikimedia.org/T86521

Event Timeline

Aklapper renamed this task from alt tag in math environment to alt tag in math environment seems to get ignored.Sep 17 2019, 4:20 PM

Hi @Lpd-Lbr, thanks for taking the time to report this and welcome to Wikimedia Phabricator!

Which MediaWiki version and which Math version is this about? (Or is this about some Wikimedia website?)

Thank You for the prompt reply!

I fear that I don't understand the question. How can I find out which MediaWiki and Math version I am using, or what qualifies as some Wikimedia site?

I have followed this guide to report the bug: https://en.wikipedia.org/wiki/Wikipedia:Bug_reports_and_feature_requests

A minimal example of the bug can be seen here: https://de.wikipedia.org/wiki/Benutzer:Lpd-Lbr/Alternativtext

This update of the help pages may give an estimate (25 August 2009) on when the feature was initially implemented: https://en.wikipedia.org/w/index.php?diff=next&oldid=309966422

@Lpd-Lbr Thank you for your bug report. This is the intended behavior of the Math extension. Thus it's not a bug but a feature request. I will take care of the handling of this feature request. Note, that it might take a few weeks until there is a decision if we implement the feature.

Thank You!
Am I correct in assuming that in this case, the documentation is wrong? What is the process to correct this?

To help the discussion here is some info about current usage.

There are about 190 uses of alt tags on the English wikipedia (excluding repetitions).

Many are simple text descriptions of the formula like

<math alt="1-2+3-4+...=1/4">

<math alt="cosine of phi in the x-hat direction plus sine of phi in the y-hat direction">

others are more descriptive

<math alt="K a can be written as a ratio of three terms. The numerator of the ratio holds the concentration of the deprotonated base N H 3, times that of the hydronium ion H 3 O +. The denominator holds the activity of the acid N H 4 +. Using the
definition for K a, K b equals K w divided by K A." >

A full list is attached.

The worry is we replace a verbose but accurate description of the mathematical formula with something which is more prone to the whims of editors.

It would be good to get some input from mathematicians who actually use screen readers.

We could add an if statement that uses the current representation unless the alt tag is specified. That is easy to implement.

@Lpd-Lbr Thank you for your bug report. This is the intended behavior of the Math extension. Thus it's not a bug but a feature request. I will take care of the handling of this feature request. Note, that it might take a few weeks until there is a decision if we implement the feature.

Sorry to comment on a two years stale issue, but: Is this saying that the feature never existed? Or it existed but it was intended that it was removed?

Asking because until recently (due to being on MW 1.19 until last year when they went to 1.33 and updated extensions like this), Fandom (Wikia) was using an older version of the math tag (AFAIK the same extension) where this behavior was definitely present and definitely worked exactly as the linked documentation suggests it should.

I know they aren't very full-featured screen readers but I can't get Narrator or TalkBack to attempt to read math images at all. (They read other images fine.)

We could add an if statement that uses the current representation unless the alt tag is specified. That is easy to implement.

... This is what I can offer. If anyone is interested, I can implement that.

Mediawiki is a complex software; the behavior may have changed even though the code in the math extension did not change. Forensic analysis and debate will take longer than adding the if statement, so I would rather want to avoid discussing the reason for the changed behavior.

How about concatination? When there is a alt text simply append the alt text and the latex equation.

Take this example from https://en.wikipedia.org/wiki/Engelbart%27s_law

<math alt="Change in CoDIAK = 1 plus A-level Activity">
CoDIAK_{t \to t+1} = 1 + \mathcal{B}
</math>

The alt text is not really enough to understand the equation. So we could simply do some like

<img src="..." alt="Change in CoDIAK = 1 plus A-level Activity: CoDIAK_{t \to t+1} = 1 + \mathcal{B}" />

This way we don't loose any information. Some may prefer the textual description, others might want the actual formula.

The example you linked currently renders to:

<span class="mwe-math-element"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;">
<math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle CIQ_{t}={\mathcal {A}}\left(1+{\mathcal {B}}\right)^{t}}">
  <semantics>
    <mrow class="MJX-TeXAtom-ORD">
      <mstyle scriptlevel="0" displaystyle="true">
        <mi>C</mi>
        <mi>I</mi>
        <msub>
          <mi>Q</mi>
          <mrow class="MJX-TeXAtom-ORD">
            <mi>t</mi>
          </mrow>
        </msub>
        <mo>=</mo>
        <mrow class="MJX-TeXAtom-ORD">
          <mrow class="MJX-TeXAtom-ORD">
            <mi class="MJX-tex-caligraphic" mathvariant="script">A</mi>
          </mrow>
        </mrow>
        <msup>
          <mrow>
            <mo>(</mo>
            <mrow>
              <mn>1</mn>
              <mo>+</mo>
              <mrow class="MJX-TeXAtom-ORD">
                <mrow class="MJX-TeXAtom-ORD">
                  <mi class="MJX-tex-caligraphic" mathvariant="script">B</mi>
                </mrow>
              </mrow>
            </mrow>
            <mo>)</mo>
          </mrow>
          <mrow class="MJX-TeXAtom-ORD">
            <mi>t</mi>
          </mrow>
        </msup>
      </mstyle>
    </mrow>
    <annotation encoding="application/x-tex">{\displaystyle CIQ_{t}={\mathcal {A}}\left(1+{\mathcal {B}}\right)^{t}}</annotation>
  </semantics>
</math></span><img src="https://wikimedia.org/api/rest_v1/media/math/render/svg/cc48941eb34494138ad31fd535f0fab17060704e" class="mwe-math-fallback-image-inline" aria-hidden="true" style="vertical-align: -0.838ex; width:18.786ex; height:3.176ex;" alt="CIQ_{t}={\mathcal  {A}}\left(1+{\mathcal  {B}}\right)^{t}"></span>

I think there are still quite some places where one can get the tex string from, i.e., annotation encoding="application/x-tex"
However, if you still want to have the tex in the alttext I am happy to implement that as well. See https://lists.w3.org/Archives/Public/www-math/2021Jul/0058.html for a recent discussion for math and screen readers.