mathjax / MathJax-node

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

[API change] exports.start() can accept a callback to get the MathJax object #319

Closed beeplin closed 7 years ago

beeplin commented 7 years ago

In #318 we discussed how to access the MathJax object in mathjax-node. I suggest using the existing start() api to do this:

//  E.g.
//     mjAPI.start(function (MathJax) {
//       MathJax.Hub.Register.StartupHook('XXX Ready', function () {
//         // something you need to run when XXX is ready
//       }
//     });
//
exports.start = function (callback) {
  RestartMathJax();
  exports.typeset({}, function () {
    callback && callback(window.MathJax);
  });
}

Currently the start() API is merely used in practice, because the first typeset() already does its job. Therefore I think it may be a reasonable design to make use of start() to access the MathJax object.

pkra commented 7 years ago

Please make PRs based off develop (and to develop). Thanks!