Skip to content

Commit 4b0ab13

Browse files
committed
ensure having MathJax.Hub before set config for MathJax v2
1 parent 022a525 commit 4b0ab13

File tree

4 files changed

+9
-5
lines changed

4 files changed

+9
-5
lines changed

Diff for: packages/javascript/jupyterlab-plotly/src/Figure.ts

+6-2
Original file line numberDiff line numberDiff line change
@@ -826,9 +826,13 @@ export class FigureView extends DOMWidgetView {
826826
this.model.on("change:_py2js_update", this.do_update, this);
827827
this.model.on("change:_py2js_animate", this.do_animate, this);
828828

829-
// MathJax configuration
829+
// MathJax v2 configuration
830830
// ---------------------
831-
if ((window as any).MathJax) {
831+
if (
832+
(window as any).MathJax &&
833+
(window as any).MathJax.Hub &&
834+
(window as any).MathJax.Hub.Config
835+
) {
832836
(window as any).MathJax.Hub.Config({ SVG: { font: "STIX-Web" } });
833837
}
834838

Diff for: packages/python/plotly/plotly/io/_base_renderers.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ def __init__(self, width=None, height=None, scale=None, engine="auto"):
236236
window.PlotlyConfig = {MathJaxConfig: 'local'};"""
237237

238238
_mathjax_config = """\
239-
if (window.MathJax) {MathJax.Hub.Config({SVG: {font: "STIX-Web"}});}"""
239+
if (window.MathJax && window.MathJax.Hub && window.MathJax.Hub.Config) {window.MathJax.Hub.Config({SVG: {font: "STIX-Web"}});}"""
240240

241241

242242
class HtmlRenderer(MimetypeRenderer):

Diff for: packages/python/plotly/plotly/io/_html.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
_mathjax_config = """\
2222
<script type="text/javascript">\
23-
if (window.MathJax) {MathJax.Hub.Config({SVG: {font: "STIX-Web"}});}\
23+
if (window.MathJax && window.MathJax.Hub && && window.MathJax.Hub.Config) {window.MathJax.Hub.Config({SVG: {font: "STIX-Web"}});}\
2424
</script>"""
2525

2626

Diff for: packages/python/plotly/plotly/offline/offline.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ def _get_jconfig(config=None):
190190

191191
_mathjax_config = """\
192192
<script type="text/javascript">\
193-
if (window.MathJax) {MathJax.Hub.Config({SVG: {font: "STIX-Web"}});}\
193+
if (window.MathJax && window.MathJax.Hub && window.MathJax.Hub.Config) {window.MathJax.Hub.Config({SVG: {font: "STIX-Web"}});}\
194194
</script>"""
195195

196196

0 commit comments

Comments
 (0)