Skip to content

Commit e8d0564

Browse files
committed
Reorder and rollback mathjax.
1 parent 70f6c31 commit e8d0564

2 files changed

Lines changed: 35 additions & 12 deletions

File tree

src/py/kaleido/_page_generator.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@
88
_logger = logistro.getLogger(__name__)
99

1010
DEFAULT_PLOTLY = "https://cdn.plot.ly/plotly-2.35.2.js"
11-
DEFAULT_MATHJAX = "https://cdn.jsdelivr.net/npm/mathjax@3.2.2/es5/tex-svg.js"
11+
DEFAULT_MATHJAX = (
12+
"https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js"
13+
"?config=TeX-AMS-MML_SVG"
14+
)
1215

1316
KJS_PATH = Path(__file__).resolve().parent / "vendor" / "kaleido_scopes.js"
1417

@@ -67,6 +70,12 @@ def __init__(self, *, plotly=None, mathjax=None, others=None, force_cdn=False):
6770
6871
"""
6972
self._scripts = []
73+
if mathjax is not False:
74+
if not mathjax:
75+
mathjax = DEFAULT_MATHJAX
76+
else:
77+
_ensure_path(mathjax)
78+
self._scripts.append(mathjax)
7079
if force_cdn:
7180
plotly = (DEFAULT_PLOTLY, "utf-8")
7281
elif not plotly:
@@ -97,12 +106,6 @@ def __init__(self, *, plotly=None, mathjax=None, others=None, force_cdn=False):
97106
plotly = (plotly, "utf-8")
98107
_logger.debug(f"Plotly script: {plotly}")
99108
self._scripts.append(plotly)
100-
if mathjax is not False:
101-
if not mathjax:
102-
mathjax = DEFAULT_MATHJAX
103-
else:
104-
_ensure_path(mathjax)
105-
self._scripts.append(mathjax)
106109
if others:
107110
for o in others:
108111
_ensure_path(o)

src/py/kaleido/vendor/index.html

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,36 @@
11
<!DOCTYPE html>
2+
3+
<!--
4+
THIS FILE IS AN EXAMPLE, IT IS GENERATED AUTOMATICALLY AT RUNTIME
5+
TO ENSURE FULLY UPDATED RESOURCES
6+
-->
7+
28
<html>
39
<head>
10+
<meta charset="utf-8" />
411
<title>Kaleido-fier</title>
12+
513
<script>
6-
window.PlotlyConfig = {MathJaxConfig: 'local'};
14+
// Plotly won't fetch MathJax; you'll provide it
15+
window.PlotlyConfig = { MathJaxConfig: 'local' };
716
</script>
17+
18+
<!-- Only your one tweak; preset handles TeX+AMS+SVG -->
819
<script type="text/x-mathjax-config">
9-
MathJax.Hub.Config({ "SVG": {blacker: 0 }});
20+
MathJax.Hub.Config({
21+
SVG: { blacker: 0 }
22+
});
1023
</script>
11-
<script src="https://cdn.plot.ly/plotly-2.35.3.min.js" charset="utf-8"></script>
12-
<script src="https://cdn.jsdelivr.net/npm/mathjax@3.2.2/es5/tex-svg.js"></script>
24+
25+
<!-- Preset loads TeX input, AMS, and SVG output -->
26+
<script src="/vendor/mathjax/2.7.5/MathJax.js?config=TeX-AMS_SVG"></script>
27+
28+
<!-- Plotly after MathJax (since we're in 'local' mode) -->
29+
<script src="https://cdn.plot.ly/plotly-2.35.3.min.js"></script>
30+
1331
<script src="./kaleido_scopes.js"></script>
1432
</head>
15-
<body style="{margin: 0; padding: 0;}"><img id="kaleido-image"></img></body>
33+
<body style="margin:0; padding:0;">
34+
<img id="kaleido-image" />
35+
</body>
1636
</html>

0 commit comments

Comments
 (0)