Skip to content
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

nbconvert to notebook doesn't respect line endings #1062

Open
jamesmyatt opened this issue Jul 8, 2019 · 7 comments · May be fixed by #2145
Open

nbconvert to notebook doesn't respect line endings #1062

jamesmyatt opened this issue Jul 8, 2019 · 7 comments · May be fixed by #2145
Labels
format:Notebook pertains to exporting to the Notebook format
Milestone

Comments

@jamesmyatt
Copy link

jamesmyatt commented Jul 8, 2019

On Windows, when I run

jupyter nbconvert --to notebook --execute --inplace "Untitled25.ipynb"

it uses CRLF line endings, but when when I open and save it directly via Jupyter notebook or Jupyterlab it always saves with LF line endings.

I think that the best solution would be to match the behaviour of Jupyter notebook, i.e. replace the line endings with LF. Alternatively, it should maintain the existing line endings, rather than (presumably) always using "native".

nbconvert 5.5.0, notebook 5.7.8, pandoc 2.7.3, juptyerlab 1.0.1

@t-makaro t-makaro added the format:Notebook pertains to exporting to the Notebook format label Aug 2, 2019
@mydmdm
Copy link

mydmdm commented Sep 3, 2019

same issue, I write a script to clear cell outputs before committing for security, but the command

jupyter nbconvert --ClearOutputPreprocessor.enabled=True --inplace

changes the line ending

@MSeal
Copy link
Contributor

MSeal commented Sep 4, 2019

If we change this behavior we should leave a flag to preserve system line-endings. I'd be ok with someone making that change so long as it could be opt-ed out of. There's sometimes system specific actions that complain when line-endings don't match the system but most modern windows applications and tools handle it smoothly now-a-days.

@mydmdm
Copy link

mydmdm commented Sep 5, 2019

Maybe a option flag to let user select line ending among

  • keep-as-it-is (the same to the source file)
  • auto (depends on the OS running the command)
  • LF
  • CRLF

Agreed that the default value of such flag would preserve the current behavior (now is auto?)

@MSeal
Copy link
Contributor

MSeal commented Sep 5, 2019

Yes. I believe it is auto atm. I'd also be ok changing the default to LF in the 6.x branch if we wanted as conforming to other notebook executions might be nice and the major change is easy to justify default changes.

@jamesmyatt
Copy link
Author

jamesmyatt commented Jun 8, 2020

The default should be the same as the Jupyter notebook or lab editors. It's a mistake that it's not the same and I can't imagine how anyone would be happy that the line endings change. I'm happy for it to be an option, but the default should be the one the creates the least issues. If no-one has raised this as an issue before, then it's probably because they're not looking.

Sorry to be a bit :grrr: but LF line endings on Windows hasn't been an issue for years, and especially not for anything or anyone that would consume an ipynb file.

@MSeal MSeal added this to the 6.0 milestone Jun 9, 2020
@MSeal
Copy link
Contributor

MSeal commented Jun 9, 2020

I added it to the 6.0 milestone -- could use some extra contributors helping get small issues like these moved across the finish line before the last major issues get resolved.

@auxym
Copy link

auxym commented Dec 13, 2021

Hi, any update on this? I'm running nbconvert 6.0.0 and still experiencing the issue. Is the fix included in a more recent version?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
format:Notebook pertains to exporting to the Notebook format
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants