Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow MathJax root to be configured. #1403 #1525

Merged
merged 1 commit into from
Jul 8, 2016
Merged

Conversation

dpvc
Copy link
Member

@dpvc dpvc commented Jun 14, 2016

Allow MathJax root to be configured. Resolves issue #1403.

The best way to set the root is to use

<script>
MathJax = {root:"http://myhost.net/mathjax"};
</script>
<script src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"></script>

so that the configuration file will be loaded from the correct location as well. Otherwise, you can use

<script type="text/x-mathjax-config">
MathJax.Hub.Config({
  root:"http://myhost.net/mathjax",
  config: ["TeX-AMS_HTML.js"]
});
</script>
<script src="http://cdn.mathjax.org/mathjax/latest/MathJax.js"></script>

@pkra pkra added this to the MathJax v2.x.x milestone Jun 15, 2016
}
}
return last;
return queue.Push(function () {MathJax.Ajax.config.root = MathJax.Hub.config.root});
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is Push synchronous, i.e., will there be a return value?

Copy link
Member Author

@dpvc dpvc Jul 6, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, the return value is the MathJax.Callback object created from the item pushed (Callbacks can be created from lots of possible data). The important point in returning the last callback pushed is that Callback objects are not only functions that can be called, but they also know how to work with MathJax.Callback.Queue objects; when a Callback is pushed on a Queue, the Queue will block until the Callback is called, and when it is, the next item in the Queue will start. But if a queued item returns another Callback, then the queue continues to pause until that callback is called, and so on.

So in this case, ConfigBlocks is itself pushed on a queue, and that queue will not continue until all the items that have been queued in queue in this routine are run, because the outer queue will have to wait for the Callback object returned by queue.Push(), and that only runs after everything else in queue has been run.

The MathJax.Callback was my attempt to do the job that now would be handled by promises, but that idea hadn't been developed (in javascript) at the time, and so the paradigm is a bit more awkward than it should be. It is one of the things that needs fixing in 3.0.

@zorkow
Copy link
Member

zorkow commented Jul 8, 2016

Thanks for the explanation.
lgtm.

@dpvc dpvc merged commit 0c52c28 into mathjax:develop Jul 8, 2016
@dpvc dpvc deleted the issue1403 branch July 8, 2016 12:58
edemaine added a commit to edemaine/coauthor that referenced this pull request Jul 9, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants