Closed firezym closed 1 month ago
I'm not able to reproduce this using the same versions of nb-clean and nbformat, either using the Git filter or invoking nb-clean manually:
$ nb-clean check plotly-example-2.ipynb
plotly-example-2.ipynb cell 0: metadata
plotly-example-2.ipynb cell 0: execution count
plotly-example-2.ipynb cell 0: outputs
plotly-example-2.ipynb metadata: language_info.version
However, I'm on Linux whereas you're on Windows and there's a warning from Git that LF line endings will be replaced with CRLF line endings on checkout in your output. To see if the line ending conversion is involved, do you have the same error if you run nb-clean outside the Git filter (nb-clean check plotly-example-2.ipynb
)?
I can pass the $ nb-clean check plotly-example-2.ipynb
on windows powershell command line too, returning the same results as you.
But when I use $ git add plotly-example-2.ipynb
, I still get the same error showing above.
My CRLF setting in the git global config file C:\Users\Administrator\.gitconfig
is as following
[core]
autocrlf = input
Should I alter the autocrlf setting to something else?
According to this PR in another project, Jupyter notebooks are always created with LF line endings on Windows. That suggests adding the following to the .gitattributes
file in your repository (if you've not worked with the .gitattributes
file before, there's documentation on its purpose and the available options here):
*.ipynb text eol=lf
I'll assume configuring .gitattributes
worked: if you have any other trouble please open a new issue.
@srstevenson Thanks for this awesome repo. I am having some trouble cleaning notebooks with html/js inside. Below is the detailed error. Please kindly check it out :)
System :
Windows Server 2022 Datacenter 21H2 20348.2402
Core Packages :
jupyterlab >= 4.0.10 nbformat 5.9.2 nb-clean 3.2.0 plotly 5.18.0
Core Commands :
It works well on notebooks without plotly. But getting error from this notebook with plotly's html js snippets in it. plotly-example-2.zip
Error :
I checked the json format. It happens on line 29 which is the beginning of a chunk of js snippet having confusing "" in it.
Can not reproduce using nbformat directly in python:
When I use nbformat to load, such error will not happen. It seems fine to get the whole html content in
notebook['cells'][0]['outputs'][0]['data']['text/html']
.