Skip to content

Commit 245c2eb

Browse files
authored
Add mathjax config to unbold latex (#274)
* Add mathjax config to unbold latex * Add argument descriptions * Populate arguments * Update uv.lock * Set up parameterization * Set default log level properly * Add note to changelog * Set pdf to page size * Add CHANGELOG * Add type-checks for better user errors * Remove match-case for python<3.10 * Improve error verbosity * Remove layout check for is_figurish * Allow None-path * Fix attribute error in logging print * Update changelog
1 parent a0bbebc commit 245c2eb

File tree

4 files changed

+35
-13
lines changed

4 files changed

+35
-13
lines changed

src/py/CHANGELOG.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ v1.0.0rc11
22
- Write mocker tool to parameterize opts in tests
33
- Crop page to pdf size
44
- Add type checks to user input for improved error messages
5+
- Fix latex strings in PDF bolding
56
v1.0.0rc10
67
- Allow user to pass Figure-like dicts
78
- Fix bug by which calc fig rejected plotly figures

src/py/kaleido/_page_generator.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ class PageGenerator:
2626
<script>
2727
window.PlotlyConfig = {MathJaxConfig: 'local'}
2828
</script>
29+
<script type="text/x-mathjax-config">
30+
MathJax.Hub.Config({ "SVG": { blacker: 0 }})
31+
</script>
2932
"""
3033
"""The header is the HTML that always goes at the top. Rarely needs changing."""
3134

src/py/kaleido/vendor/index.html

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@
33
<head>
44
<title>Kaleido-fier</title>
55
<script>
6-
window.PlotlyConfig = {MathJaxConfig: 'local'}
6+
window.PlotlyConfig = {MathJaxConfig: 'local'};
7+
</script>
8+
<script type="text/x-mathjax-config">
9+
MathJax.Hub.Config({ "SVG": {blacker: 0 }});
710
</script>
811
<script src="https://cdn.plot.ly/plotly-2.35.3.min.js" charset="utf-8"></script>
912
<script src="https://cdn.jsdelivr.net/npm/[email protected]/es5/tex-svg.js"></script>

src/py/tests/test_page_generator.py

Lines changed: 27 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,19 @@
1919
<style id="head-style"></style>
2020
<title>Kaleido-fier</title>
2121
<script>
22-
window.PlotlyConfig = {MathJaxConfig: 'local'}
22+
window\.PlotlyConfig = {MathJaxConfig: 'local'}
23+
</script>
24+
<script type="text/x-mathjax-config">
25+
MathJax\.Hub\.Config\({ "SVG": { blacker: 0 }}\)
2326
</script>
2427
25-
<script src="https://cdn.plot.ly/plotly-2.35.2.js" charset="utf-8"></script>
26-
<script src="https://cdn.jsdelivr.net/npm/mathjax@3.2.2/es5/tex-svg.js"></script>
27-
<script src="\S[^\n]*/kaleido_scopes.js"></script>
28+
<script src="https://cdn\.plot\.ly/plotly-2\.35\.2\.js" charset="utf-8"></script>
29+
<script src="https://cdn\.jsdelivr\.net/npm/mathjax@3\.2\.2/es5/tex-svg\.js"></script>
30+
<script src="\S[^\n]*/kaleido_scopes\.js"></script>
2831
</head>
2932
<body style="{margin: 0; padding: 0;}"><img id="kaleido-image"><img></body>
3033
</html>
31-
""")
34+
""") # noqa: E501 line too long
3235

3336
all_defaults_re = re.compile(r"""
3437
<!DOCTYPE html>
@@ -39,6 +42,9 @@
3942
<script>
4043
window\.PlotlyConfig = {MathJaxConfig: 'local'}
4144
</script>
45+
<script type="text/x-mathjax-config">
46+
MathJax\.Hub\.Config\({ "SVG": { blacker: 0 }}\)
47+
</script>
4248
4349
<script src="\S[^\n]*/package_data/plotly\.min\.js" charset="utf-8"></script>
4450
<script src="https://cdn\.jsdelivr\.net/npm/mathjax@3\.2\.2/es5/tex-svg\.js"></script>
@@ -55,12 +61,15 @@
5561
<style id="head-style"></style>
5662
<title>Kaleido-fier</title>
5763
<script>
58-
window.PlotlyConfig = {MathJaxConfig: 'local'}
64+
window\.PlotlyConfig = {MathJaxConfig: 'local'}
65+
</script>
66+
<script type="text/x-mathjax-config">
67+
MathJax\.Hub\.Config\({ "SVG": { blacker: 0 }}\)
5968
</script>
6069
6170
<script src="file:///with_plot" charset="utf-8"></script>
62-
<script src="https://cdn.jsdelivr.net/npm/mathjax@3.2.2/es5/tex-svg.js"></script>
63-
<script src="\S[^\n]*/kaleido_scopes.js"></script>
71+
<script src="https://cdn\.jsdelivr\.net/npm/mathjax@3\.2\.2/es5/tex-svg\.js"></script>
72+
<script src="\S[^\n]*/kaleido_scopes\.js"></script>
6473
</head>
6574
<body style="{margin: 0; padding: 0;}"><img id="kaleido-image"><img></body>
6675
</html>
@@ -73,11 +82,14 @@
7382
<style id="head-style"></style>
7483
<title>Kaleido-fier</title>
7584
<script>
76-
window.PlotlyConfig = {MathJaxConfig: 'local'}
85+
window\.PlotlyConfig = {MathJaxConfig: 'local'}
86+
</script>
87+
<script type="text/x-mathjax-config">
88+
MathJax\.Hub\.Config\({ "SVG": { blacker: 0 }}\)
7789
</script>
7890
7991
<script src="file:///with_plot" charset="utf-8"></script>
80-
<script src="\S[^\n]*/kaleido_scopes.js"></script>
92+
<script src="\S[^\n]*/kaleido_scopes\.js"></script>
8193
</head>
8294
<body style="{margin: 0; padding: 0;}"><img id="kaleido-image"><img></body>
8395
</html>
@@ -90,14 +102,17 @@
90102
<style id="head-style"></style>
91103
<title>Kaleido-fier</title>
92104
<script>
93-
window.PlotlyConfig = {MathJaxConfig: 'local'}
105+
window\.PlotlyConfig = {MathJaxConfig: 'local'}
106+
</script>
107+
<script type="text/x-mathjax-config">
108+
MathJax\.Hub\.Config\({ "SVG": { blacker: 0 }}\)
94109
</script>
95110
96111
<script src="file:///with_plot" charset="utf-8"></script>
97112
<script src="file:///with_mathjax"></script>
98113
<script src="1"></script>
99114
<script src="2"></script>
100-
<script src="\S[^\n]*/kaleido_scopes.js"></script>
115+
<script src="\S[^\n]*/kaleido_scopes\.js"></script>
101116
</head>
102117
<body style="{margin: 0; padding: 0;}"><img id="kaleido-image"><img></body>
103118
</html>

0 commit comments

Comments
 (0)