Repository: sphinx-doc/sphinx

Issue:
Use latest mathjax version by default
The current `sphinx.ext.mathjax` plugin uses mathjax version 2.7.1, see
https://github.com/sphinx-doc/sphinx/blob/c2fcb82221d4b6b2b57bc8cd01954eda239ad7e8/sphinx/ext/mathjax.py#L108

This version is not the most current one, and is known to have problems with accents in Safari (https://github.com/mathjax/MathJax/issues/1737) and on iOS (https://github.com/mathjax/MathJax/issues/2091).

I would advocate switching to `https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/latest.js` as the default `mathjax_path` (as recommended by http://docs.mathjax.org/en/latest/configuration.html). Anyone who needs to pin a specific version can still set that version in their `conf.py`, but for most people, using "latest" will probably cause the least problems.

Discussion:

Patch:
diff --git a/CHANGES b/CHANGES
index 6f7367919..e047f7f63 100644
--- a/CHANGES
+++ b/CHANGES
@@ -16,6 +16,7 @@ Features added
 Bugs fixed
 ----------
 
+* #5725: mathjax: Use CDN URL for "latest" version by default
 * #5460: html search does not work with some 3rd party themes
 * #5520: LaTeX, caption package incompatibility since Sphinx 1.6
 * #5614: autodoc: incremental build is broken when builtin modules are imported
diff --git a/sphinx/ext/mathjax.py b/sphinx/ext/mathjax.py
index 21406c451..2a9f37699 100644
--- a/sphinx/ext/mathjax.py
+++ b/sphinx/ext/mathjax.py
@@ -98,7 +98,7 @@ def setup(app):
     # 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.1/MathJax.js?'
+                         'https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/latest.js?'
                          'config=TeX-AMS-MML_HTMLorMML', 'html')
     app.add_config_value('mathjax_options', {}, 'html')
     app.add_config_value('mathjax_inline', [r'\(', r'\)'], 'html')


Test patch:
diff --git a/tests/test_ext_math.py b/tests/test_ext_math.py
index 5ccaa6047..796ed852c 100644
--- a/tests/test_ext_math.py
+++ b/tests/test_ext_math.py
@@ -97,7 +97,7 @@ def test_mathjax_options(app, status, warning):
 
     content = (app.outdir / 'index.html').text()
     assert ('<script async="async" integrity="sha384-0123456789" type="text/javascript" '
-            'src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?'
+            'src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/latest.js?'
             'config=TeX-AMS-MML_HTMLorMML"></script>' in content)