@sam and all interested in typing math in Discourse. I’ve updated the discourse-math plugin so that it uses MathJax V3, rather than the much slower and very outdated V2. As expected, the result is a much snappier user experience, while still maintaining the feature rich environment as compared to KaTeX.
I’d love to issue a pull request, if you think the results look good.
You can see it in action on my class Discourse site:
Most of the content on that site is private or unlisted. There should be several topics at the top in the MathJax V3 category that illustrate the ideas, though
You can examine the code for the plugin in this standalone discourse-mathjax plugin repo. The file that has the most modifications by far is the initializer.
You can also use that repo to install it on a standalone site right now. Just be sure to remove the old repo during installation. Thus, you’d modify the standard plugin install technique to look like this:
hooks:
after_code:
- exec:
cd: $home/plugins
cmd:
- rm -r discourse-math
- git clone https://github.com/discourse/docker_manager.git
- git clone https://github.com/mcmcclur/discourse-math.git
Comments
The most recent version of MathJax is actually 4.0.0. I chose to go with V3.2.2 for several reasons
- While V4 is certainly much faster than V2, it’s not quite as fast as V3.
- The user experience is a bit different in V4, particularly if the user clicks on the output.
- The 4.0.0 status makes me wonder how many bugs there might be.
Having said that, the API for V4 is identical to that of V3. It should be possible to upgrade later, by simply dropping the latest MathJax Repo in.
I had to make one small change in the locales/server.en.yml file. Of course, there are a ton more such files for various languages. My understanding is that those other files would be automatically translated later?
I really don’t use chat at all and haven’t tested it in that context.