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

empty line in notebook metadata section prevent it from openning #404

Closed
zhuoqiang opened this issue Dec 20, 2019 · 1 comment
Closed

empty line in notebook metadata section prevent it from openning #404

zhuoqiang opened this issue Dec 20, 2019 · 1 comment
Milestone

Comments

@zhuoqiang
Copy link
Contributor

zhuoqiang commented Dec 20, 2019

jupytext seems remove the indent space in empty lines when syncing the metadata from ipynb to python file. And empty line in YAML, while legal, prevent jupytext from working with error message:

Unreadable Notebook: c.py ScannerError('while scanning a quoted scalar', <yaml.error.Mark object at 0x7f9f90243190>, 'found unexpected end of stream', <yaml.error.Mark object at 0x7f9f90535be0>)

reproduce step:

  1. create a new python file with following content:
# ---
# jupyter:
#   jupytext:
#     cell_markers: '"""
#       
#       ,
#       
#       """'
#     formats: .notebook//ipynb,py:percent
#     notebook_metadata_filter: -all,jupytext
#     text_representation:
#       extension: .py
#       format_name: percent
# ---

it configs the jupytext to use percent format and """\n \n""" as the markdown seperator.
note that there are indent space in the two empty lines

  1. open the python file in jupyter notebook mode, it will open it successfully
  2. press the save button to save the file, in order to trigger jupytext to save the metadata back to python file
  3. you will notice that the indent space were removed in the two empty lines by jupytext
  4. refresh the notebook, or reopen it again, there's an error
Unreadable Notebook: c.py ScannerError('while scanning a quoted scalar', <yaml.error.Mark object at 0x7f9f90243190>, 'found unexpected end of stream', <yaml.error.Mark object at 0x7f9f90535be0>)
@zhuoqiang zhuoqiang changed the title notebook metadata saved in python does not preserve indent space for newline empty line in notebook metadata section prevent it from openning Dec 20, 2019
zhuoqiang added a commit to zhuoqiang/jupytext that referenced this issue Dec 20, 2019
empty line is legal in YAML config section
@mwouts mwouts added this to the 1.3.1 milestone Dec 21, 2019
@mwouts
Copy link
Owner

mwouts commented Dec 21, 2019

I see! Thank you @zhuoqiang for reporting this, and for the associated PR. I will review and integrate this soon.

@mwouts mwouts closed this as completed in 5a53b3d Dec 23, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants