Skip to content

Commit

Permalink
Reproduce and fix #1070
Browse files Browse the repository at this point in the history
  • Loading branch information
mwouts committed Jun 20, 2023
1 parent f9f1fef commit 919461f
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
9 changes: 8 additions & 1 deletion docs/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
Jupytext ChangeLog
==================

1.14.7-dev (2023-06-??)
-------------------

**Fixed**
- Fix opening of notebooks with empty YAML header ([#1070](https://github.com/mwouts/jupytext/issues/1070))


1.14.6 (2023-06-04)
-------------------

**Changed**
- This version comes with a build requirement `jupyterlab>=3,<4`, as the Jupyterlab
extension for Jupytext is not compatible with JupyterLab 4 yet (#1054)
extension for Jupytext is not compatible with JupyterLab 4 yet ([#1054](https://github.com/mwouts/jupytext/issues/1054))
- The JupyterLab extension was released to `npm` in version 1.3.9.

1.14.5 (2023-02-25)
Expand Down
2 changes: 2 additions & 0 deletions jupytext/formats.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,8 @@ def read_metadata(text, ext):
# MyST has the metadata at the root level
if not metadata and ext in myst_extensions() and text.startswith("---"):
for header in yaml.safe_load_all(text):
if not isinstance(header, dict):
continue
if (
header.get("jupytext", {})
.get("text_representation", {})
Expand Down
15 changes: 15 additions & 0 deletions tests/test_read_simple_markdown.py
Original file line number Diff line number Diff line change
Expand Up @@ -941,3 +941,18 @@ def test_hide_notebook_metadata(
compare(md2, md)
nb2 = jupytext.reads(md, "md")
compare_notebooks(nb2, nb)


def test_notebook_with_empty_header_1070(
md="""---
---
This file has empty frontmatter.
""",
):
nb = jupytext.reads(md, fmt="md:markdown")
md2 = jupytext.writes(nb, "md")
compare(md2, md)
nb2 = jupytext.reads(md, "md")
compare_notebooks(nb2, nb)

0 comments on commit 919461f

Please sign in to comment.