jupyter / nbconvert

Jupyter Notebook Conversion
https://nbconvert.readthedocs.io/
BSD 3-Clause "New" or "Revised" License
1.75k stars 569 forks source link

nbconvert strips leading newlines in code cells. #1238

Open BoPeng opened 4 years ago

BoPeng commented 4 years ago

When a code cell has a leading newline, nbconvert strips it.

Create a notebook with a single Python cell

image

convert to HTML and the first line is gone.

image

In my particular kernel, the leading newlines are significant so the automatic removal of the leading newlines caused some confusion. My understanding is that nbconvert should convert lines in code cells faithfully.

test_space.txt

Nbconvert version: nbconvert 5.6.1

mgeier commented 4 years ago

FYI, nbsphinx handles blank lines correctly, see e.g. https://nbsphinx.readthedocs.io/en/0.6.0/code-cells.html.

MSeal commented 4 years ago

I'm not sure why the code cells are manipulated here, thanks for raising the issue. I'll tag it for 6.0 and see if we can get it fixed by then.