Skip to content
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

No longer inject MathJax config by default #5514

Merged
merged 8 commits into from
Feb 19, 2021
Merged
Show file tree
Hide file tree
Changes from 4 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
3 changes: 0 additions & 3 deletions src/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@ require('native-promise-only');
// inject plot css
require('../build/plotcss');

// inject default MathJax config
require('./fonts/mathjax_config')();

// include registry module and expose register method
var Registry = require('./registry');
var register = exports.register = Registry.register;
Expand Down
21 changes: 0 additions & 21 deletions src/fonts/mathjax_config.js

This file was deleted.

12 changes: 0 additions & 12 deletions src/lib/svg_text_utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,27 +153,16 @@ function cleanEscapesForTex(s) {

function texToSVG(_texString, _config, _callback) {
var originalRenderer,
originalConfig,
originalProcessSectionDelay,
tmpDiv;

MathJax.Hub.Queue(
function() {
originalConfig = Lib.extendDeepAll({}, MathJax.Hub.config);

originalProcessSectionDelay = MathJax.Hub.processSectionDelay;
if(MathJax.Hub.processSectionDelay !== undefined) {
// MathJax 2.5+
MathJax.Hub.processSectionDelay = 0;
}

return MathJax.Hub.Config({
messageStyle: 'none',
tex2jax: {
inlineMath: [['$', '$'], ['\\(', '\\)']]
},
displayAlign: 'left',
});
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think we still want all of the code you removed from svg_text_utils - store the existing config, set our own, and replace the original config at the end. That way we get the config we want without interfering with anything the rest of the page might be doing.

},
function() {
// Get original renderer
Expand Down Expand Up @@ -213,7 +202,6 @@ function texToSVG(_texString, _config, _callback) {
if(originalProcessSectionDelay !== undefined) {
MathJax.Hub.processSectionDelay = originalProcessSectionDelay;
}
return MathJax.Hub.Config(originalConfig);
});
}

Expand Down
Binary file modified test/image/baselines/legend_mathjax_title_and_items.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/image/baselines/mathjax.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/image/baselines/parcats_grid_subplots.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/image/baselines/ternary-mathjax.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 7 additions & 7 deletions test/image/mocks/legend_mathjax_title_and_items.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"layout": {
"legend": {
"title": {
"text": "$\\varphi ={\\frac {1+{\\sqrt {5}}}{2}}=0.618$"
"text": "$$\\varphi ={\\frac {1+{\\sqrt {5}}}{2}}=0.618$$"
},
"orientation": "v",
"bordercolor": "gray",
Expand All @@ -20,32 +20,32 @@
},
"data": [
{
"name": "${\\frac {1}{2}}=0.5$",
"name": "$${\\frac {1}{2}}=0.5$$",
"x": [1, 2],
"y": [0.5, 0.5]
},
{
"name": "${\\frac {2}{3}}=0.6666$",
"name": "$${\\frac {2}{3}}=0.6666$$",
"x": [2, 3],
"y": [0.6666, 0.6666]
},
{
"name": "${\\frac {3}{5}}=0.6$",
"name": "$${\\frac {3}{5}}=0.6$$",
"x": [3, 5],
"y": [0.6, 0.6]
},
{
"name": "${\\frac {5}{8}}=0.6125$",
"name": "$${\\frac {5}{8}}=0.6125$$",
"x": [5, 8],
"y": [0.6125, 0.6125]
},
{
"name": "${\\frac {8}{13}}=0.6153$",
"name": "$${\\frac {8}{13}}=0.6153$$",
"x": [8, 13],
"y": [0.6153, 0.6153]
},
{
"name": "${\\frac {13}{21}}=0.619$",
"name": "$${\\frac {13}{21}}=0.619$$",
"x": [13, 21],
"y": [0.619, 0.619]
}]
Expand Down
26 changes: 13 additions & 13 deletions test/image/mocks/mathjax.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,18 @@
"y": [0, 1.414],
"text": ["Hx+yH", "H\\sqrt{2}H"],
"mode": "text+markers",
"name": "$E^2=m^2c^4+p^2c^2$"
"name": "$$E^2=m^2c^4+p^2c^2$$"
}, {
"x": [0, 1],
"y": [1.4, 0.1],
"text": ["H1.400 \\pm 0.023H", "H0.100 \\pm 0.002H"],
"textposition": "auto",
"type": "bar",
"name": "$x=\\frac{-b \\pm \\sqrt{b^2-4ac}}{2a}$"
"name": "$$x=\\frac{-b \\pm \\sqrt{b^2-4ac}}{2a}$$"
}, {
"type": "pie",
"values": [1, 9],
"labels": ["$\\frac{1}{10}=10\\%$", "$\\frac{9}{10}=90\\%$"],
"labels": ["$$\\frac{1}{10}=10\\%$$", "$$\\frac{9}{10}=90\\%$$"],
"textinfo": "label",
"domain": {"x": [0.3, 0.75], "y": [0.55, 1]}
}, {
Expand All @@ -26,25 +26,25 @@
"colorbar": {"title": {"text": "He^{i\\pi}=-1H"}, "y": 0.225, "len": 0.45}
}],
"layout": {
"yaxis":{"domain": [0, 0.45], "title": {"text": "$y=\\sin{2 \\theta}$"}},
"yaxis":{"domain": [0, 0.45], "title": {"text": "$$y=\\sin{2 \\theta}$$"}},
"xaxis":{
"domain": [0, 0.45],
"title": {"text": "$x=\\int_0^a a^2+1$"},
"title": {"text": "$$x=\\int_0^a a^2+1$$"},
"tickvals": [0, 1],
"ticktext": ["$\\frac{0}{100}$", "$\\frac{100}{100}$"]
"ticktext": ["$$\\frac{0}{100}$$", "$$\\frac{100}{100}$$"]
},
"xaxis2": {"domain": [0.85, 1], "anchor": "y2"},
"yaxis2": {
"domain": [0, 0.45],
"anchor": "x2",
"tickvals": [0, 1],
"ticktext": ["Ha+b+c+dH", "He+f+g+hH"],
"title": {"text": "$(||01\\rangle+|10\\rangle)/\\sqrt2$"}
"title": {"text": "$$(||01\\rangle+|10\\rangle)/\\sqrt2$$"}
},
"height":500,
"width":800,
"margin": {"r": 250},
"title": {"text": "$i\\hbar\\frac{d\\Psi}{dt}=-[V-\\frac{-\\hbar^2}{2m}\\nabla^2]\\Psi$"},
"title": {"text": "$$i\\hbar\\frac{d\\Psi}{dt}=-[V-\\frac{-\\hbar^2}{2m}\\nabla^2]\\Psi$$"},
"annotations":[
{
"text": "H is substituted for $<br>where we would like<br>math but do not yet<br>fully support it",
Expand All @@ -53,23 +53,23 @@
"showarrow": false
},
{
"text":"$(top,left)$","showarrow":false,"xref":"paper","yref":"paper",
"text":"$$(top,left)$$","showarrow":false,"xref":"paper","yref":"paper",
"xanchor":"left","yanchor":"top","x":0,"y":1,"textangle":10,
"bordercolor":"#0c0","borderpad":3,"bgcolor":"#dfd"
},
{
"text":"$(right,bottom)$","xref":"paper","yref":"paper",
"text":"$$(right,bottom)$$","xref":"paper","yref":"paper",
"xanchor":"right","yanchor":"bottom","x":0.2,"y":0.7,"ax":-20,"ay":-20,
"textangle":-30,"bordercolor":"#0c0","borderpad":3,"bgcolor":"#dfd",
"opacity":0.5
},
{"text":"$not-visible$", "visible": false},
{"text":"$$not-visible$$", "visible": false},
{
"text":"$^{29}Si$","x":0.7,"y":0.7,"showarrow":false,
"text":"$$^{29}Si$$","x":0.7,"y":0.7,"showarrow":false,
"xanchor":"right","yanchor":"top"
},
{
"text":"$^{17}O$","x":0.7,"y":0.7,"ax":15,"ay":-15,
"text":"$$^{17}O$$","x":0.7,"y":0.7,"ax":15,"ay":-15,
"xanchor":"left","yanchor":"bottom"
}
]
Expand Down
2 changes: 1 addition & 1 deletion test/image/mocks/parcats_grid_subplots.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
{"label": "Two",
"values": ["A", "B", "A", "B", "C", "C", "A", "B", "C"],
"categoryarray": ["A", "B", "C"],
"ticktext": ["$A^2$", "<b>Bold</b><br>and<br><i>Italic</i>", "<a href='http://www.google.com'>Link</a>"]
"ticktext": ["$$A^2$$", "<b>Bold</b><br>and<br><i>Italic</i>", "<a href='http://www.google.com'>Link</a>"]
},
{"label": "Three", "values": [11, 11, 11, 11, 11, 11, 11, 11, 11]}]
},
Expand Down
2 changes: 1 addition & 1 deletion test/image/mocks/table_plain_birds.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

