Skip to content

Add mathjax config to unbold latex #274

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 20 commits into from
Mar 25, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/py/CHANGELOG.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ v1.0.0rc11
- Write mocker tool to parameterize opts in tests
- Crop page to pdf size
- Add type checks to user input for improved error messages
- Fix latex strings in PDF bolding
v1.0.0rc10
- Allow user to pass Figure-like dicts
- Fix bug by which calc fig rejected plotly figures
Expand Down
3 changes: 3 additions & 0 deletions src/py/kaleido/_page_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ class PageGenerator:
<script>
window.PlotlyConfig = {MathJaxConfig: 'local'}
</script>
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ "SVG": { blacker: 0 }})
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ndrezn just wondering if you knew anything about this Config option, its being recomendad for improving some rendering oddities in Kaleido

</script>
"""
"""The header is the HTML that always goes at the top. Rarely needs changing."""

Expand Down
5 changes: 4 additions & 1 deletion src/py/kaleido/vendor/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
<head>
<title>Kaleido-fier</title>
<script>
window.PlotlyConfig = {MathJaxConfig: 'local'}
window.PlotlyConfig = {MathJaxConfig: 'local'};
</script>
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ "SVG": {blacker: 0 }});
</script>
<script src="https://cdn.plot.ly/plotly-2.35.3.min.js" charset="utf-8"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/es5/tex-svg.js"></script>
Expand Down
39 changes: 27 additions & 12 deletions src/py/tests/test_page_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,19 @@
<style id="head-style"></style>
<title>Kaleido-fier</title>
<script>
window.PlotlyConfig = {MathJaxConfig: 'local'}
window\.PlotlyConfig = {MathJaxConfig: 'local'}
</script>
<script type="text/x-mathjax-config">
MathJax\.Hub\.Config\({ "SVG": { blacker: 0 }}\)
</script>

<script src="https://cdn.plot.ly/plotly-2.35.2.js" charset="utf-8"></script>
<script src="https://cdn.jsdelivr.net/npm/mathjax@3.2.2/es5/tex-svg.js"></script>
<script src="\S[^\n]*/kaleido_scopes.js"></script>
<script src="https://cdn\.plot\.ly/plotly-2\.35\.2\.js" charset="utf-8"></script>
<script src="https://cdn\.jsdelivr\.net/npm/mathjax@3\.2\.2/es5/tex-svg\.js"></script>
<script src="\S[^\n]*/kaleido_scopes\.js"></script>
</head>
<body style="{margin: 0; padding: 0;}"><img id="kaleido-image"><img></body>
</html>
""")
""") # noqa: E501 line too long

all_defaults_re = re.compile(r"""
<!DOCTYPE html>
Expand All @@ -39,6 +42,9 @@
<script>
window\.PlotlyConfig = {MathJaxConfig: 'local'}
</script>
<script type="text/x-mathjax-config">
MathJax\.Hub\.Config\({ "SVG": { blacker: 0 }}\)
</script>

<script src="\S[^\n]*/package_data/plotly\.min\.js" charset="utf-8"></script>
<script src="https://cdn\.jsdelivr\.net/npm/mathjax@3\.2\.2/es5/tex-svg\.js"></script>
Expand All @@ -55,12 +61,15 @@
<style id="head-style"></style>
<title>Kaleido-fier</title>
<script>
window.PlotlyConfig = {MathJaxConfig: 'local'}
window\.PlotlyConfig = {MathJaxConfig: 'local'}
</script>
<script type="text/x-mathjax-config">
MathJax\.Hub\.Config\({ "SVG": { blacker: 0 }}\)
</script>

<script src="file:///with_plot" charset="utf-8"></script>
<script src="https://cdn.jsdelivr.net/npm/mathjax@3.2.2/es5/tex-svg.js"></script>
<script src="\S[^\n]*/kaleido_scopes.js"></script>
<script src="https://cdn\.jsdelivr\.net/npm/mathjax@3\.2\.2/es5/tex-svg\.js"></script>
<script src="\S[^\n]*/kaleido_scopes\.js"></script>
</head>
<body style="{margin: 0; padding: 0;}"><img id="kaleido-image"><img></body>
</html>
Expand All @@ -73,11 +82,14 @@
<style id="head-style"></style>
<title>Kaleido-fier</title>
<script>
window.PlotlyConfig = {MathJaxConfig: 'local'}
window\.PlotlyConfig = {MathJaxConfig: 'local'}
</script>
<script type="text/x-mathjax-config">
MathJax\.Hub\.Config\({ "SVG": { blacker: 0 }}\)
</script>

<script src="file:///with_plot" charset="utf-8"></script>
<script src="\S[^\n]*/kaleido_scopes.js"></script>
<script src="\S[^\n]*/kaleido_scopes\.js"></script>
</head>
<body style="{margin: 0; padding: 0;}"><img id="kaleido-image"><img></body>
</html>
Expand All @@ -90,14 +102,17 @@
<style id="head-style"></style>
<title>Kaleido-fier</title>
<script>
window.PlotlyConfig = {MathJaxConfig: 'local'}
window\.PlotlyConfig = {MathJaxConfig: 'local'}
</script>
<script type="text/x-mathjax-config">
MathJax\.Hub\.Config\({ "SVG": { blacker: 0 }}\)
</script>

<script src="file:///with_plot" charset="utf-8"></script>
<script src="file:///with_mathjax"></script>
<script src="1"></script>
<script src="2"></script>
<script src="\S[^\n]*/kaleido_scopes.js"></script>
<script src="\S[^\n]*/kaleido_scopes\.js"></script>
</head>
<body style="{margin: 0; padding: 0;}"><img id="kaleido-image"><img></body>
</html>
Expand Down