Description
When both [tex]/tagformat and ui/safe extensions are enabled in MathJax v4, \eqref links cannot navigate to the target equation. The equation's DOM element loses its id attribute because the safe extension filters it out.
Steps to Reproduce
- Enable both
tagformat and ui/safe extensions:
window.MathJax = {
loader: {
load: ['ui/safe', '[tex]/tagformat']
},
tex: {
tags: 'ams',
packages: { '[+]': ['tagformat'] }
}
};
- Use
\label and \eqref in the document:
\begin{equation}
E = mc^2 \label{eq:einstein}
\end{equation}
See equation \eqref{eq:einstein}.
- Click the equation number generated by
\eqref
Expected Behavior
Clicking the \eqref link should scroll/jump to the target equation (same behavior as MathJax v3, or when ui/safe is disabled).
Actual Behavior
- The equation number (tag) displays correctly
- The
\eqref link is generated with href="#mjx-eqn:eq:einstein"
- But the target equation element has no
id attribute
- Clicking the link does nothing
Root Cause
tagformat extension generates IDs in the format mjx-eqn:label-name (contains colon :)
ui/safe extension's default idPattern in safe mode is /^mjx-[-a-zA-Z0-9_.]+$/ which does not include colon
- IDs with colons are silently stripped by the safe extension
Workaround
Customize idPattern to allow colons:
options: {
safeOptions: {
idPattern: /^mjx-[-a-zA-Z0-9_.:]+$/
}
}
Suggested Fix
Update the default idPattern in ui/safe to include colon, since tagformat is an official extension and its default ID format should work out-of-the-box with the safe extension.
Environment
- MathJax version: v4.1.2
- Browser: All browsers
I am loading MathJax via
<script src="https://cdn.jsdelivr.net/npm/mathjax@4/tex-mml-chtml.js"></script>
Description
When both
[tex]/tagformatandui/safeextensions are enabled in MathJax v4,\eqreflinks cannot navigate to the target equation. The equation's DOM element loses itsidattribute because the safe extension filters it out.Steps to Reproduce
tagformatandui/safeextensions:\labeland\eqrefin the document:\eqrefExpected Behavior
Clicking the
\eqreflink should scroll/jump to the target equation (same behavior as MathJax v3, or whenui/safeis disabled).Actual Behavior
\eqreflink is generated withhref="#mjx-eqn:eq:einstein"idattributeRoot Cause
tagformatextension generates IDs in the formatmjx-eqn:label-name(contains colon:)ui/safeextension's defaultidPatternin safe mode is/^mjx-[-a-zA-Z0-9_.]+$/which does not include colonWorkaround
Customize
idPatternto allow colons:Suggested Fix
Update the default
idPatterninui/safeto include colon, sincetagformatis an official extension and its default ID format should work out-of-the-box with the safe extension.Environment
I am loading MathJax via