Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
require('mathjax-full/js/util/asyncLoad/node.js');
require('mathjax-full/js/a11y/semantic-enrich.js');
const STATE = require('mathjax-full/js/core/MathItem.js').STATE;
//
// Remove the data-semantic-* attributes other than data-semantic-speech
//
function removeSemanticData(math) {
math.root.walkTree(node => {
const attributes = node.attributes.getAllAttributes();
delete attributes.xmlns; // some internal nodes get this attribute for some reason
for (const name of Object.keys(attributes)) {
if (name.substr(0, 14) === 'data-semantic-' && name !== 'data-semantic-speech') {
delete attributes[name];
}
}
});
}