diff --git a/converters/base.py b/converters/base.py index 5691dd3..3233f68 100755 --- a/converters/base.py +++ b/converters/base.py @@ -72,7 +72,7 @@ class Converter(object): files_dir = str() with_preamble = True user_preamble = None - output = str() + output = unicode() raw_as_verbatim = False def __init__(self, infile): @@ -140,6 +140,7 @@ class Converter(object): if not hasattr(self, 'nb'): self.read() self.output = self.convert() + assert(type(self.output) == unicode) return self.save() def read(self): diff --git a/converters/notebook.py b/converters/notebook.py index 541b0c0..cc4f0c9 100755 --- a/converters/notebook.py +++ b/converters/notebook.py @@ -1,4 +1,5 @@ from converters.base import Converter +from converters.utils import cell_to_lines from shutil import rmtree import json @@ -23,7 +24,7 @@ class ConverterNotebook(Converter): rmtree(self.files_dir) def convert(self): - return json.dumps(json.loads(Converter.convert(self, ',')), indent=1, sort_keys=True) + return unicode(json.dumps(json.loads(Converter.convert(self, ',')), indent=1, sort_keys=True)) def optional_header(self): s = \ diff --git a/converters/utils.py b/converters/utils.py index e36cfc5..5109461 100755 --- a/converters/utils.py +++ b/converters/utils.py @@ -1,8 +1,14 @@ from __future__ import print_function from lexers import IPythonLexer + import subprocess +import copy +import json import re + from IPython.utils.text import indent +from IPython.utils import path, py3compat +from IPython.nbformat.v3.nbjson import BytesEncoder #----------------------------------------------------------------------------- # Utility functions