I have this code that was working in MathJax version 3 with SymbolMap instead of TokenMap.
This is my full code after removing everything unnecessary. The `\p` makes text invisible until revealed by JavaScript. However, when I run my website, the "a"'s in MathJax is not invisible. Could you please tell me how I can fix this? Also "npm install mathjax-full" seems to install a previous version of MathJax, not MathJax4.0.
window.MathJax = Object.assign({
loader: {
load: [
'[tex]/color',
'[tex]/cancel',
'[tex]/unicode',
'[tex]/mathtools',
'[tex]/textcomp',
],
},
output:{
font:'mathjax-tex'
},
tex: {
inlineMath: [['$', '$'], ['\\(', '\\)']],
preFilters: [
({math}) => {
if (math.start.delim !== '\begin{align}') {
math.math = math.math.replace(/(\\begin|\\end){align}/g, '$1{aligned}');
}
}
],
packages: {
'[+]': ['bold-chars', 'color', 'cancel', 'unicode', 'mathtools', 'textcomp'],//
},
maxBuffer: 10 * 1024,
tags: 'ams',
macros: Object.assign({
//pause
p: ['\\class{invisible}{#1}',1],
})
},
startup: {
ready: () => {
const { MacroMap } = MathJax._.input.tex.TokenMap;//.SymbolMap
const { Configuration } = MathJax._.input.tex.Configuration;
const BaseMethods = MathJax._.input.tex.base.BaseMethods.default;
let map= {};
new MacroMap('bold-chars', {'a':`\\p{\\unicode{${'a'.charCodeAt(0)}}}}`}, BaseMethods);
Configuration.create('bold-chars', { handler: { character: ['bold-chars'] } });
MathJax.startup.defaultReady();
}
}
});
delete window.ExtraMacros;