mathjax / MathJax-node

MathJax for Node
Apache License 2.0
614 stars 96 forks source link

Typeset not calling the callback function #438

Closed jvdoorn closed 5 years ago

jvdoorn commented 5 years ago

I have the following code (inside a vue-component):

const mathjax = require('mathjax-node')
// mathjax.start()

mathjax.typeset({
        math: 'E = mc^2',
        format: 'TeX',
        mml: true
}, function (result, data) {
        console.log('typeset finished')
        console.log(result)
        console.log(data)
})

It appears however that mathjax.typeset method is not being called at all (or taking ages to do so). Am I missing something here?

dpvc commented 5 years ago

I don't know vuejs, but a quick look act their website seems to indicate that it is for making web applications for use in a browser. MathJax-node is not intended for browser use, and can not be incorporated into browser applications. For that, you should just use MathJax itself directly.

When MathJax was first written, the web landscape was quite different, and there were no tools like webpack or requirejs, so MathJax includes its own loader to dynamically load its components. This means it doesn't play well with webpack, and you probably aren't getting all the pieces it needs incorporated into your application. Worse yet, MathJax-node relies on jsdom, which is a very heavy dependency, and one that would be completely unnecessary in a browser (jsdom is a Javascript implementation of the DOM).

We are in the end processes of a complete rewrite of MathJax for version 3, and this rewrite brings MathJax into a more modern design, one that can be webpacked, and that works the same on the server side with nodejs as in the browser. We are putting together the beta.4 release as we speak, and hope to have the official 3.0.0 release shortly thereafter. You might consider trying the beta.3 version that is available here, with node-based demos here. There are a number of important improvements in beta.4, so it may be easier to wait until that is out (later this week?).

In any case, I don't think the approach given above will work.

jvdoorn commented 5 years ago

Thank you for the response @dpvc, I fixed my issue by using mathjax-electron, not sure why I didn't use that in the first case anyway. It works now however so I'll close this issue.

dpvc commented 5 years ago

OK, glad you got it to work. Good luck with the project.