"height": 30,

"values": [["<b>#</b>", ""], ["<b>Species</b>", ""], ["Latitude", "$\\phi °$"], ["Longitude", "$\\lambda °$"], ["Exposure", ""], ["Condition", "<i>Live / Dead</i>"], ["Date", "<i>yyyy-mm-dd</i>"]],
"values": [["<b>#</b>", ""], ["<b>Species</b>", ""], ["Latitude", "$$\\phi °$$"], ["Longitude", "$$\\lambda °$$"], ["Exposure", ""], ["Condition", "<i>Live / Dead</i>"], ["Date", "<i>yyyy-mm-dd</i>"]],

"align": ["right", "left", "right", "right", "left", "left", "left"],

Expand Down
2 changes: 1 addition & 1 deletion test/image/mocks/table_wrapped_birds.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

"height": 30,

"values": [["<b>#</b>", ""], ["<b>Species</b>", ""], ["Latitude", "$\\phi °$"], ["Longitude", "$\\lambda °$"], ["Exposure", ""], ["Condition", "<i>Live / Dead</i>"], ["Date", "<i>yyyy-mm-dd</i>"]],
"values": [["<b>#</b>", ""], ["<b>Species</b>", ""], ["Latitude", "$$\\phi °$$"], ["Longitude", "$$\\lambda °$$"], ["Exposure", ""], ["Condition", "<i>Live / Dead</i>"], ["Date", "<i>yyyy-mm-dd</i>"]],

