Skip to content

Instantly share code, notes, and snippets.

@groakat
Forked from damianavila/using_local_reveal.ipynb
Last active December 20, 2015 10:30
Show Gist options
  • Save groakat/6115366 to your computer and use it in GitHub Desktop.
Save groakat/6115366 to your computer and use it in GitHub Desktop.
Changed RevealExporter to SlidesExporter to make it working with IPython 1.0
Display the source blob
Display the rendered blob
Raw
{
"metadata": {
"name": ""
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
{
"cell_type": "heading",
"level": 1,
"metadata": {},
"source": [
"IPython nbconvert slides exporter."
]
},
{
"cell_type": "heading",
"level": 2,
"metadata": {},
"source": [
"Using a local copy of reveal.js library."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"If you have low connectivity, it is better to load a local copy of the reveal.js library.\n",
"You can easily configure this behaviour using a config object from the IPython machinery.\n",
"Below, you have one way to do it:"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"from IPython.nbconvert.exporters import SlidesExporter\n",
"from IPython.config import Config\n",
"\n",
"from IPython.nbformat import current as nbformat\n",
"\n",
"infile = \"my_slideshow.ipynb\" # load the name of your slideshow\n",
"outfile = \"my_slideshow.slides.html\"\n",
"\n",
"notebook = open(infile).read()\n",
"notebook_json = nbformat.reads_json(notebook)\n",
"\n",
"# This is the config object I talked before, in the 'url_prefix', \n",
"# you can set you proper location of your local reveal.js library,\n",
"# i.e. if the reveal.js is located in the same directory as your \n",
"# your_slideshow.reveal.html, then set 'url_prefix':'reveal.js'.\n",
"#\n",
"# An empty 'url_prefix' will produce the default behaviour\n",
"c = Config({\n",
" 'RevealHelpTransformer':{\n",
" 'enabled':True,\n",
" 'url_prefix':'reveal.js',\n",
" }, \n",
" })\n",
"\n",
"exportHtml = SlidesExporter(config=c)\n",
"(body,resources) = exportHtml.from_notebook_node(notebook_json)\n",
"\n",
"open(outfile, 'w').write(body.encode('utf-8'))"
],
"language": "python",
"metadata": {},
"outputs": [],
"prompt_number": 10
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"**Enjoy!**\n",
"\n",
"**Dami\u00e1n Avila.**\n",
"\n",
"*(tiny adjustments for IPython 1.0 by Peter Rennert)*"
]
}
],
"metadata": {}
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment