mathjax / MathJax

Beautiful and accessible math in all browsers
http://www.mathjax.org/
Apache License 2.0
10.02k stars 1.16k forks source link

Make AsciiMath work with Vite #3122

Open DanielJGeiger opened 8 months ago

DanielJGeiger commented 8 months ago

Issue Summary

Vite uses strict mode, so the usage of arguments.callee fails. Besides removing arguments.callee from the relevant JS files, Vite compatibility evidently requires slight changes to an additional AsciiMath JS file.

Steps to Reproduce:

See https://excalidraw-mcjzus0ve-excalidraw.vercel.app/ (source commit https://github.com/excalidraw/excalidraw/pull/6037/commits/27a8cda8fdf7e7bc4e0d44f27bfa11cee21fc1cd) for an example of https://github.com/mathjax/MathJax-src/pull/854 in use. In this deployment:

  1. Select "Math" in the toolbar.
  2. Type \(\alpha\) and press "Escape".
  3. Rendering fails with the browser console error "ReferenceError: MathJax is not defined", traced back to an AsciiMath JS file.

Technical Details:

I am configuring and loading MathJax via loadMathJax() in src/element/subtypes/mathjax/implementation.tsx.

Supporting Information:

dpvc commented 8 months ago

Currently, as you can see, the AsciiMath input jax has not been ported to a native v3 input jax, but instead loads the legacy v2 code and patches it in through some hacked shim code. The AsciiMath code needs to be ported to an actual v3 input jax so that the legacy v2 code can be dropped. This is one of the last remaining v2 pieces that needs to be moved to v3.

We are not planning to make changes to the legacy v2 code at this time, but appreciate the effort you have put into providing the changes you have made. I'm sure that will be useful to others who are having similar issues to yours.