From 33adb16c8ee4ef8c4387dc31caf2a399d8ca15f8 Mon Sep 17 00:00:00 2001 From: Emily KL <4672118+emilykl@users.noreply.github.com> Date: Thu, 16 Jul 2026 15:00:43 -0400 Subject: [PATCH 1/2] change default MathJax URL to v3 rather than v2 (and associated changes) --- src/js/src/plotly/constants.js | 2 - src/py/kaleido/_page_generator.py | 13 +---- src/py/kaleido/kaleido.py | 2 +- src/py/kaleido/vendor/kaleido_scopes.js | 72 ++++++++++++------------- 4 files changed, 38 insertions(+), 51 deletions(-) diff --git a/src/js/src/plotly/constants.js b/src/js/src/plotly/constants.js index ab8a213d..2e0c323e 100644 --- a/src/js/src/plotly/constants.js +++ b/src/js/src/plotly/constants.js @@ -32,8 +32,6 @@ module.exports = { svg: /^data:image\/svg\+xml,/ }, - mathJaxConfigQuery: '?config=TeX-AMS-MML_SVG', - // time [in ms] after which printToPDF errors when image isn't loaded pdfPageLoadImgTimeout: 20000 } diff --git a/src/py/kaleido/_page_generator.py b/src/py/kaleido/_page_generator.py index f99ad5a4..34a0176b 100644 --- a/src/py/kaleido/_page_generator.py +++ b/src/py/kaleido/_page_generator.py @@ -17,11 +17,8 @@ _logger = logistro.getLogger(__name__) -DEFAULT_PLOTLY = "https://cdn.plot.ly/plotly-2.35.2.js" -DEFAULT_MATHJAX = ( - "https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js" - "?config=TeX-AMS-MML_SVG" -) +DEFAULT_PLOTLY = "https://cdn.plot.ly/plotly-3.7.0.js" +DEFAULT_MATHJAX = "https://cdnjs.cloudflare.com/ajax/libs/mathjax/3.2.2/es5/tex-svg.min.js" KJS_PATH = Path(__file__).resolve().parent / "vendor" / "kaleido_scopes.js" @@ -54,12 +51,6 @@ class PageGenerator: Kaleido-fier - - """ """The header is the HTML that always goes at the top. Rarely needs changing.""" diff --git a/src/py/kaleido/kaleido.py b/src/py/kaleido/kaleido.py index f0771f3c..74d0789c 100644 --- a/src/py/kaleido/kaleido.py +++ b/src/py/kaleido/kaleido.py @@ -143,7 +143,7 @@ def __init__( # noqa: PLR0913 mathjax (str | Path | Literal[False] | None, optional): A path or URL to a mathjax.js file. If False, mathjax is - disabled. Defaults to None- which means to use version 2.35 via + disabled. If not provided, Kaleido will use MathJax v3 via CDN. headers (dict[str, str] | None, optional): diff --git a/src/py/kaleido/vendor/kaleido_scopes.js b/src/py/kaleido/vendor/kaleido_scopes.js index 3ed4cbf8..490b2a07 100644 --- a/src/py/kaleido/vendor/kaleido_scopes.js +++ b/src/py/kaleido/vendor/kaleido_scopes.js @@ -37,41 +37,41 @@ module.exports = value => { }; },{}],3:[function(require,module,exports){ -'use strict'; - -/** - * Is this string all whitespace? - * This solution kind of makes my brain hurt, but it's significantly faster - * than !str.trim() or any other solution I could find. - * - * whitespace codes from: http://en.wikipedia.org/wiki/Whitespace_character - * and verified with: - * - * for(var i = 0; i < 65536; i++) { - * var s = String.fromCharCode(i); - * if(+s===0 && !s.trim()) console.log(i, s); - * } - * - * which counts a couple of these as *not* whitespace, but finds nothing else - * that *is* whitespace. Note that charCodeAt stops at 16 bits, but it appears - * that there are no whitespace characters above this, and code points above - * this do not map onto white space characters. - */ - -module.exports = function(str){ - var l = str.length, - a; - for(var i = 0; i < l; i++) { - a = str.charCodeAt(i); - if((a < 9 || a > 13) && (a !== 32) && (a !== 133) && (a !== 160) && - (a !== 5760) && (a !== 6158) && (a < 8192 || a > 8205) && - (a !== 8232) && (a !== 8233) && (a !== 8239) && (a !== 8287) && - (a !== 8288) && (a !== 12288) && (a !== 65279)) { - return false; - } - } - return true; -} +'use strict'; + +/** + * Is this string all whitespace? + * This solution kind of makes my brain hurt, but it's significantly faster + * than !str.trim() or any other solution I could find. + * + * whitespace codes from: http://en.wikipedia.org/wiki/Whitespace_character + * and verified with: + * + * for(var i = 0; i < 65536; i++) { + * var s = String.fromCharCode(i); + * if(+s===0 && !s.trim()) console.log(i, s); + * } + * + * which counts a couple of these as *not* whitespace, but finds nothing else + * that *is* whitespace. Note that charCodeAt stops at 16 bits, but it appears + * that there are no whitespace characters above this, and code points above + * this do not map onto white space characters. + */ + +module.exports = function(str){ + var l = str.length, + a; + for(var i = 0; i < l; i++) { + a = str.charCodeAt(i); + if((a < 9 || a > 13) && (a !== 32) && (a !== 133) && (a !== 160) && + (a !== 5760) && (a !== 6158) && (a < 8192 || a > 8205) && + (a !== 8232) && (a !== 8233) && (a !== 8239) && (a !== 8287) && + (a !== 8288) && (a !== 12288) && (a !== 65279)) { + return false; + } + } + return true; +} },{}],4:[function(require,module,exports){ // shim for using process in browser @@ -2638,8 +2638,6 @@ module.exports = { svg: /^data:image\/svg\+xml,/ }, - mathJaxConfigQuery: '?config=TeX-AMS-MML_SVG', - // time [in ms] after which printToPDF errors when image isn't loaded pdfPageLoadImgTimeout: 20000 } From c5fe7c10198b532a91c125a20e6face3645edeab Mon Sep 17 00:00:00 2001 From: Emily KL <4672118+emilykl@users.noreply.github.com> Date: Thu, 16 Jul 2026 15:09:51 -0400 Subject: [PATCH 2/2] update test --- src/py/tests/test_page_generator.py | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/py/tests/test_page_generator.py b/src/py/tests/test_page_generator.py index f5b7907e..b5a119db 100644 --- a/src/py/tests/test_page_generator.py +++ b/src/py/tests/test_page_generator.py @@ -25,12 +25,6 @@ Kaleido-fier - -