diff --git a/converters/reveal.py b/converters/reveal.py index 0adc0ab..4682b1f 100644 --- a/converters/reveal.py +++ b/converters/reveal.py @@ -24,7 +24,10 @@ class ConverterReveal(ConverterMarkdown): return m_list def meta2str(self, meta): - meta_tuple = meta[u'slideshow'].items() + try: + meta_tuple = meta[u'slideshow'].items() + except KeyError as e: + meta_tuple = () meta_list = [[x + ' = ' + unicode(y)] for x, y in meta_tuple] meta_list = self.switch_meta(meta_list) return u'\n'.join(list(itertools.chain(*meta_list))) diff --git a/example_slide.ipynb b/example_slide.ipynb index b705225..36e3c3f 100644 --- a/example_slide.ipynb +++ b/example_slide.ipynb @@ -10,36 +10,46 @@ { "cell_type": "heading", "level": 1, - "metadata": {}, + "metadata": { + "slideshow": { + "new_section": true + } + }, "source": [ "Notebook Slide Example" ] }, { "cell_type": "markdown", - "metadata": {}, - "source": [ - "Rendered by vIPer using [Reveal.js](http://lab.hakim.se/reveal-js)!" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, + "metadata": { + "slideshow": { + "new_fragment": false + } + }, "source": [ - "(also you can get a [pdf](http://www.slideviper.oquanta.info/reveal/slides.pdf) version with chrome!)" + "Rendered by nbconvert using [Reveal.js](http://lab.hakim.se/reveal-js)!" ] }, { "cell_type": "markdown", - "metadata": {}, + "metadata": { + "slideshow": { + "new_fragment": true + } + }, "source": [ - "##<<<" + "by Dami\u00e1n Avila" ] }, { "cell_type": "heading", "level": 2, - "metadata": {}, + "metadata": { + "slideshow": { + "new_section": true, + "new_subsection": true + } + }, "source": [ "NOTE: This notebook was modified from a Fernando's one" ] @@ -53,28 +63,22 @@ }, { "cell_type": "markdown", - "metadata": {}, - "source": [ - "##---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, + "metadata": { + "slideshow": { + "new_subsection": true + } + }, "source": [ "The combination of easy editing in markdown with the notebook's ability to contain code, figures and results, makes it an ideal platform for quick authoring of technical documents, so being able to post to a blog is a natural request." ] }, { "cell_type": "markdown", - "metadata": {}, - "source": [ - "##---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, + "metadata": { + "slideshow": { + "new_subsection": true + } + }, "source": [ "Today, in answering a query about this from a colleague, I decided to try again the status of our conversion pipeline, and I'm happy to report that with a bit of elbow-grease, at least on Blogger things work pretty well! \n", "\n", @@ -82,16 +86,14 @@ ] }, { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "##>>><<<" - ] - }, - { "cell_type": "heading", "level": 2, - "metadata": {}, + "metadata": { + "slideshow": { + "new_section": true, + "new_subsection": true + } + }, "source": [ "Converting your notebook to html with nbconvert" ] @@ -109,28 +111,22 @@ }, { "cell_type": "markdown", - "metadata": {}, - "source": [ - "##---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, + "metadata": { + "slideshow": { + "new_subsection": true + } + }, "source": [ "This will leave two files in your computer, one named `your_notebook.html` and one named `your_noteboook_header.html`; it might also create a directory called `your_notebook_files` if needed for ancillary files. The first file will contain the body of your post and can be pasted wholesale into the Blogger editing area. The second file contains the CSS and Javascript material needed for the notebook to display correctly, you should only need to use this once to configure your blogger setup (see next):" ] }, { "cell_type": "markdown", - "metadata": {}, - "source": [ - "##---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, + "metadata": { + "slideshow": { + "new_subsection": true + } + }, "source": [ " # Only one notebook so far\n", " (master)longs[blog]> ls\n", @@ -147,16 +143,14 @@ ] }, { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "##>>><<<" - ] - }, - { "cell_type": "heading", "level": 2, - "metadata": {}, + "metadata": { + "slideshow": { + "new_section": true, + "new_subsection": true + } + }, "source": [ "Configuring your Blogger blog to accept notebooks" ] @@ -170,47 +164,71 @@ }, { "cell_type": "markdown", - "metadata": {}, + "metadata": { + "slideshow": { + "new_fragment": true, + "new_subsection": true + } + }, "source": [ - "##---" + "* Once authenticated, go to your blog's overview page by clicking on its title.\n", + "\n", + "\n" ] }, { "cell_type": "markdown", - "metadata": {}, + "metadata": { + "slideshow": { + "new_fragment": true + } + }, "source": [ - "1. Once authenticated, go to your blog's overview page by clicking on its title.\n", - "2. Click on templates (left column) and customize using the Advanced options.\n", - "3. Scroll down the middle column until you see an \"Add CSS\" option.\n", - "4. Copy entire the contents of the `_header` file into the CSS box." + "* Click on templates (left column) and customize using the Advanced options." ] }, { "cell_type": "markdown", - "metadata": {}, + "metadata": { + "slideshow": { + "new_fragment": true + } + }, "source": [ - "##---" + "* Scroll down the middle column until you see an \"Add CSS\" option." ] }, { "cell_type": "markdown", - "metadata": {}, + "metadata": { + "slideshow": { + "new_fragment": true + } + }, "source": [ - "That's it, and you shouldn't need to do anything else as long as the CSS we use in the notebooks doesn't drastically change. This customization of your blog needs to be done only once.\n", - "\n", - "While you are at it, I recommend you change the width of your blog so that cells have enough space for clean display; in experimenting I found out that the default template was too narrow to properly display code cells, producing a lot of text wrapping that impaired readability. I ended up using a layout with a single column for all blog contents, putting the blog archive at the bottom. Otherwise, if I kept the right sidebar, code cells got too squished in the post area." + "* Copy entire the contents of the `_header` file into the CSS box." ] }, { "cell_type": "markdown", - "metadata": {}, + "metadata": { + "slideshow": { + "new_subsection": true + } + }, "source": [ - "##---" + "That's it, and you shouldn't need to do anything else as long as the CSS we use in the notebooks doesn't drastically change. This customization of your blog needs to be done only once.\n", + "\n", + "While you are at it, I recommend you change the width of your blog so that cells have enough space for clean display; in experimenting I found out that the default template was too narrow to properly display code cells, producing a lot of text wrapping that impaired readability. I ended up using a layout with a single column for all blog contents, putting the blog archive at the bottom. Otherwise, if I kept the right sidebar, code cells got too squished in the post area." ] }, { "cell_type": "markdown", - "metadata": {}, + "metadata": { + "slideshow": { + "new_subsection": true + } + }, "source": [ "I also had problems using some of the fancier templates available from 'Dynamic Views', in that I could never get inline math to render. But sticking to those from the Simple or 'Picture Window' categories worked fine and they still allow for a lot of customization.\n", "\n", @@ -218,16 +236,13 @@ ] }, { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "##>>>" - ] - }, - { "cell_type": "heading", "level": 2, - "metadata": {}, + "metadata": { + "slideshow": { + "new_section": true + } + }, "source": [ "Adding the actual posts" ] @@ -242,16 +257,13 @@ ] }, { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "##---" - ] - }, - { "cell_type": "heading", "level": 2, - "metadata": {}, + "metadata": { + "slideshow": { + "new_section": true + } + }, "source": [ "What can you put in?" ] @@ -287,14 +299,11 @@ }, { "cell_type": "markdown", - "metadata": {}, - "source": [ - "##---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, + "metadata": { + "slideshow": { + "new_section": true + } + }, "source": [ "With pylab loaded, the usual matplotlib operations work" ] @@ -328,14 +337,11 @@ }, { "cell_type": "markdown", - "metadata": {}, - "source": [ - "##---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, + "metadata": { + "slideshow": { + "new_section": true + } + }, "source": [ "The notebook, thanks to MathJax, has great LaTeX support, so that you can type inline math $(1,\\gamma,\\ldots, \\infty)$ as well as displayed equations:\n", "\n", @@ -347,16 +353,14 @@ ] }, { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "##<<<" - ] - }, - { "cell_type": "heading", "level": 2, - "metadata": {}, + "metadata": { + "slideshow": { + "new_section": true, + "new_subsection": true + } + }, "source": [ "You can easily include formatted text and code with markdown" ] @@ -379,14 +383,11 @@ }, { "cell_type": "markdown", - "metadata": {}, - "source": [ - "##---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, + "metadata": { + "slideshow": { + "new_subsection": true + } + }, "source": [ "or other languages:\n", "\n", @@ -405,14 +406,11 @@ }, { "cell_type": "markdown", - "metadata": {}, - "source": [ - "##>>>" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, + "metadata": { + "slideshow": { + "new_section": true + } + }, "source": [ "And since the notebook can store displayed images in the file itself, you can show images which will be embedded in your post:" ] @@ -425,16 +423,13 @@ ] }, { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "##---" - ] - }, - { "cell_type": "heading", "level": 1, - "metadata": {}, + "metadata": { + "slideshow": { + "new_section": true + } + }, "source": [ "IPython rocks!" ]