"align": ["right", "left", "right", "right", "left", "left", "left"],

Expand Down
6 changes: 3 additions & 3 deletions test/image/mocks/ternary-mathjax.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,21 @@
"sum": 100,
"aaxis": {
"title": {
"text": "$A^2$"
"text": "$$A^2$$"
},
"showline": true,
"showgrid": true
},
"baxis": {
"title": {
"text": "$B^2$"
"text": "$$B^2$$"
},
"showline": true,
"showgrid": true
},
"caxis": {
"title": {
"text": "$C^2$"
"text": "$$C^2$$"
},
"showline": true,
"showgrid": true
Expand Down
16 changes: 8 additions & 8 deletions test/jasmine/bundle_tests/mathjax_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,17 @@ var destroyGraphDiv = require('../assets/destroy_graph_div');
describe('Test MathJax:', function() {
var mathJaxScriptTag;

// N.B. we have to load MathJax "dynamically" as Karam
// N.B. we used to have to load MathJax "dynamically" as Karam
// does not undefined the MathJax's `?config=` parameter.
//
// Eventually, it might be nice to move these tests in the "regular" test
// Now with the mathjax_config no longer needed,
// it might be nice to move these tests in the "regular" test
// suites, but to do that we'll need to find a way to remove MathJax from
// page without breaking things downstream.
beforeAll(function(done) {
mathJaxScriptTag = document.createElement('script');
mathJaxScriptTag.type = 'text/javascript';
mathJaxScriptTag.onload = function() {
require('@src/fonts/mathjax_config')();
done();
};
mathJaxScriptTag.onerror = function() {
Expand Down Expand Up @@ -73,12 +73,12 @@ describe('Test MathJax:', function() {
}

var longCats = ['aaaaaaaaa', 'bbbbbbbbb', 'cccccccc'];
var texTitle = '$f(x) = \\int_0^\\infty \\psi(t) dt$';
var texCats = ['$\\phi$', '$\\nabla \\cdot \\vec{F}$', '$\\frac{\\partial x}{\\partial y}$'];
var texTitle = '$$f(x) = \\int_0^\\infty \\psi(t) dt$$';
var texCats = ['$$\\phi$$', '$$\\nabla \\cdot \\vec{F}$$', '$$\\frac{\\partial x}{\\partial y}$$'];
var longTexCats = [
'$\\int_0^\\infty \\psi(t) dt$',
'$\\alpha \\int_0^\\infty \\eta(t) dt$',
'$\\int_0^\\infty \\zeta(t) dt$'
'$$\\int_0^\\infty \\psi(t) dt$$',
'$$\\alpha \\int_0^\\infty \\eta(t) dt$$',
'$$\\int_0^\\infty \\zeta(t) dt$$'
];

it('should scoot x-axis title below x-axis ticks', function(done) {
Expand Down