mystmd icon indicating copy to clipboard operation
mystmd copied to clipboard

trouble with programatically injecting HTML with ipywidgets

Open parmentelat opened this issue 1 year ago • 3 comments

Hey

I'm facing an issue when porting the following page from jb1

specifically I have a IPython extension ipythontutor that streamlines the insertion of an iframe with pythontutor illustrating the Python code, by calling ipywidgets.HTML()

jb1 is able to do behave as expected and to produce an iframe (see below)

but when rendered by myst, I am getting an error message (see in context below) that says

a Jupyter kernel connection is required ... HTML(...)


trying to understand better I then added (the second half of the test notebook) a simple call to HTML() and that one goes through properly in myst, so I guess the next step would be to narrow this down a bit, but before I do I could really use a better understanding of why a kernel would be needed at all at read-time in this scenario ?!? particularly as jb1 behaves as expected

PS. after writing this I realize that in this specific instance maybe I could/should have used IPython.display.HTML instead; however I have a few other similar discrepancies as soon as ipywidgets are involved, so I guess this issue is still worth discussing, even if only from a more general standpoint

here's jb1 output

image

see also https://jupyterlab-examples.readthedocs.io/en/main/1-06-pythontutor-nb.html

and here's the output I get from `myst`

image

the code of the IPython magic

https://github.com/parmentelat/ipythontutor/blob/main/ipythontutor.py

parmentelat avatar May 31 '24 12:05 parmentelat