Skip to content

nbconvert to notebook doesn't respect line endings #1062

@jamesmyatt

Description

@jamesmyatt

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

Activity

mydmdm

mydmdm commented on Sep 3, 2019

@mydmdm

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

MSeal commented on Sep 4, 2019

@MSeal
Contributor

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

mydmdm commented on Sep 5, 2019

@mydmdm

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

MSeal commented on Sep 5, 2019

@MSeal
Contributor

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

jamesmyatt commented on Jun 8, 2020

@jamesmyatt
Author

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.

added this to the 6.0 milestone on Jun 9, 2020
MSeal

MSeal commented on Jun 9, 2020

@MSeal
Contributor

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

auxym commented on Dec 13, 2021

@auxym

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    format:Notebookpertains to exporting to the Notebook format

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

      Participants

      @jamesmyatt@MSeal@auxym@mydmdm@t-makaro

      Issue actions

        nbconvert to notebook doesn't respect line endings · Issue #1062 · jupyter/nbconvert