diff --git a/devtools/test_dashboard/index-mathjax3chtml.html b/devtools/test_dashboard/index-mathjax3chtml.html index 795c5688703..75561236224 100644 --- a/devtools/test_dashboard/index-mathjax3chtml.html +++ b/devtools/test_dashboard/index-mathjax3chtml.html @@ -49,12 +49,7 @@ options.format = svgDocument.inputJax[0].name; return svgDocument.convert(math, options); }; - /* - MathJax.tex2svgPromise = (math, options = {}) => { - options.format = svgDocument.inputJax[0].name; - return mathjax.handleRetriesFor(() => svgDocument.convert(math, options)); - }; - */ + MathJax.svgStylesheet = () => svgOutput.styleSheet(svgDocument); } } diff --git a/devtools/test_dashboard/index.html b/devtools/test_dashboard/index.html index de0841cc650..521077098c0 100644 --- a/devtools/test_dashboard/index.html +++ b/devtools/test_dashboard/index.html @@ -27,7 +27,7 @@ - + diff --git a/package-lock.json b/package-lock.json index 33b6740c070..f08cad23e78 100644 --- a/package-lock.json +++ b/package-lock.json @@ -54,8 +54,8 @@ }, "devDependencies": { "@biomejs/biome": "2.2.0", - "@plotly/mathjax-v2": "npm:mathjax@2.7.5", - "@plotly/mathjax-v3": "npm:mathjax@^3.2.2", + "@plotly/mathjax-v3": "npm:mathjax@3.2.2", + "@plotly/mathjax-v4": "npm:mathjax@^4.1.2", "@types/d3": "3.5.34", "@types/node": "^24.10.0", "amdefine": "^1.0.1", @@ -626,6 +626,13 @@ "resolved": "https://registry.npmjs.org/tinyqueue/-/tinyqueue-3.0.0.tgz", "integrity": "sha512-gRa9gwYU3ECmQYv3lslts5hxuIa90veaEcxDYuu3QGOIAEM2mOZkVHp48ANJuu1CURtRdHKUBY5Lm1tHV+sD4g==" }, + "node_modules/@mathjax/mathjax-newcm-font": { + "version": "4.1.3", + "resolved": "https://registry.npmjs.org/@mathjax/mathjax-newcm-font/-/mathjax-newcm-font-4.1.3.tgz", + "integrity": "sha512-gzAB3dFHilHX1l5x2xUqRL+1jDQt3Fyza1DkEMVXWC4E8SvsGdlgEza47HYi2WhVcgfkvf4zgUGzuhbq3Pjlew==", + "dev": true, + "license": "Apache-2.0" + }, "node_modules/@nodelib/fs.scandir": { "version": "2.1.5", "resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz", @@ -697,13 +704,6 @@ "elementary-circuits-directed-graph": "^1.0.4" } }, - "node_modules/@plotly/mathjax-v2": { - "name": "mathjax", - "version": "2.7.5", - "resolved": "https://registry.npmjs.org/mathjax/-/mathjax-2.7.5.tgz", - "integrity": "sha512-OzsJNitEHAJB3y4IIlPCAvS0yoXwYjlo2Y4kmm9KQzyIBZt2d8yKRalby3uTRNN4fZQiGL2iMXjpdP1u2Rq2DQ==", - "dev": true - }, "node_modules/@plotly/mathjax-v3": { "name": "mathjax", "version": "3.2.2", @@ -711,6 +711,17 @@ "integrity": "sha512-Bt+SSVU8eBG27zChVewOicYs7Xsdt40qm4+UpHyX7k0/O9NliPc+x77k1/FEsPsjKPZGJvtRZM1vO+geW0OhGw==", "dev": true }, + "node_modules/@plotly/mathjax-v4": { + "name": "mathjax", + "version": "4.1.3", + "resolved": "https://registry.npmjs.org/mathjax/-/mathjax-4.1.3.tgz", + "integrity": "sha512-BN/8Pkgn7G1pIDYJqd9md+JHsE/jydSYbyOZnSdSA0WziuVO8mRxdYiWFumkVVly/8U+hm9DpIIoWuvySverzw==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@mathjax/mathjax-newcm-font": "^4.1.3" + } + }, "node_modules/@plotly/point-cluster": { "version": "3.1.9", "resolved": "https://registry.npmjs.org/@plotly/point-cluster/-/point-cluster-3.1.9.tgz", diff --git a/package.json b/package.json index 5b3d9044e75..1d8f1c84352 100644 --- a/package.json +++ b/package.json @@ -115,8 +115,8 @@ }, "devDependencies": { "@biomejs/biome": "2.2.0", - "@plotly/mathjax-v2": "npm:mathjax@2.7.5", - "@plotly/mathjax-v3": "npm:mathjax@^3.2.2", + "@plotly/mathjax-v3": "npm:mathjax@3.2.2", + "@plotly/mathjax-v4": "npm:mathjax@^4.1.2", "@types/d3": "3.5.34", "@types/node": "^24.10.0", "amdefine": "^1.0.1", diff --git a/src/lib/svg_text_utils.js b/src/lib/svg_text_utils.js index d4bd953684b..379e5e5702c 100644 --- a/src/lib/svg_text_utils.js +++ b/src/lib/svg_text_utils.js @@ -74,11 +74,14 @@ exports.convertToTspans = function(_context, gd, _callback) { } if(tex) { - ((gd && gd._promises) || []).push(new Promise(function(resolve) { - _context.style('display', 'none'); - var fontSize = parseInt(_context.node().style.fontSize, 10); - var config = {fontSize: fontSize}; - + _context.style('display', 'none'); + var fontSize = parseInt(_context.node().style.fontSize, 10); + var config = {fontSize: fontSize}; + // capture the anchor now: the callback runs async, by which point a + // positioning pass may have changed text-anchor and would mis-place the svg + var textAnchor = _context.attr('text-anchor'); + + ((gd && gd._promises) || []).push( texToSVG(tex[2], config, function(_svgEl, _glyphDefs, _svgBBox) { parent.selectAll('svg.' + svgClass).remove(); parent.selectAll('g.' + svgClass + '-group').remove(); @@ -86,10 +89,14 @@ exports.convertToTspans = function(_context, gd, _callback) { var newSvg = _svgEl && _svgEl.select('svg'); if(!newSvg || !newSvg.node()) { showText(); - resolve(); return; } + // Re-hide the source text. It should already be hidden, but it's possible + // another code path has made it visible again before the async render finishes, + // so we hide it again here now that the MathJax has actually been rendered + _context.style('display', 'none'); + var mathjaxGroup = parent.append('g') .classed(svgClass + '-group', true) .attr({ @@ -151,11 +158,9 @@ exports.convertToTspans = function(_context, gd, _callback) { x = 0; y = dy; } else { - var anchor = _context.attr('text-anchor'); - x = x - w * ( - anchor === 'middle' ? 0.5 : - anchor === 'end' ? 1 : 0 + textAnchor === 'middle' ? 0.5 : + textAnchor === 'end' ? 1 : 0 ); y = y + dy - h / 2; } @@ -166,9 +171,8 @@ exports.convertToTspans = function(_context, gd, _callback) { }); if(_callback) _callback.call(_context, mathjaxGroup); - resolve(mathjaxGroup); - }); - })); + }) + ); } else showText(); return _context; @@ -187,68 +191,73 @@ function cleanEscapesForTex(s) { var inlineMath = [['$', '$'], ['\\(', '\\)']]; -function texToSVG(_texString, _config, _callback) { - var MathJaxVersion = parseInt( - (MathJax.version || '').split('.')[0] - ); - - if( - MathJaxVersion !== 2 && - MathJaxVersion !== 3 - ) { - Lib.warn('No MathJax version:', MathJax.version); - return; - } - - var originalRenderer, - originalConfig, - originalProcessSectionDelay, - tmpDiv; +// Configure MathJax, then build its startup document by calling MathJax.startup.defaultReady(). +// Once the startup document is built, we can reset the config immediately, +// and reuse the same document for all render calls. +var mathjaxReadyPromise = null; - var setConfig2 = function() { - originalConfig = Lib.extendDeepAll({}, MathJax.Hub.config); +// Verify that the MathJax output is set to SVG +function mathjaxOutputIsSvg() { + var doc = MathJax.startup && MathJax.startup.document; + return !!(doc && doc.outputJax && doc.outputJax.name === 'SVG'); +} - originalProcessSectionDelay = MathJax.Hub.processSectionDelay; - if(MathJax.Hub.processSectionDelay !== undefined) { - // MathJax 2.5+ but not 3+ - MathJax.Hub.processSectionDelay = 0; +function ensureMathJax(MathJaxVersion) { + if(mathjaxReadyPromise && mathjaxOutputIsSvg()) return mathjaxReadyPromise; + + var config = MathJax.config; + var origTex = config.tex; + var origSvg = config.svg; + var origOutput = config.startup.output; + + try { + // Configure MathJax the way we need it for plotly + config.tex = Lib.extendFlat({}, origTex, {inlineMath: inlineMath}); + config.startup.output = 'svg'; + + // MathJax v4 enables automatic inline linebreaking by default, + // which breaks a lot of our layout assumptions. Disabling it + // gives behavior consistent with v3. + if(MathJaxVersion === 4) { + config.svg = Lib.extendFlat({}, origSvg, { + linebreaks: Lib.extendFlat({}, origSvg && origSvg.linebreaks, {inline: false}) + }); } - return MathJax.Hub.Config({ - messageStyle: 'none', - tex2jax: { - inlineMath: inlineMath - }, - displayAlign: 'left', - }); - }; + MathJax.startup.defaultReady(); + } finally { + // Reset the config to its original values + config.tex = origTex; + config.svg = origSvg; + config.startup.output = origOutput; + } - var setConfig3 = function() { - originalConfig = Lib.extendDeepAll({}, MathJax.config); + mathjaxReadyPromise = MathJax.startup.promise; + return mathjaxReadyPromise; +} - if(!MathJax.config.tex) { - MathJax.config.tex = {}; - } +function texToSVG(_texString, _config, _callback) { + const MathJaxVersion = parseInt( + (MathJax.version || '').split('.')[0] + ); - MathJax.config.tex.inlineMath = inlineMath; - }; + if( + MathJaxVersion !== 3 && + MathJaxVersion !== 4 + ) { + Lib.warn('Unsupported MathJax version:', MathJax.version); + _callback(); + return Promise.resolve(); + } - var setRenderer2 = function() { - originalRenderer = MathJax.Hub.config.menuSettings.renderer; - if(originalRenderer !== 'SVG') { - return MathJax.Hub.setRenderer('SVG'); - } - }; + return renderTex(_texString, _config, _callback, MathJaxVersion); +} - var setRenderer3 = function() { - originalRenderer = MathJax.config.startup.output; - if(originalRenderer !== 'svg') { - MathJax.config.startup.output = 'svg'; - } - }; +function renderTex(_texString, _config, _callback, MathJaxVersion) { + var tmpDiv; - var initiateMathJax = function() { - var randomID = 'math-output-' + Lib.randstr({}, 64); + const initiateMathJax = function() { + const randomID = 'math-output-' + Lib.randstr({}, 64); tmpDiv = d3.select('body').append('div') .attr({id: randomID}) .style({ @@ -258,81 +267,38 @@ function texToSVG(_texString, _config, _callback) { }) .text(cleanEscapesForTex(_texString)); - var tmpNode = tmpDiv.node(); + const tmpNode = tmpDiv.node(); - return MathJaxVersion === 2 ? - MathJax.Hub.Typeset(tmpNode) : - MathJax.typeset([tmpNode]); + return MathJax.typesetPromise([tmpNode]); }; - var finalizeMathJax = function() { - var sel = tmpDiv.select( - MathJaxVersion === 2 ? '.MathJax_SVG' : '.MathJax' - ); + const finalizeMathJax = function() { + const sel = tmpDiv.select('.MathJax'); - var node = !sel.empty() && tmpDiv.select('svg').node(); + const node = !sel.empty() && tmpDiv.select('svg').node(); if(!node) { Lib.log('There was an error in the tex syntax.', _texString); _callback(); } else { - var nodeBBox = node.getBoundingClientRect(); - var glyphDefs; - if(MathJaxVersion === 2) { - glyphDefs = d3.select('body').select('#MathJax_SVG_glyphs'); - } else { - glyphDefs = sel.select('defs'); - } + const nodeBBox = node.getBoundingClientRect(); + const glyphDefs = sel.select('defs'); _callback(sel, glyphDefs, nodeBBox); } tmpDiv.remove(); }; - var resetRenderer2 = function() { - if(originalRenderer !== 'SVG') { - return MathJax.Hub.setRenderer(originalRenderer); - } - }; - - var resetRenderer3 = function() { - if(originalRenderer !== 'svg') { - MathJax.config.startup.output = originalRenderer; - } - }; - - var resetConfig2 = function() { - if(originalProcessSectionDelay !== undefined) { - MathJax.Hub.processSectionDelay = originalProcessSectionDelay; - } - return MathJax.Hub.Config(originalConfig); - }; - - var resetConfig3 = function() { - MathJax.config = originalConfig; - }; - - if(MathJaxVersion === 2) { - MathJax.Hub.Queue( - setConfig2, - setRenderer2, - initiateMathJax, - finalizeMathJax, - resetRenderer2, - resetConfig2 - ); - } else if(MathJaxVersion === 3) { - setConfig3(); - setRenderer3(); - MathJax.startup.defaultReady(); - - MathJax.startup.promise.then(function() { - initiateMathJax(); - finalizeMathJax(); - - resetRenderer3(); - resetConfig3(); + // start from a resolved promise so a synchronous throw in ensureMathJax + // routes to the catch below instead of rejecting the gd._promises entry + return Promise.resolve() + .then(function() { return ensureMathJax(MathJaxVersion); }) + .then(initiateMathJax) + .then(finalizeMathJax) + .catch((err) => { + Lib.log('MathJax typesetting failed.', _texString, err); + if(tmpDiv) tmpDiv.remove(); + _callback(); }); - } } var TAG_STYLES = { diff --git a/src/plot_api/plot_config.js b/src/plot_api/plot_config.js index f8f293a95e3..28fbab70b21 100644 --- a/src/plot_api/plot_config.js +++ b/src/plot_api/plot_config.js @@ -27,7 +27,7 @@ var configAttributes = { dflt: true, description: [ 'Determines whether math should be typeset or not,', - 'when MathJax (either v2 or v3) is present on the page.' + 'when MathJax (either v3 or v4) is present on the page.' ].join(' ') }, diff --git a/src/plot_api/subroutines.js b/src/plot_api/subroutines.js index 7cb735ce338..666f3e7b6a5 100644 --- a/src/plot_api/subroutines.js +++ b/src/plot_api/subroutines.js @@ -684,7 +684,7 @@ exports.doLegend = function(gd) { }; exports.doTicksRelayout = function(gd) { - Axes.draw(gd, 'redraw'); + var drawPromise = Axes.draw(gd, 'redraw'); if(gd._fullLayout._hasOnlyLargeSploms) { Registry.subplotsRegistry.splom.updateGrid(gd); @@ -693,7 +693,9 @@ exports.doTicksRelayout = function(gd) { } exports.drawMainTitle(gd); - return Plots.previousPromises(gd); + return Promise.resolve(drawPromise).then(function() { + return Plots.previousPromises(gd); + }); }; exports.doModeBar = function(gd) { diff --git a/src/types/generated/schema.d.ts b/src/types/generated/schema.d.ts index 92fdc3e79d7..c7ed1fabf77 100644 --- a/src/types/generated/schema.d.ts +++ b/src/types/generated/schema.d.ts @@ -16375,7 +16375,7 @@ export interface ConfigBase { */ topojsonURL?: string; /** - * Determines whether math should be typeset or not, when MathJax (either v2 or v3) is present on the page. + * Determines whether math should be typeset or not, when MathJax (either v3 or v4) is present on the page. * @default true */ typesetMath?: boolean; diff --git a/test/image/baselines/legend_mathjax_title_and_items.png b/test/image/baselines/legend_mathjax_title_and_items.png index 0b3181e088d..ff1af32bde5 100644 Binary files a/test/image/baselines/legend_mathjax_title_and_items.png and b/test/image/baselines/legend_mathjax_title_and_items.png differ diff --git a/test/image/baselines/mathjax.png b/test/image/baselines/mathjax.png index dc454c412b8..22a6dc9c226 100644 Binary files a/test/image/baselines/mathjax.png and b/test/image/baselines/mathjax.png differ diff --git a/test/image/baselines/mathjax3___mathjax.png b/test/image/baselines/mathjax3___mathjax.png index d8c6aafc1ed..b3e3e6e8d4a 100644 Binary files a/test/image/baselines/mathjax3___mathjax.png and b/test/image/baselines/mathjax3___mathjax.png differ diff --git a/test/image/baselines/mathjax3___ternary-mathjax-title-place-subtitle.png b/test/image/baselines/mathjax3___ternary-mathjax-title-place-subtitle.png index 3d06239168e..5447c63f7e7 100644 Binary files a/test/image/baselines/mathjax3___ternary-mathjax-title-place-subtitle.png and b/test/image/baselines/mathjax3___ternary-mathjax-title-place-subtitle.png differ diff --git a/test/image/baselines/mathjax3___ternary-mathjax.png b/test/image/baselines/mathjax3___ternary-mathjax.png index a145da8021b..58f3b9302b7 100644 Binary files a/test/image/baselines/mathjax3___ternary-mathjax.png and b/test/image/baselines/mathjax3___ternary-mathjax.png differ diff --git a/test/image/baselines/parcats_grid_subplots.png b/test/image/baselines/parcats_grid_subplots.png index 0925b959212..27899d0ff86 100644 Binary files a/test/image/baselines/parcats_grid_subplots.png and b/test/image/baselines/parcats_grid_subplots.png differ diff --git a/test/image/baselines/table_latex_multitrace_scatter.png b/test/image/baselines/table_latex_multitrace_scatter.png index 973dba8886c..63054172192 100644 Binary files a/test/image/baselines/table_latex_multitrace_scatter.png and b/test/image/baselines/table_latex_multitrace_scatter.png differ diff --git a/test/image/baselines/table_plain_birds.png b/test/image/baselines/table_plain_birds.png index 37a4a5533a5..bfe81d92d95 100644 Binary files a/test/image/baselines/table_plain_birds.png and b/test/image/baselines/table_plain_birds.png differ diff --git a/test/image/baselines/table_wrapped_birds.png b/test/image/baselines/table_wrapped_birds.png index fc53fb898f5..b1d5edd261e 100644 Binary files a/test/image/baselines/table_wrapped_birds.png and b/test/image/baselines/table_wrapped_birds.png differ diff --git a/test/image/baselines/ternary-mathjax-title-place-subtitle.png b/test/image/baselines/ternary-mathjax-title-place-subtitle.png index 980a5beb679..c98ccb7c453 100644 Binary files a/test/image/baselines/ternary-mathjax-title-place-subtitle.png and b/test/image/baselines/ternary-mathjax-title-place-subtitle.png differ diff --git a/test/image/baselines/ternary-mathjax.png b/test/image/baselines/ternary-mathjax.png index 0eb463e26eb..2f30323640c 100644 Binary files a/test/image/baselines/ternary-mathjax.png and b/test/image/baselines/ternary-mathjax.png differ diff --git a/test/image/make_baseline.py b/test/image/make_baseline.py index 0c0934adc2c..8bce6c7e5ba 100644 --- a/test/image/make_baseline.py +++ b/test/image/make_baseline.py @@ -36,8 +36,6 @@ print("output to", dirOut) -mathjax_version = 2 -mathjax = None if "mathjax3" in sys.argv or "mathjax3=" in sys.argv: # until https://github.com/plotly/Kaleido/issues/124 is addressed # we are uanble to use local mathjax v3 installed in node_modules @@ -46,6 +44,11 @@ mathjax_version = 3 print("Kaleido using MathJax v3") +else: + mathjax_version = 4 + # Kaleido still defaults to MathJax v2, so we need to explicitly specify the path to MathJax v4 + mathjax = "https://cdn.jsdelivr.net/npm/mathjax@4.1.2/tex-svg.js" + print("Kaleido using MathJax v4") virtual_webgl_version = 0 # i.e. virtual-webgl is not used if "virtual-webgl" in sys.argv or "virtual-webgl=" in sys.argv: diff --git a/test/jasmine/bundle_tests/mathjax_config_test.js b/test/jasmine/bundle_tests/mathjax_config_test.js index 1d80b6ca933..9cc0e318a1f 100644 --- a/test/jasmine/bundle_tests/mathjax_config_test.js +++ b/test/jasmine/bundle_tests/mathjax_config_test.js @@ -16,20 +16,18 @@ describe('Test MathJax v' + mathjaxVersion + ' config test:', function() { beforeAll(function(done) { gd = createGraphDiv(); - if(mathjaxVersion === 3) { - window.MathJax = { - startup: { - output: 'chtml', - tex: { - inlineMath: [['|', '|']] - } + window.MathJax = { + startup: { + output: 'chtml', + tex: { + inlineMath: [['|', '|']] } - }; - } + } + }; - var src = mathjaxVersion === 3 ? + const src = mathjaxVersion === 3 ? '/base/node_modules/@plotly/mathjax-v3/es5/tex-svg.js' : - '/base/node_modules/@plotly/mathjax-v2/MathJax.js?config=TeX-AMS_SVG'; + '/base/node_modules/@plotly/mathjax-v4/tex-svg.js'; loadScript(src, done); }); @@ -37,25 +35,9 @@ describe('Test MathJax v' + mathjaxVersion + ' config test:', function() { afterAll(destroyGraphDiv); it('should maintain startup renderer & inlineMath after SVG rendering', function(done) { - if(mathjaxVersion === 2) { - window.MathJax.Hub.Config({ - tex2jax: { - inlineMath: [['|', '|']] - } - }); - - window.MathJax.Hub.setRenderer('CHTML'); - } - // before plot - if(mathjaxVersion === 3) { - expect(window.MathJax.config.startup.output).toEqual('chtml'); - expect(window.MathJax.config.startup.tex.inlineMath).toEqual([['|', '|']]); - } - if(mathjaxVersion === 2) { - expect(window.MathJax.Hub.config.menuSettings.renderer).toEqual(''); - expect(window.MathJax.Hub.config.tex2jax.inlineMath).toEqual([['|', '|']]); - } + expect(window.MathJax.config.startup.output).toEqual('chtml'); + expect(window.MathJax.config.startup.tex.inlineMath).toEqual([['|', '|']]); Plotly.newPlot(gd, { data: [{ @@ -69,19 +51,8 @@ describe('Test MathJax v' + mathjaxVersion + ' config test:', function() { }) .then(function() { // after plot - if(mathjaxVersion === 3) { - expect(window.MathJax.config.startup.output).toEqual('chtml'); - expect(window.MathJax.config.startup.tex.inlineMath).toEqual([['|', '|']]); - } - if(mathjaxVersion === 2) { - expect(window.MathJax.Hub.config.menuSettings.renderer).toEqual(''); - } - }) - .then(delay(1000)) // TODO: why we need this delay for mathjax v2 here? - .then(function() { - if(mathjaxVersion === 2) { - expect(window.MathJax.Hub.config.tex2jax.inlineMath).toEqual([['|', '|']]); - } + expect(window.MathJax.config.startup.output).toEqual('chtml'); + expect(window.MathJax.config.startup.tex.inlineMath).toEqual([['|', '|']]); }) .then(done, done.fail); }); diff --git a/test/jasmine/bundle_tests/mathjax_test.js b/test/jasmine/bundle_tests/mathjax_test.js index 4b5d03a4b4b..2602ff3818c 100644 --- a/test/jasmine/bundle_tests/mathjax_test.js +++ b/test/jasmine/bundle_tests/mathjax_test.js @@ -10,10 +10,13 @@ var mathjaxVersion = __karma__.config.mathjaxVersion; describe('Test MathJax v' + mathjaxVersion + ':', function() { beforeAll(function(done) { - var src = mathjaxVersion === 3 ? + const src = mathjaxVersion === 3 ? '/base/node_modules/@plotly/mathjax-v3/es5/tex-svg.js' : - '/base/node_modules/@plotly/mathjax-v2/MathJax.js?config=TeX-AMS-MML_SVG'; + '/base/node_modules/@plotly/mathjax-v4/tex-svg.js'; + // TODO: `?config=` is not needed for MathJax v3 and onward, + // should we adjust these tests? + // N.B. we have to load MathJax "dynamically" as Karma // does not undefined the MathJax's `?config=` parameter. // diff --git a/test/jasmine/karma.conf.js b/test/jasmine/karma.conf.js index c061ff818eb..c551b0ae97e 100644 --- a/test/jasmine/karma.conf.js +++ b/test/jasmine/karma.conf.js @@ -69,7 +69,7 @@ if (argv.info) { '', 'Other options:', ' - `--info`: show this info message', - ' - `--mathjax3`: to load mathjax v3 in relevant test', + ' - `--mathjax3`: to load mathjax v3 in relevant test (otherwise mathjax v4 is loaded)', ' - `--Chrome` (alias `--chrome`): run test in (our custom) Chrome browser', ' - `--Firefox` (alias `--FF`, `--firefox`): run test in (our custom) Firefox browser', ' - `--nowatch (dflt: `false`, `true` on CI)`: run karma w/o `autoWatch` / multiple run mode', @@ -128,8 +128,8 @@ if (isFullSuite) { var pathToCustomMatchers = path.join(__dirname, 'assets', 'custom_matchers.js'); var pathToTopojsonDist = path.join(__dirname, '..', '..', 'topojson', 'dist'); -var pathToMathJax2 = path.join(__dirname, '..', '..', 'node_modules', '@plotly/mathjax-v2'); var pathToMathJax3 = path.join(__dirname, '..', '..', 'node_modules', '@plotly/mathjax-v3'); +var pathToMathJax4 = path.join(__dirname, '..', '..', 'node_modules', '@plotly/mathjax-v4'); var pathToVirtualWebgl = path.join(__dirname, '..', '..', 'node_modules', 'virtual-webgl', 'src', 'virtual-webgl.js'); var reporters = []; @@ -200,10 +200,10 @@ func.defaultConfig = { // N.B. the rest of this field is filled below files: [ pathToCustomMatchers, - // available to fetch from /base/node_modules/@plotly/mathjax-v2/ + // available to fetch from /base/node_modules/@plotly/mathjax-v3/ // more info: http://karma-runner.github.io/3.0/config/files.html - { pattern: pathToMathJax2 + '/**', included: false, watched: false, served: true }, { pattern: pathToMathJax3 + '/**', included: false, watched: false, served: true }, + { pattern: pathToMathJax4 + '/**', included: false, watched: false, served: true }, { pattern: pathToTopojsonDist + '/**', included: false, watched: false, served: true } ], @@ -308,7 +308,7 @@ func.defaultConfig = { tagPrefix: '@', skipTags: isCI ? 'noCI' : null, - mathjaxVersion: argv.mathjax3 ? 3 : 2, + mathjaxVersion: argv.mathjax3 ? 3 : 4, // See https://jasmine.github.io/api/3.4/Configuration.html jasmine: { diff --git a/test/plot-schema.json b/test/plot-schema.json index f4286815758..6a22cc6a378 100644 --- a/test/plot-schema.json +++ b/test/plot-schema.json @@ -340,7 +340,7 @@ "valType": "string" }, "typesetMath": { - "description": "Determines whether math should be typeset or not, when MathJax (either v2 or v3) is present on the page.", + "description": "Determines whether math should be typeset or not, when MathJax (either v3 or v4) is present on the page.", "dflt": true, "valType": "boolean" },