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

Move to MathJax 3. #7961

Merged
merged 9 commits into from Jul 24, 2020
Merged
8 changes: 6 additions & 2 deletions doc/usage/extensions/math.rst
Expand Up @@ -140,6 +140,10 @@ are built:
.. module:: sphinx.ext.mathjax
:synopsis: Render math using JavaScript via MathJax.

.. warning::
Version 4.0 changes the version of MathJax used to version 3. You may need to
to override ``mathjax_path`` or change your configuration options.
hameerabbasi marked this conversation as resolved.
Show resolved Hide resolved

.. versionadded:: 1.1

This extension puts math as-is into the HTML files. The JavaScript package
Expand All @@ -161,12 +165,12 @@ Sphinx but is set to automatically include it from a third-party site.
MathJax.

The default is the ``https://`` URL that loads the JS files from the
`cdnjs`__ Content Delivery Network. See the `MathJax Getting Started
`jsdelivr`__ Content Delivery Network. See the `MathJax Getting Started
page`__ for details. If you want MathJax to be available offline or
without including resources from a third-party site, you have to
download it and set this value to a different path.

__ https://cdnjs.com
__ https://www.jsdelivr.com/

__ https://docs.mathjax.org/en/latest/start.html

Expand Down
4 changes: 2 additions & 2 deletions sphinx/ext/mathjax.py
Expand Up @@ -96,8 +96,8 @@ def setup(app: Sphinx) -> Dict[str, Any]:
# more information for mathjax secure url is here:
# https://docs.mathjax.org/en/latest/start.html#secure-access-to-the-cdn
app.add_config_value('mathjax_path',
'https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.7/latest.js?'
'config=TeX-AMS-MML_HTMLorMML', 'html')
'https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js',
'html')
app.add_config_value('mathjax_options', {}, 'html')
app.add_config_value('mathjax_inline', [r'\(', r'\)'], 'html')
app.add_config_value('mathjax_display', [r'\[', r'\]'], 'html')
Expand Down
4 changes: 2 additions & 2 deletions tests/test_ext_math.py
Expand Up @@ -71,8 +71,8 @@ def test_mathjax_options(app, status, warning):

content = (app.outdir / 'index.html').read_text()
assert ('<script async="async" integrity="sha384-0123456789" '
'src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.7/latest.js?'
'config=TeX-AMS-MML_HTMLorMML"></script>' in content)
'src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js">'
'</script>' in content)


@pytest.mark.sphinx('html', testroot='ext-math',
Expand Down