feat!: upgrade to mathjax v3
Description
Upgrades mathjax from version 2 to 3.2.1. MathJax v3 is a complete rewrite of MathJax with changes in its internal structure so it is not a drop in replacement to v2.
This PR implements the changes required to make use of v3 and still have the same functionality as before and hopefully without breaking anything.
Useful information to include:
- This will impact both learners and course authors.
- There are no changes in UI
Supporting information
-
Private-ref: BB-7992 - MathJax v2 to v3 upgrade document
Testing instructions
- Setup master devstack
- Start lms, cms and frontend-app-learning using
make {lms,cms,frontend-app-learning}-up. - Checkout this PR/branch and run
make {lms,cms}-static. - Restart lms and cms using
make {lms,cms}-restartto make sure new static files are served. - Visit studio on http://localhost:18010/
- Go to Network tab in console and search for
mathjaxto make sure that mathjax v3 is being loaded. - Go to demo course and create a new unit.
- Add a following components:
- Problem > numerical input
- Problem > advanced > Math expression input problem
- Text > Raw HTML: add
\[\mathbf{x}^{G} = \frac{1} {M}\sum^{3}_{i=1}m_i\mathbf{x}^{G}_i\]formulae in the text.
- In the problem blocks input field try adding some asciimath formulas, for example:
R_1*R_2/R_3,A*x^2 + sqrt(y). Make sure preview works as expected. - Go to unit with title
Mathematical Expressionsin second section and play with the input field. In this field you can also enter tex as it is directly converted by MathJax while numerical input problems use a python library calledcalcto parse the text first and they cannot parse tex. - Go to next section with title
Chemical Equations, play with the input field. - Publish the changes and click on
View Live Versionbutton and test above blocks again in LMS. - To test mathematical expressions in discussions, go to discussions tab and create a post. Add some text with math and tex formulas.
- Remember to escape backtick with
\, example:\`A*x^2 + sqrt(y)\` - Escape
\[and\(with additional\for tex commands, example:\\[A \cdot x^2 + \sqrt{y}\\],\\(A \cdot x^2 + \sqrt{y}\\)
- Remember to escape backtick with
- Repeat above tests with and without this PR changes, i.e. with MathJax v2 and v3.
Please let me know if we are using mathjax in some other components which we need to test.
Deadline
None
Other information
None
Thanks for the pull request, @navinkarkera! Please note that it may take us up to several weeks or months to complete a review and merge your PR.
Feel free to add as much of the following information to the ticket as you can:
- supporting documentation
- Open edX discussion forum threads
- timeline information ("this must be merged by XX date", and why that is)
- partner information ("this is a course on edx.org")
- any other information that can help Product understand the context for the PR
All technical communication about the code itself will be done via the GitHub pull request interface. As a reminder, our process documentation is here.
Please let us know once your PR is ready for our review and all tests are green.
@navinkarkera Great work on this! Mathjax2 is also used in frontend-app-library-authoring. Can you please take a look?
Mathjax2 is also used in frontend-app-library-authoring. Can you please take a look?
@CefBoud Although I don't know if it is in the scope, I can update it as it seems to be used in only once place.
Please see discussion re upgrade paths for MathML rendering not being simple in this earlier PR: https://github.com/openedx/edx-platform/pull/32418 If you'd like to implement a course-level Advanced Option (with at least MathJax v2.7.9 and 3.2.1), that'd be super.
@wittjeff Thanks for pointing me to the PR. About implementing course level advance option to support both v2 and v3, I'll come back with an update/answer soon.
Related discussion re Canvas use of MathJax: https://community.canvaslms.com/t5/Canvas-Question-Forum/Canvas-s-MathJax-Needs-An-Update/m-p/583189
I submitted a PR because I'm having some issues with MathJax on the edX platform.Let me know if there is anything I can do here
Hi @navinkarkera, I tried testing this recently with a more current version of edx-platform and could not get it to work. Is it still working on your environment?
@rayzhou-bit Thanks for testing it. I am currently occupied with another project and we haven't received any confirmation from the original stakeholders yet, but I hope to get back to this soon.