-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix joining of source
when source
is an array of strings
#186
Conversation
source
when source
is an array of strings
Jupyverse sends the cell source as-is, which also leads to extra newlines in JupyterLab. There is a fix in jupyter-server/jupyverse#354, but does it mean this issue is a JupyterLab frontend issue (not particularly an issue in jupyter-ydoc)? Meaning that JupyterLab should render the source correctly if in an array. |
JupyterLab uses the This means jupyter-server/jupyverse#354 would then not be necessary, as the frontend would handle reading an array of strings. |
But the issue also appears in non-collaborative mode. |
Because JupyterLab still instantiates a And uses shared interfaces exposes by |
I see, thanks. Then I think this PR is good to go. I'll also merge jupyter-server/jupyverse#354 to better align with jupyter-server. |
Thanks @jtpio! |
Thanks @davidbrochart for the review! Would it be possible to get this in a patch release? 🙏 |
Thanks! |
This should fix the issue noticed in jupyterlite/jupyterlite#1141 (comment).
As discussed in jupyterlite/jupyterlite#1141 (comment), loading notebooks which have cells with their
source
set to be a list of strings instead of a single string.Example notebook: https://github.com/jupyterlite/jupyterlite/blob/main/examples/pyodide/ipycanvas.ipynb
Example cell:
Which in JupyterLite renders as follows with extra line breaks:
Currently the server component in JupyterLite does not normalize the
source
to be a string. So it sends the array of strings to the frontend.This is not an issue in stock JupyterLab because the response from the Jupyter Server already normalizes the
source
to be a single string:This is likely because Jupyter Server uses
nbformat
to read the notebook: https://github.com/jupyter-server/jupyter_server/blob/3544deb53902cc02c9aa9d6513b3c30f1113896b/jupyter_server/services/contents/fileio.py#L264-L291And the
nbformat
documentation mentions the following in https://nbformat.readthedocs.io/en/latest/format_description.html#cell-types:nbformat
also joins the string with an empty string: https://github.com/jupyter/nbformat/blob/0a2942c8f77d33b43a327293c7a7596afcf4527d/nbformat/v4/rwbase.py#L38