Skip to content
Open
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
2 changes: 0 additions & 2 deletions src/js/src/plotly/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
13 changes: 2 additions & 11 deletions src/py/kaleido/_page_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -54,12 +51,6 @@ class PageGenerator:
<head>
<style id="head-style"></style>
<title>Kaleido-fier</title>
<script>
window.PlotlyConfig = {MathJaxConfig: 'local'}
</script>
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ "SVG": { blacker: 0 }})
</script>
"""
"""The header is the HTML that always goes at the top. Rarely needs changing."""

Expand Down
2 changes: 1 addition & 1 deletion src/py/kaleido/kaleido.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
72 changes: 35 additions & 37 deletions src/py/kaleido/vendor/kaleido_scopes.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
}
Expand Down
6 changes: 0 additions & 6 deletions src/py/tests/test_page_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,6 @@
<head>
<style id="head-style"></style>
<title>Kaleido-fier</title>
<script>
window.PlotlyConfig = {MathJaxConfig: 'local'}
</script>
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ "SVG": { blacker: 0 }})
</script>

</head>
<body style="{margin: 0; padding: 0;}"><img id="kaleido-image" /></body>
Expand Down
Loading