Skip to content

Commit 0c1a50d

Browse files
committed
upgrade MathJax in html template from v2 to v3
1 parent 18842db commit 0c1a50d

3 files changed

Lines changed: 9 additions & 11 deletions

File tree

‎plotly/io/_html.py‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -280,12 +280,14 @@ def to_html(
280280
include_mathjax = include_mathjax.lower()
281281

282282
mathjax_template = """\
283-
<script src="{url}?config=TeX-AMS-MML_SVG"></script>"""
283+
<script src="{url}"></script>"""
284284

285285
if include_mathjax == "cdn":
286286
mathjax_script = (
287287
mathjax_template.format(
288-
url=("https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js")
288+
url=(
289+
"https://cdnjs.cloudflare.com/ajax/libs/mathjax/3.2.2/es5/tex-svg.min.js"
290+
)
289291
)
290292
+ _mathjax_config
291293
)

‎plotly/offline/offline.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ def _build_resize_script(plotdivid, plotly_root="Plotly"):
100100

101101

102102
def _build_mathjax_script(url):
103-
return '<script src="{url}?config=TeX-AMS-MML_SVG"></script>'.format(url=url)
103+
return '<script src="{url}"></script>'.format(url=url)
104104

105105

106106
def _get_jconfig(config=None):

‎tests/test_core/test_offline/test_offline.py‎

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,9 @@
4545
directory_script = '<script charset="utf-8" src="plotly.min.js"></script>'
4646

4747

48-
mathjax_cdn = "https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js"
48+
mathjax_cdn = "https://cdnjs.cloudflare.com/ajax/libs/mathjax/3.2.2/es5/tex-svg.min.js"
4949

50-
mathjax_config_str = "?config=TeX-AMS-MML_SVG"
51-
52-
mathjax_cdn_script = '<script src="{cdn}{config}"></script>'.format(
53-
cdn=mathjax_cdn, config=mathjax_config_str
54-
)
50+
mathjax_cdn_script = f'<script src="{mathjax_cdn}"></script>'
5551

5652
mathjax_font = "STIX-Web"
5753

@@ -369,7 +365,7 @@ def test_include_mathjax_path_html(self):
369365
self.assertIn(plotly_config_script, html)
370366
self.assertIn(PLOTLYJS, html)
371367
self.assertNotIn(mathjax_cdn_script, html)
372-
self.assertIn(other_cdn + mathjax_config_str, html)
368+
self.assertIn(other_cdn, html)
373369
self.assertIn(mathjax_font, html)
374370

375371
def test_include_mathjax_path_div(self):
@@ -379,7 +375,7 @@ def test_include_mathjax_path_div(self):
379375
self.assertIn(plotly_config_script, html)
380376
self.assertIn(PLOTLYJS, html)
381377
self.assertNotIn(mathjax_cdn_script, html)
382-
self.assertIn(other_cdn + mathjax_config_str, html)
378+
self.assertIn(other_cdn, html)
383379
self.assertIn(mathjax_font, html)
384380

385381
def test_auto_play(self):

0 commit comments

Comments
 (0)