Mathjax support in github using a Chrome browser plugin?

怎甘沉沦 提交于 2019-12-18 13:23:29

问题


I'd like Mathjax to work on all my github pages (e.g., Markdown displayed on github, issue trackers). I have a lot of files generated from R Markdown that also have equations.

While I'd love github to provide optional support for Mathjax, I thought a more realistic aim would be to have some browser plugin that detects that I'm on a github page and automatically runs the mathjax script.

  • Are there any browser plugins for the Chrome browser that automatically run a MathJaX script on specified URLs (e.g., http*github*)?

Initial thoughts

There's quite a long discussion on MathOverflow. However, the discussion includes discussion of a range of technologies (not just MathJax) and many of the solutions are specific to the Firefox browser.


回答1:


Here is a GreaseMonkey script that should do what you want: Run MathJax in Github. It should work in all the major browser (though some need plugins to run GreaseMonkey scripts; see the installation instructions for this question for details).

This script only loads MathJax on pages that contain TeX or MathML markup (it does a very simple test for that, which certainly could be made more sophisticated). Note that the default delimiters are \(...\) for in-line math and \[...\] or $$...$$ for displayed math. In particular, single-dollars aren't enable as math delimiters (since they occur too frequently in ordinary non-math text). If you wanted to enable single-dollar delimiters, you would need to edit the script to add a MathJax configuration script prior to loading MathJax.js itself.

The script is set to trigger on http://github.com/* and https://github.com/*. Not all the GreaseMonkey implementations provide for pattern matching in the host part of the URL, but if yours does, you can make it more sophisticated so that it will get subdomains of github as well.

Hope that does what you need.

Edit: The script now enables $...$ for in-line math, as requested by the asker.



来源:https://stackoverflow.com/questions/11255900/mathjax-support-in-github-using-a-chrome-browser-plugin

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!