jupyter-widgets / ipywidgets

Interactive Widgets for the Jupyter Notebook
https://ipywidgets.readthedocs.io
BSD 3-Clause "New" or "Revised" License
3.17k stars 949 forks source link

MathJax3 in Jupyterlab4 #3829

Open fleming79 opened 1 year ago

fleming79 commented 1 year ago

It looks like JupyterLab 4 switched to using MathJax3 (https://github.com/jupyterlab/jupyterlab/pull/13877).

Looking in the source for ipywidgets ipywidgets/packages/controls/src/utils.ts the function typeset hasn't been upgraded to work with MathJax3. source here and copied below.

export function typeset(element: HTMLElement, text?: string): void {
  if (text !== void 0) {
    element.textContent = text;
  }
  if ((window as any).MathJax !== void 0) {
    MathJax!.Hub!.Queue(['Typeset', MathJax.Hub, element]);
  }
}

The MathJax upgrade notes here explain that Mathjax.Hub has" been removed entirely" which results in an attribute error in the code snippet above Mathjax content is not empty.

The issue was observed in the package ipylab which subclasses a VBox to create new classes Panel and SplitPanel. The issue is reported here: https://github.com/jtpio/ipylab/issues/129#issuecomment-1696979893

fleming79 commented 1 year ago

See also the Label and HTMLMath widgets currently don't render correctly.

https://ipywidgets.readthedocs.io/en/stable/examples/Widget%20List.html#label https://ipywidgets.readthedocs.io/en/stable/examples/Widget%20List.html#html-math

image

mathcodemaster commented 1 year ago

Hello, i am struggling with for some time now, happy to see that someone identified the problem, i have no idea how i could contribute to fix such an issue, but i am here as a support! I am sure that helps everybody a lot. I was wondering if there is a possibility to switch back to mathjax2 in the meantime, but was not successful.

mathcodemaster commented 1 year ago

As i said, i probably cant contribute much do the solution, but i would be very happy if that gets fixed so what i found is the update manual from mathjax at: https://docs.mathjax.org/en/latest/upgrading/v2.html image

maybe that helps someone who knows how to read this ;)

mathcodemaster commented 5 months ago

hello there, i just wanted to ask in on the state of this issue. do i see it right that latex is not working for ipywidgets at the moment at all, since this bug is out there? i regularly check in on the ipywidgets documentation at

https://ipywidgets.readthedocs.io/en/8.1.3/examples/Widget%20Layout.html#latex

and it is still also broken there.

Is there any way of going around this?

fleming79 commented 5 months ago

I think it has been resolved by this PR, but as you say still doesn't render in the documentation. Have you tried with the latest version of jupyterlab_widgets?

pip install -U jupyterlab_widgets

image

mathcodemaster commented 5 months ago

Thanks for the reply i will have to try the newest version then!

vpicouet commented 2 months ago

It does not work on my end even after upgrading on python 3.12...: pip install -U jupyterlab_widgets pip install -U ipywidgets