Skip to content
This repository has been archived by the owner on Jun 28, 2021. It is now read-only.

Commit

Permalink
Merge 69e54fc into 3a87e26
Browse files Browse the repository at this point in the history
  • Loading branch information
Chilipp committed May 14, 2019
2 parents 3a87e26 + 69e54fc commit 074b51e
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 2 deletions.
10 changes: 8 additions & 2 deletions sphinx_nbexamples/__init__.py
Expand Up @@ -838,8 +838,14 @@ def recursive_processing(self, base_dir, target_dir, it):
if label:
labels[label] = nbps
s = ".. _%s:\n\n" % this_label
with open(os.path.join(file_dir, readme_file)) as f:
s += f.read().rstrip() + '\n\n'

if readme_file.endswith('.md'):
s += spr.check_output(
['pandoc', os.path.join(file_dir, readme_file),
'-t', 'rst']).decode('utf-8').rstrip() + '\n\n'
else:
with open(os.path.join(file_dir, readme_file)) as f:
s += f.read().rstrip() + '\n\n'

s += "\n\n.. toctree::\n\n"
s += ''.join(' %s\n' % os.path.splitext(os.path.basename(
Expand Down
@@ -1,2 +1,4 @@
Some additional examples in a subfolder
=======================================

This is [a markdown link](https://www.google.de/).
@@ -1,2 +1,4 @@
Some additional examples in a subfolder
=======================================

This is [a markdown link](https://www.google.de/).
9 changes: 9 additions & 0 deletions tests/test_sphinx_nbexamples.py
Expand Up @@ -191,6 +191,15 @@ def test_given_thumb(self):
msg=('The wrong picture has been chosen for '
'example_mpl_test_figure_chosen.ipynb'))

def test_md_readme(self):
"""Test the conversion of README.md"""
html_path = osp.join(self.out_dir, 'examples', 'sub', 'index.html')
self.assertTrue(osp.exists(html_path),
msg=html_path + ' is missing!')
with open(html_path) as f:
html = f.read()
self.assertIn('a markdown link</a>', html)


@unittest.skipIf(pathlib is None, 'The pathlib package is required!')
class TestLinkGalleries(BaseTest):
Expand Down

0 comments on commit 074b51e

Please sign in to comment.