Upgrade MathJax support from v2/v3 to v3/v4#7898
Open
emilykl wants to merge 11 commits into
Open
Conversation
…cript to reference mathjax v3/v4 instead of v2/v3
…roach, and migrate to v3/v4
…t of render, make sure raw input text is hidden at end of MathJax render, start render chain with Promise.resolve()
656d638 to
9c0b33c
Compare
9c0b33c to
83bb307
Compare
emilykl
commented
Jul 10, 2026
|
|
||
| // Now that the MathJax render has finished, re-hide the source text. | ||
| // We hid it earlier, too, but since this callback runs async, | ||
| // another function may have made it visible again |
Contributor
Author
There was a problem hiding this comment.
add a TODO to investigate this further
camdecoster
reviewed
Jul 10, 2026
| // Strip $…$ delimiters and clean up escape charaters, | ||
| // then pass the result to MathDocument.convert() to get an SVG element back | ||
| const texMath = cleanEscapesForTex(_texString).replace(/^\$+|\$+$/g, ''); | ||
| return MathJax._.mathjax.mathjax.handleRetriesFor(function() { |
Contributor
There was a problem hiding this comment.
Why is this call to handleRetriesFor required?
|
|
||
| resetRenderer3(); | ||
| resetConfig3(); | ||
| // Initialize, render MathJax, then call _callback() |
Contributor
There was a problem hiding this comment.
Suggested change
| // Initialize, render MathJax, then call _callback() |
| MathJax.config.startup.output = 'svg'; | ||
| var tmpDiv; | ||
|
|
||
| const initiateMathJax = function() { |
Contributor
There was a problem hiding this comment.
Should this be an async function?
| @@ -0,0 +1 @@ | |||
| - Add support for MathJax v4, and **drop support for v2** [[#7898](https://github.com/plotly/plotly.js/pull/7898)] | |||
Contributor
There was a problem hiding this comment.
Suggested change
| - Add support for MathJax v4, and **drop support for v2** [[#7898](https://github.com/plotly/plotly.js/pull/7898)] | |
| - **Breaking:** Add support for MathJax v4, and **drop support for v2** [[#7898](https://github.com/plotly/plotly.js/pull/7898)] |
Contributor
There was a problem hiding this comment.
Do you now why the legend got smaller?
Contributor
There was a problem hiding this comment.
Is the MathJax specifier supposed to be showing up in the pie chart? Is this the fallback behavior?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Update plotly.js to be compatible with MathJax v4, and drop support for MathJax v2.
Due to some logic improvements, this should also make MathJax rendering faster.
svg_text_utils.jsto use MathJax v3/v4 syntax to render math symbolsMathJax.startup.defaultReady()on every individual render. This was very slow and also incorrect usage of the MathJax APIMathDocument.convert(tex)rather thanMathJax.typeset(tex)MathJax._.namespace. While not officially documented, the pattern is used in a few places in the MathJax documentation for advanced configurationSteps for testing
npm start) which uses MathJax 4mathjaxin the name (and the other baselines changed here) looks OK and matches the new baselines on this branchmathjaxmock itself contains several strings of TeX which don't render due to syntax errors; this is not new, and it's deliberate, to test the fallback behaviorhttp://localhost:3000/devtools/test_dashboard/index-mathjax3.html) and verify again that everything looks fine