Closed gcalmettes closed 4 years ago
Solved!
Found the parser.ParseArg
method that is what I needed in this case.
tex_fragments(parser, name, type) {
const def = parseAttributes(parser.GetBrackets(name))
const math = parser.ParseArg(name )
const node = parser.create('node', 'mrow', [math], def)
parser.Push(node)
}
I am trying to rewrite an old mathjax extension (adding Reveal.js specific capability to mathjax equations rendered into the slides) using the new API of Mathjax V3.
I am using the custom-tex-extension example as starting point.
The goal would be to be able to encapsulate part of an equation into its own DOM element on which specific classes have been added.
See the image below for an example: in this case, I am aiming at isolating the
\alpha + 4
part into its own DOM element for which I am adding adanger
class. What I get instead is on the right part.The problem I have is that right now, the part is correctly isolated, but the
\alpha + 4
part is not translated and only the raw text is rendered. This is not surprising since I am givingparser.create('text', text)
as child, but I was unable to find how to add the "transformed" nodes instead.A simplified version of the relevant code is given below.
Any guidance on how I could do this would be appreciated. Thanks a lot and great work on the V3!