On Mon, Aug 16, 2010 at 12:21, David <dwarnol...@suddenlink.net> wrote: > All, > > It seems that MathJax (mathjax.org) is going to replace jsMath. It is > supported by the AMS, SIAM, and Design Science, among others. I am > particularly interested because it can generate MathML that can be > read by screen readers for the visually impaired. > > So, my question, can we get Sphinx to work with MathJax?
Coincidentally, this is exactly what I was working on today. Here is my contribution to Sphinx, I would be happy if it can be improved on and added to the core set of extensions. It should be a drop-in replacement for jsmath or pngmath; edit your conf.py file as described below to use it. Background ============== I took the Sphinx 'jsmath.py' extension under /sphinx/ext/jsmath.py and merely modified it, as appropriate, to make it work with MathJax, http://www.mathjax.org/resources/docs/?mathjax.html Installation =========== * The extension is available here: http://bitbucket.org/kevindunn/sphinx-extension-mathjax/src/tip/mathjax.py or available from here (easier to copy/paste or wget): http://connectmv.com/mathjax-extension/mathjax.py.txt * In your ``conf.py`` file, replace 'sphinx.ext.pngmath' or 'sphinx.ext.jsmath' with 'mathjax' * Ensure the directory containing the above "mathjax.py" file is in ``sys.path``. Configuration ================= Similar to the builtin jsmath Sphinx extension, you must specify the path to your webserver's ``MathJax.js`` file. In your ``conf.py`` file, please add a line, similar to: mathjax_path = '/MathJax/MathJax.js' which will be added to the <script> section of the Sphinx HTML output. To compare this extension to the 'pngmath' extension, please open these two links side-by-side: * Using pngmath: http://connectmv.com/mathjax-extension/with-pngmath.html * Using the new mathjax extension: http://connectmv.com/mathjax-extension/with-mathjax.html These two pages used the RST code from the Sphinx documentation (http://sphinx.pocoo.org/latest/ext/math.html). Please note, I can't explain the reason for the missing equation numbers in mathjax. Hope this extension helps. I will be rolling this out to my other websites shortly, so I can't claim it is "production-ready" just yet. Feedback welcome. Kevin Dunn Of interest: MathJax looks for any \( ... \) delimiters in the HTML code to denote in-line mathematics, while either \[ ... \] or $$ .... $$ denote display-style math. These are the default settings for MathJax. If you have configured your MathJax script to use other delimiters (http://www.mathjax.org/docs/options/tex2jax.html), then these two additional options must be set in your conf.py. You DO NOT need to set these if you use an "out-of-the-box" installation of MathJax. For example, you might have set the config settings MathJax.js to use "$" for in-line math and "$$" for display-style math. Then in your ``conf.py`` file you must set the same values: mathjax_inline = ['$', '$'] # default setting in mathjax.py is: [r'\(', r'\)'] mathjax_display = ['$$', '$$'] # default setting in mathjax.py is: [r'\[', r'\]'] > David Arnold > College of the Redwoods > Eureka, CA 95501 -- You received this message because you are subscribed to the Google Groups "sphinx-dev" group. To post to this group, send email to sphinx-...@googlegroups.com. To unsubscribe from this group, send email to sphinx-dev+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sphinx-dev?hl=en.