nvda icon indicating copy to clipboard operation
nvda copied to clipboard

On web pages, <math> attrs are not being imported

Open NSoiffer opened this issue 3 years ago • 10 comments

For web pages, NVDA is not grabbing the attrs for the math tag. It does get them for the children. The code to get the MathML is in ia2Web.py. It gets the math element with

    node = self.IAccessibleObject.QueryInterface(ISimpleDOMNode)

and gets the children (with all of their attrs) with node.innerHTML. For some reason (historical?), it does try to grab a data-mathml attribute. It also sets a xml:lang attr.

All of this is in ia2Web.py:_get_mathMl. I think the solution is to change

	if self.language:
		attrs = ' xml:lang="%s"' % self.language
	else:
		attrs = ""

to

	attrs = node.attributes(...)   # not sure of exact call args or values returned -- should be converted to a string
	if self.language:
		attrs += ' xml:lang="%s"' % self.language

Steps to reproduce:

Visit the math expression in this codepen

Actual behavior:

None of the attrs are present on the math tag. In particular, subject is missing.

Expected behavior:

All of the attrs and their values should be present (xmlns='http://www.w3.org/1998/Math/MathML' and subject='None').

Why it matters

Most of the attributes don't affect speech or braille. However, the W3C Math Working Group is looking at ways authors can express their intent to help AT generate good speech. One such way is to include attributes on any of the MathML elements. This includes math. The two attributes currently being proposed for inclusion in MathML 4 are intent and subject. It is important that these attributes be on all the elements for improved spreech.

Typically, there aren't many attrs on the math tag, but if there is a concern about grabbing all of them, then just subject and intent could be queried with code similar to that use for data-mathml. Specifically:

	attrNames = (BSTR * 1)("subject")
	namespaceIds = (c_short * 1)(0)
	subject_attr = node.attributesForNames(1, attrNames, namespaceIds)

If subject_attr exists, it is added to attrs. The same thing could be done for intent.

System configuration

NVDA installed/portable/running from source:

NVDA version:

Windows version:

Name and version of other software in use when reproducing the issue:

Other information about your system:

Other questions

Does the issue still occur after restarting your computer?

Have you tried any other versions of NVDA? If so, please report their behaviors.

If NVDA add-ons are disabled, is your problem still occurring?

Does the issue still occur after you run the COM Registration Fixing Tool in NVDA's tools menu?

NSoiffer avatar May 17 '22 00:05 NSoiffer