From e181fce21c083c4f1e70b744f097072c7d615441 2014-06-27 16:20:19 From: Min RK Date: 2014-06-27 16:20:19 Subject: [PATCH] Merge pull request #5957 from damianavila/fragments IPython slides: fragments are now in a linear flow and include next "-" cells. --- diff --git a/IPython/nbconvert/postprocessors/serve.py b/IPython/nbconvert/postprocessors/serve.py index 5051454..d2383be 100644 --- a/IPython/nbconvert/postprocessors/serve.py +++ b/IPython/nbconvert/postprocessors/serve.py @@ -53,7 +53,7 @@ class ServePostProcessor(PostProcessorBase): open_in_browser = Bool(True, config=True, help="""Should the browser be opened automatically?""" ) - reveal_cdn = Unicode("https://cdn.jsdelivr.net/reveal.js/2.5.0", config=True, + reveal_cdn = Unicode("https://cdn.jsdelivr.net/reveal.js/2.6.2", config=True, help="""URL for reveal.js CDN.""" ) reveal_prefix = Unicode("reveal.js", config=True, help="URL prefix for reveal.js") diff --git a/IPython/nbconvert/preprocessors/revealhelp.py b/IPython/nbconvert/preprocessors/revealhelp.py index fb39ed0..a4d90fe 100755 --- a/IPython/nbconvert/preprocessors/revealhelp.py +++ b/IPython/nbconvert/preprocessors/revealhelp.py @@ -49,13 +49,25 @@ class RevealHelpPreprocessor(Preprocessor): #Make sure the cell has slideshow metadata. cell.metadata.slide_type = cell.get('metadata', {}).get('slideshow', {}).get('slide_type', '-') - #Get the slide type. If type is start of subslide or slide, + #Get the slide type. If type is start of subslide or slide, #end the last subslide/slide. if cell.metadata.slide_type in ['slide']: worksheet.cells[index - 1].metadata.slide_helper = 'slide_end' if cell.metadata.slide_type in ['subslide']: worksheet.cells[index - 1].metadata.slide_helper = 'subslide_end' - + #Prevent the rendering of "do nothing" cells before fragments + #Group fragments passing frag_number to the data-fragment-index + if cell.metadata.slide_type in ['fragment']: + worksheet.cells[index].metadata.frag_number = index + i = 1 + while i < len(worksheet.cells) - index: + worksheet.cells[index + i].metadata.frag_helper = 'fragment_end' + worksheet.cells[index + i].metadata.frag_number = index + i += 1 + #Restart the slide_helper when the cell status is changed + #to other types. + if cell.metadata.slide_type in ['-', 'skip', 'notes', 'fragment']: + worksheet.cells[index - 1].metadata.slide_helper = '-' if not isinstance(resources['reveal'], dict): resources['reveal'] = {} diff --git a/IPython/nbconvert/preprocessors/tests/test_revealhelp.py b/IPython/nbconvert/preprocessors/tests/test_revealhelp.py index 829147c..07b27fc 100644 --- a/IPython/nbconvert/preprocessors/tests/test_revealhelp.py +++ b/IPython/nbconvert/preprocessors/tests/test_revealhelp.py @@ -28,11 +28,11 @@ class Testrevealhelp(PreprocessorTestsBase): """Contains test functions for revealhelp.py""" def build_notebook(self): - """Build a reveal slides notebook in memory for use with tests. + """Build a reveal slides notebook in memory for use with tests. Overrides base in PreprocessorTestsBase""" outputs = [nbformat.new_output(output_type="stream", stream="stdout", output_text="a")] - + slide_metadata = {'slideshow' : {'slide_type': 'slide'}} subslide_metadata = {'slideshow' : {'slide_type': 'subslide'}} @@ -56,7 +56,7 @@ class Testrevealhelp(PreprocessorTestsBase): def test_constructor(self): """Can a RevealHelpPreprocessor be constructed?""" self.build_preprocessor() - + def test_reveal_attribute(self): """Make sure the reveal url_prefix resources is set""" @@ -82,7 +82,8 @@ class Testrevealhelp(PreprocessorTestsBase): # Make sure slide end is only applied to the cells preceeding slide # cells. - assert 'slide_helper' not in cells[1].metadata + assert 'slide_helper' in cells[1].metadata + self.assertEqual(cells[1].metadata['slide_helper'], '-') # Verify 'slide-end' assert 'slide_helper' in cells[0].metadata diff --git a/IPython/nbconvert/templates/html/slides_reveal.tpl b/IPython/nbconvert/templates/html/slides_reveal.tpl index f27fc76..e2444f5 100644 --- a/IPython/nbconvert/templates/html/slides_reveal.tpl +++ b/IPython/nbconvert/templates/html/slides_reveal.tpl @@ -10,7 +10,13 @@
{{ super() }} {%- elif cell.metadata.slide_type in ['-'] -%} - {{ super() }} + {%- if cell.metadata.frag_helper in ['fragment_end'] -%} +
+ {{ super() }} +
+ {%- else -%} + {{ super() }} + {%- endif -%} {%- elif cell.metadata.slide_type in ['skip'] -%}
{{ super() }} @@ -20,7 +26,7 @@ {{ super() }} {%- elif cell.metadata.slide_type in ['fragment'] -%} -
+
{{ super() }}
{%- endif -%}