@@ -32,6 +32,7 @@ exports.convertToTspans = function(_context, gd, _callback) {
3232 var tex = ( ! _context . attr ( 'data-notex' ) ) &&
3333 gd && gd . _context . typesetMath &&
3434 ( typeof MathJax !== 'undefined' ) &&
35+ isMathJaxVersionSupported ( ) &&
3536 matchTex ( str ) ;
3637
3738 var parent = d3 . select ( _context . node ( ) . parentNode ) ;
@@ -204,18 +205,25 @@ function cleanEscapesForTex(s) {
204205// and reused for subsequent calls.
205206var mathjaxSVGDocument = null ;
206207
207- function texToSVG ( _texString , _config , _callback ) {
208- const MathJaxVersion = parseInt (
209- ( MathJax . version || '' ) . split ( '.' ) [ 0 ]
210- ) ;
208+ // plotly.js is only compatible with MathJax v3 and v4.
209+ const mathJaxMajorVersion = ( ) => parseInt ( ( MathJax . version || '' ) . split ( '.' ) [ 0 ] ) ;
211210
212- if (
213- MathJaxVersion !== 3 &&
214- MathJaxVersion !== 4
215- ) {
211+ // Only warn once per page
212+ var warnedUnsupportedMathJax = false ;
213+
214+ function isMathJaxVersionSupported ( ) {
215+ const version = mathJaxMajorVersion ( ) ;
216+ if ( version === 3 || version === 4 ) return true ;
217+
218+ if ( ! warnedUnsupportedMathJax ) {
219+ warnedUnsupportedMathJax = true ;
216220 Lib . warn ( 'Unsupported MathJax version:' , MathJax . version ) ;
217- return ;
218221 }
222+ return false ;
223+ }
224+
225+ function texToSVG ( _texString , _config , _callback ) {
226+ const MathJaxVersion = mathJaxMajorVersion ( ) ;
219227
220228 var tmpDiv ;
221229
0 commit comments