Beispiel #1
0
def guide_worksheet(path):
    require_login()
    
    from IPython.nbformat import current as nbformat
    from IPython.nbconvert.exporters import RevealExporter
    from IPython.config import Config
    try:
        nb = nbformat.reads_json(file("notebooks/"+path).read())
    except IOError:
        return "Файл %s не найден" % (path)
    
    c = Config({
            'RevealHelpTransformer':{
                'enabled':True,
                'url_prefix':'reveal.js',
                },                
            })

    exportHtml = RevealExporter(config=c)
    (body,resources) = exportHtml.from_notebook_node(nb)

    return body.encode('utf-8')
Beispiel #2
0
from IPython.nbconvert.exporters import RevealExporter
from IPython.config import Config

from IPython.nbformat import current as nbformat

infile = "slides.ipynb" # load the name of your slideshow
outfile = "slides.reveal.html"

notebook = open(infile).read()
notebook_json = nbformat.reads_json(notebook)

# This is the config object I talked before, in the 'url_prefix', 
# you can set you proper location of your local reveal.js library,
# i.e. if the reveal.js is located in the same directory as your 
# your_slideshow.reveal.html, then set 'url_prefix':'reveal.js'.
c = Config({
            'RevealHelpTransformer':{
                'enabled':True,
                'url_prefix':'reveal.js',
                },                
            })

exportHtml = RevealExporter(config=c)
(body,resources) = exportHtml.from_notebook_node(notebook_json)

open(outfile, 'w').write(body.encode('utf-8'))
Beispiel #3
0
"""
from IPython.nbconvert.exporters import RevealExporter
from IPython.config import Config

from IPython.nbformat import current as nbformat

infile = "chapmanb_bosc2013_bcbio.ipynb"
outfile = "chapmanb_bosc2013_bcbio.html"

notebook = open(infile).read()
notebook_json = nbformat.reads_json(notebook)

c = Config({'RevealHelpTransformer': {'enabled': True,
                                      'url_prefix':'../reveal.js',},
            "CSSHTMLHeaderTransformer": {'enabled': False}
            })

exportHtml = RevealExporter(config=c)
(body,resources) = exportHtml.from_notebook_node(notebook_json)

with open(outfile, "w") as out_handle:
    in_css_override = False
    for line in body.encode('utf-8').split("\n"):
        if line.startswith("/* Overrides of notebook CSS"):
            in_css_override = True
        if in_css_override:
            if line.startswith("</style>"):
                in_css_override = False
        if not in_css_override:
            out_handle.write(line + "\n")