edx-platform icon indicating copy to clipboard operation
edx-platform copied to clipboard

feat!: upgrade to mathjax v3

Open navinkarkera opened this issue 2 years ago • 9 comments

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

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}-restart to make sure new static files are served.
  • Visit studio on http://localhost:18010/
  • Go to Network tab in console and search for mathjax to 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 Expressions in 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 called calc to 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 Version button 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}\\)
  • 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

navinkarkera avatar Oct 22 '23 09:10 navinkarkera

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.

openedx-webhooks avatar Oct 22 '23 09:10 openedx-webhooks

@navinkarkera Great work on this! Mathjax2 is also used in frontend-app-library-authoring. Can you please take a look?

CefBoud avatar Oct 26 '23 14:10 CefBoud

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.

navinkarkera avatar Oct 26 '23 15:10 navinkarkera

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 avatar Nov 07 '23 17:11 wittjeff

@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.

navinkarkera avatar Nov 08 '23 05:11 navinkarkera

Related discussion re Canvas use of MathJax: https://community.canvaslms.com/t5/Canvas-Question-Forum/Canvas-s-MathJax-Needs-An-Update/m-p/583189

wittjeff avatar Nov 08 '23 18:11 wittjeff

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

Yagnesh1998 avatar Nov 09 '23 10:11 Yagnesh1998

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 avatar Jan 22 '24 18:01 rayzhou-bit

@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.

navinkarkera avatar Feb 02 '24 15:02 navinkarkera