Skip to content

Commit

Permalink
Add support to Pandoc >= 2.11.2
Browse files Browse the repository at this point in the history
Pandoc replaced `--atx-headers` with `--markdown-headings=atx`.
  • Loading branch information
rgaiacs authored and mwouts committed Jul 30, 2023
1 parent a296996 commit 36eb877
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions jupytext/pandoc.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,13 @@ def md_to_notebook(text):
tmp_file.write(text.encode("utf-8"))
tmp_file.close()

parse_version = partial(parse, custom_error=PandocError)
if parse_version(pandoc_version()) < parse_version("2.11.2"):
pandoc_args = "--from markdown --to ipynb -s --atx-headers --wrap=preserve --preserve-tabs"
else:
pandoc_args = "--from markdown --to ipynb -s --markdown-headings=atx --wrap=preserve --preserve-tabs"
pandoc(
"--from markdown --to ipynb -s --atx-headers --wrap=preserve --preserve-tabs",
pandoc_args,
tmp_file.name,
tmp_file.name,
)
Expand All @@ -109,8 +114,13 @@ def notebook_to_md(notebook):
tmp_file.write(ipynb_writes(notebook).encode("utf-8"))
tmp_file.close()

parse_version = partial(parse, custom_error=PandocError)
if parse_version(pandoc_version()) < parse_version("2.11.2"):
pandoc_args = "--from ipynb --to markdown -s --atx-headers --wrap=preserve --preserve-tabs"
else:
pandoc_args = "--from ipynb --to markdown -s --markdown-headings=atx --wrap=preserve --preserve-tabs"
pandoc(
"--from ipynb --to markdown -s --atx-headers --wrap=preserve --preserve-tabs",
pandoc_args,
tmp_file.name,
tmp_file.name,
)
Expand Down

0 comments on commit 36eb877

Please sign in to comment.