Skip to content

Commit

Permalink
Pandoc 2.7.2
Browse files Browse the repository at this point in the history
  • Loading branch information
mwouts committed Apr 6, 2019
1 parent 172b910 commit 63014a9
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 15 deletions.
4 changes: 0 additions & 4 deletions jupytext/compare.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ def compare_notebooks(notebook_expected,
allow_missing_code_cell_metadata = allow_expected_differences and format_name == 'sphinx'
allow_missing_markdown_cell_metadata = allow_expected_differences and format_name in ['sphinx', 'spin']
allow_removed_final_blank_line = allow_expected_differences
replace_tabs_with_spaces = format_name == 'pandoc'

cell_metadata_filter = notebook_actual.get('jupytext', {}).get('cell_metadata_filter')

Expand All @@ -94,9 +93,6 @@ def compare_notebooks(notebook_expected,
modified_cells = set()
modified_cell_metadata = set()
for i, ref_cell in enumerate(notebook_expected.cells, 1):
if replace_tabs_with_spaces and '\t' in ref_cell.source:
ref_cell = copy(ref_cell)
ref_cell.source = ref_cell.source.replace('\t', ' ')
try:
test_cell = next(test_cell_iter)
except StopIteration:
Expand Down
4 changes: 2 additions & 2 deletions jupytext/formats.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ def get_format_implementation(ext, format_name=None):

if formats_for_extension:
if ext == '.md' and format_name == 'pandoc':
raise JupytextFormatError('Please install pandoc>=2.7.1')
raise JupytextFormatError('Please install pandoc>=2.7.2')

raise JupytextFormatError("Format '{}' is not associated to extension '{}'. "
"Please choose one of: {}.".format(format_name, ext,
Expand Down Expand Up @@ -270,7 +270,7 @@ def guess_format(text, ext):
if ext == '.md':
for line in lines:
if line.startswith(':::'): # Pandoc div
return 'pandoc'
return 'pandoc', {}

# Default format
return get_format_implementation(ext).format_name, {}
Expand Down
10 changes: 5 additions & 5 deletions jupytext/pandoc.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def pandoc(args, filein=None, fileout=None):


def is_pandoc_available():
"""Is Pandoc>=2.7.1 available?"""
"""Is Pandoc>=2.7.2 available?"""
try:
pandoc_version()
return True
Expand All @@ -44,8 +44,8 @@ def is_pandoc_available():
def pandoc_version():
"""Pandoc's version number"""
version = pandoc(u'--version').splitlines()[0].split()[1]
if parse_version(version) < parse_version('2.7.1'):
raise PandocError('Please install pandoc>=2.7.1 (found version {})'.format(version))
if parse_version(version) < parse_version('2.7.2'):
raise PandocError('Please install pandoc>=2.7.2 (found version {})'.format(version))

return version

Expand All @@ -56,7 +56,7 @@ def md_to_notebook(text):
tmp_file.write(text.encode('utf-8'))
tmp_file.close()

pandoc(u'--from markdown --to ipynb -s --atx-headers --wrap=preserve', tmp_file.name, tmp_file.name)
pandoc(u'--from markdown --to ipynb -s --atx-headers --wrap=preserve --preserve-tabs', tmp_file.name, tmp_file.name)

with open(tmp_file.name, encoding='utf-8') as opened_file:
notebook = nbformat.read(opened_file, as_version=4)
Expand All @@ -71,7 +71,7 @@ def notebook_to_md(notebook):
tmp_file.write(nbformat.writes(notebook).encode('utf-8'))
tmp_file.close()

pandoc(u'--from ipynb --to markdown -s --atx-headers --wrap=preserve', tmp_file.name, tmp_file.name)
pandoc(u'--from ipynb --to markdown -s --atx-headers --wrap=preserve --preserve-tabs', tmp_file.name, tmp_file.name)

with open(tmp_file.name, encoding='utf-8') as opened_file:
text = opened_file.read()
Expand Down
2 changes: 1 addition & 1 deletion tests/test_mirror.py
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,6 @@ def test_ipynb_to_md(nb_file):


@requires_pandoc
@pytest.mark.parametrize('nb_file', list_notebooks('ipynb', skip='(functional|Notebook with)'))
@pytest.mark.parametrize('nb_file', list_notebooks('ipynb', skip='(functional|Notebook with|flavors)'))
def test_ipynb_to_pandoc(nb_file):
assert_conversion_same_as_mirror(nb_file, 'md:pandoc', 'ipynb_to_pandoc')
1 change: 1 addition & 0 deletions tests/test_read_simple_pandoc.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
from testfixtures import compare
from nbformat.v4.nbbase import new_notebook, new_markdown_cell
from jupytext.compare import compare_notebooks
Expand Down
6 changes: 3 additions & 3 deletions tests/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ def tool_version(tool):
return None


requires_jupytext_installed = pytest.mark.skipif(not tool_version('jupytext'), reason='jupytext not installed')
requires_jupytext_installed = pytest.mark.skipif(not tool_version('jupytext'), reason='jupytext is not installed')
requires_black = pytest.mark.skipif(not tool_version('black'), reason='black not found')
requires_flake8 = pytest.mark.skipif(not tool_version('flake8'), reason='flake8 not found')
requires_autopep8 = pytest.mark.skipif(not tool_version('autopep8'), reason='autopep8 not found')
requires_sphinx_gallery = pytest.mark.skipif(not rst2md, reason='sphinx_gallery not available')
requires_pandoc = pytest.mark.skipif(not is_pandoc_available(), reason='pandoc>=2.7.1 not available')
requires_sphinx_gallery = pytest.mark.skipif(not rst2md, reason='sphinx_gallery is not available')
requires_pandoc = pytest.mark.skipif(not is_pandoc_available(), reason='pandoc>=2.7.2 is not available')


def list_notebooks(path='ipynb', skip='World'):
Expand Down

0 comments on commit 63014a9

Please sign in to comment.