mathjax / MathJax-node

MathJax for Node
Apache License 2.0
616 stars 97 forks source link

Cannot read property 'childNodes' of null #468

Closed joshua7v closed 3 years ago

joshua7v commented 3 years ago

Hi,

First of all, I'm not someone understand TeX well. and I ran into an issue which I have no idea why.

this specific snippet cannot be parsed, the error it throws: Cannot read property 'childNodes' of null which is not very useful, still don't know what happened.

however, if i use https://www.mathjax.org/#demo, everything works. I guess there must be somewhere different between mathjax-node and mathjax web

\begin{align}
\xrightarrow{\alpha}&\quad \tag{01}
\end{align}

another observation if I remove the & right before \quad, the error just dispears.

\begin{align}
\xrightarrow{\alpha}\quad \tag{01}
\end{align}

so, is this something expected? or its a bug?

pkra commented 3 years ago

"This specific snippet cannot be parsed" does not sound like a mathjax-node message.

In any case, the following works for me, e.g., try it on https://npm.runkit.com/mathjax-node

var mjAPI = require("mathjax-node");

mjAPI.typeset({
  math: ' \\begin{align} \\xrightarrow{\\alpha}&\\quad \\tag{01} \\end{align}',
  format: "TeX",
  svg:true,  
}, function (data) {console.log(data.svg)});
joshua7v commented 3 years ago

@pkra ok thanks for confirmation this snippet is actually a simplified version of something way more complex from our system. but yeah, after checking that TeX string very very carefully, mathjax-node actually can render it (after fixing some escape issues). and now I have to check upper layers of our processing pipeline since mathjax works great.

thanks

pkra commented 3 years ago

Thanks for confirming. Glad to hear you could work it out.