Skip to content

Instantly share code, notes, and snippets.

@syrte
Last active April 15, 2019 14:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save syrte/e3b529a031af2998017bcc0249949f32 to your computer and use it in GitHub Desktop.
Save syrte/e3b529a031af2998017bcc0249949f32 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
import sys
import json
for file in sys.argv[1:]:
print('# file: %s' % file)
print('# vi: filetype=python')
print('')
code = json.load(open(file))
for cell in code['cells']:
if cell['cell_type'] == 'code':
print('# -------- code --------')
for line in cell['source']:
print(line, end='')
print('\n')
elif cell['cell_type'] == 'markdown':
print('# -------- markdown --------')
for line in cell['source']:
print("#", line, end='')
print('\n')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment