ipywidgets icon indicating copy to clipboard operation
ipywidgets copied to clipboard

MathJax3 in Jupyterlab4

Open fleming79 opened this issue 2 years ago • 7 comments
trafficstars

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 avatar Aug 29 '23 23:08 fleming79

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

fleming79 avatar Sep 05 '23 11:09 fleming79

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 avatar Oct 04 '23 06:10 mathcodemaster

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 avatar Oct 05 '23 06:10 mathcodemaster

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?

mathcodemaster avatar Jun 03 '24 11:06 mathcodemaster

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

fleming79 avatar Jun 04 '24 08:06 fleming79

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

mathcodemaster avatar Jun 14 '24 07:06 mathcodemaster