Skip to content

Commit

Permalink
fix no speech when role="math" on a non-math element (#17327)
Browse files Browse the repository at this point in the history
This fixes #15058.

Summary of the issue:
When someone has something like

            <span role="math">
                <math>
                    <msqrt>
                        <mn>4</mn>
                    </msqrt>
                </math>
            </span>
The math is not spoken (nothing is spoken).

This construct happens in real life math (see #15058 for more details).

Description of user facing changes
Web content such as the above will now be spoken as if the span (or other elements) are not present. This is what should have always happened.

Description of development approach
The fix (which is a bit of a hueristic) is to look inside the span (or other element with role="math" and see if exactly one of the children is math. If so, then we recursively call the code to get the MathML for it.

If there isn't exactly one math element, we fall through and raise a LookupError (which is what happened before adding this check).
  • Loading branch information
NSoiffer authored Nov 14, 2024
1 parent 3705183 commit 32245d4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
9 changes: 8 additions & 1 deletion source/NVDAObjects/IAccessible/ia2Web.py
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,14 @@ def _get_mathMl(self):
attr = mathPres.insertLanguageIntoMath(attr, self.language)
return attr
if self.IA2Attributes.get("tag") != "math":
# This isn't MathML.
# Could be a <span> (etc) that has role = math -- check the child
# If there is a single <math> child, recurse on the assumption that is what was the intended math
mathObjs: list["NVDAObjects.NVDAObject"] = [
child for child in self.children if child.IA2Attributes.get("tag") == "math"
]
if len(mathObjs) == 1:
return mathObjs[0].mathMl
# This isn't MathML
raise LookupError
if self.language:
attrs = ' xml:lang="%s"' % self.language
Expand Down
2 changes: 2 additions & 0 deletions user_docs/en/changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ To use this feature, "allow NVDA to control the volume of other applications" mu

### Bug Fixes

* Math reading has been fixed for some web elements.
Specifically, MathML inside of span and other elements that have the attribute `role="math"`. (#15058)
* Native support for the Dot Pad tactile graphics device from Dot Inc as a multiline braille display. (#17007)
* Improvements when editing in Microsoft PowerPoint:
* Caret reporting no longer breaks when text contains wide characters, such as emoji. (#17006 , @LeonarddeR)
Expand Down

0 comments on commit 32245d4

Please sign in to comment.