Skip to content

Skip SSML-containing data-semantic-* attributes in output wrapper#1432

Open
reteps wants to merge 1 commit intomathjax:developfrom
reteps:fix/skip-ssml-attributes
Open

Skip SSML-containing data-semantic-* attributes in output wrapper#1432
reteps wants to merge 1 commit intomathjax:developfrom
reteps:fix/skip-ssml-attributes

Conversation

@reteps
Copy link

@reteps reteps commented Feb 16, 2026

Problem

SRE enrichment adds these attributes containing raw SSML markup (with literal <, >, ") to MathML nodes. When handleAttributes() copies them to SVG output elements and the SVG is serialized, the unescaped < and > in attribute values produce invalid XML.
My understanding is that MathJax.startup.adaptor.outerHTML is still a valid API we can use.

This is a issue with webkit < 26.0 (https://developer.chrome.com/blog/escape-attributes, https://webkit.org/blog/17333/webkit-features-in-safari-26-0/).

Fix

Added attributes to skipAttributes so they are no longer copied from the internal MathML tree to the output DOM.

The speech system (WebWorker.setSpeechAttribute) already sets these attributes directly on output DOM nodes during speech generation. The explorer reads them from that path.

Disclosure

I root-caused this bug, and created this fix with Claude 4.6 Opus.

SRE enrichment adds data-semantic-speech, data-semantic-prefix,
data-semantic-postfix, and data-semantic-summary attributes containing
raw SSML markup to MathML nodes. When handleAttributes() copies these
to SVG output elements and the SVG is serialized via outerHTML (HTML
serialization), the unescaped < and > in SSML attribute values produce
invalid XML. This breaks usage where SVG output is loaded as a
data:image/svg+xml URI or written to .svg files.

These attributes are already set directly on output DOM nodes by the
speech system (WebWorker.setSpeechAttribute), so skipping them in
handleAttributes() has no effect on the explorer or speech output.
The plain-text equivalents (data-semantic-*-none) are unaffected.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant