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

trailing newline not preserved in splitline ipynb #1545

Closed
minrk opened this issue Apr 2, 2012 · 0 comments
Closed

trailing newline not preserved in splitline ipynb #1545

minrk opened this issue Apr 2, 2012 · 0 comments
Milestone

Comments

@minrk
Copy link
Member

minrk commented Apr 2, 2012

We use splitlines() on probable multi-line blocks for nicer ipynb files. But there is a small ambiguity, in that 0 or 1 trailing newlines produce identical output. The only place this really matters is multiple sequential stdout messages.

For instance, run a notebook with the following cell:

for i in range(5):
    print i,
    sys.stdout.flush()

print '--'

for i in range(5,10):
    print i
    sys.stdout.flush()

Then save & reload. The new output will have 56789 on one line, instead of on 5 lines like the original output.

PR #1480 now contains a fix, which is replacing item.splitlines() with (item+'\n').splitlines(), which is the true inverse of '\n'.join(lines).

@fperez fperez closed this as completed in c4cf940 Apr 15, 2012
mattvonrocketstein pushed a commit to mattvonrocketstein/ipython that referenced this issue Nov 3, 2014
Fix %notebook magic, etc. nbformat unicode tests and fixes.

* json.writes always gives unicode, so that `current.writes` can be trusted to give the same interface
* setup base TestCase for nbformat tests, to consolidate code, and better test both file formats
* add tests for reading/writing to files
* allow `name` as kwarg to new_notebook to avoid unnecessary breakage of previous API.
* remove fallback to xml, which would hide corrupt notebook files behind a nonsensical 'xml unsupported' message.

Closes ipython#1545, ipython#1487.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants