jupyterlab-contrib / rise

RISE: "Live" Reveal.js JupyterLab Slideshow Extension
BSD 3-Clause "New" or "Revised" License
157 stars 16 forks source link

Inconsistent mathjax version #72

Open yangqian opened 5 months ago

yangqian commented 5 months ago

Description

rise hardcoded mathjax version to 2.7.7 in app.py while jupyterlab4 currently uses 3.2.2. This caused some font resources to be not loaded properly. (italic font, etc. missing which makes the latex code not render correctly.) Changing the mathjax verion to 3.2.2 seems to fix the issue. (side effect is yet to be seen).

Reproduce

markdown input latex $$x$$.

Expected behavior

x is italic

x is not italic

Context

Web Browser Output
Paste the output from your browser web console here.
fjhickernell commented 3 months ago

I am experiencing this problem. Please tell me how you changed the mathjax version. Thanks.

f0k commented 2 months ago

@yangqian Thanks a lot, it works! :tada:

@fjhickernell Figure out where your jupyterlab_rise is installed. The easiest way is to run:

python3 -c 'import jupyterlab_rise; print(jupyterlab_rise.__file__)'

This will print the location of its __init__.py file. Open the app.py file in the same directory and find the following part:

        # TODO Remove CDN usage.
        mathjax_url = self.settings.get(
            "mathjax_url",
            "https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.7/MathJax.js",
        )

Change the 2.7.7 to 3.2.2, save, and restart jupyter lab (if running). To figure out whether 3.2.2 is still the correct version, you can also look at schemas/@jupyterlab/mathjax-extension/package.json.orig underneath the jupyterlab_rise directory, it has a line saying "mathjax-full": "^3.2.2". (Note that modifying the installed app.py file is a hack; the canonical way would be to clone the repository, change the source code, and install from source, but then you need node.js.)

It actually looks like mathjax_url was a setting of the plugin, but it is not included in the plugin.json and can therefore not be customized. That would have avoided the need to change the source code.

The correct solution will be to either remove CDN usage (as indicated in the comment), or to introspect which mathjax version the mathjax-extension uses.