Beispiel #1
0
    def convert(self):
        try:
            from IPython.nbformat.v3 import (new_notebook, new_worksheet,
                                             new_code_cell, new_text_cell,
                                             writes_json)

        except ImportError: # The `IPython.nbformat` package has been deprecated
            from nbformat.v3 import (new_notebook, new_worksheet,
                                     new_code_cell, new_text_cell,
                                     writes_json)

        ws = new_worksheet()

        for chunk in self.doc.parsed:
            if chunk["type"] == "doc":
                # TODO: this relies on pandoc converting into
                # markdown
                fmt = u'markdown'
                doc = self.format_docchunk(chunk['content'])
                ws.cells.append(new_text_cell(fmt, source=doc))
            if chunk["type"] == "code":
                lang = u'python'
                code = chunk['content']
                ws.cells.append(new_code_cell(input=code, language=lang))

        NB = new_notebook(name='Pweaved ipython notebook',
                          worksheets=[ws])

        self.converted = writes_json(NB)
Beispiel #2
0
    def convert(self):
        try:
            from IPython.nbformat.v3 import (new_notebook, new_worksheet,
                                             new_code_cell, new_text_cell,
                                             writes_json)

        except ImportError:  # The `IPython.nbformat` package has been deprecated
            from nbformat.v3 import (new_notebook, new_worksheet,
                                     new_code_cell, new_text_cell, writes_json)

        ws = new_worksheet()

        for chunk in self.doc.parsed:
            if chunk["type"] == "doc":
                # TODO: this relies on pandoc converting into
                # markdown
                fmt = u'markdown'
                doc = self.format_docchunk(chunk['content'])
                ws.cells.append(new_text_cell(fmt, source=doc))
            if chunk["type"] == "code":
                lang = u'python'
                code = chunk['content']
                ws.cells.append(new_code_cell(input=code, language=lang))

        NB = new_notebook(name='Pweaved ipython notebook', worksheets=[ws])

        self.converted = writes_json(NB)
def writes_json(nb, **kwargs):
    return v3.writes_json(nb, **kwargs)
Beispiel #4
0
def writes_json(nb, **kwargs):
    return v3.writes_json(nb, **kwargs)