##// END OF EJS Templates
Merge pull request #8154 from takluyver/bigsplit-nbformat...
Merge pull request #8154 from takluyver/bigsplit-nbformat Big Split: nbformat -> jupyter_nbformat

File last commit:

r18580:ba8461eb
r20895:93f2e549 merge
Show More
revealhelp.py
62 lines | 2.6 KiB | text/x-python | PythonLexer
MinRK
update nbconvert to nbformat 4
r18580 """Module that pre-processes the notebook for export via Reveal."""
Jonathan Frederic
Cleanup and refactor, transformers
r10674
MinRK
update nbconvert to nbformat 4
r18580 # Copyright (c) IPython Development Team.
# Distributed under the terms of the Modified BSD License.
Jonathan Frederic
Cleanup and refactor, transformers
r10674
Paul Ivanov
replace 'transformer' with 'preprocessor'
r12219 from .base import Preprocessor
Thomas Kluyver
Fixes for nbconvert under Python 3
r13397 from IPython.utils.traitlets import Unicode
damianavila
Added white line after imports.
r11181
Jonathan Frederic
Cleanup and refactor, transformers
r10674
Paul Ivanov
replace 'transformer' with 'preprocessor'
r12219 class RevealHelpPreprocessor(Preprocessor):
Jonathan Frederic
Split transformer code
r10437
MinRK
use local reveal.js url prefix by default...
r12443 url_prefix = Unicode('reveal.js', config=True,
MinRK
remove special handling of speaker notes
r12439 help="""The URL prefix for reveal.js.
This can be a a relative URL for a local copy of reveal.js,
or point to a CDN.
MinRK
use local reveal.js url prefix by default...
r12443 For speaker notes to work, a local reveal.js prefix must be used.
MinRK
remove special handling of speaker notes
r12439 """
)
damianavila
Make configurable the url where look for reveal.js library.
r11179
Paul Ivanov
replace 'transformer' with 'preprocessor'
r12219 def preprocess(self, nb, resources):
Jonathan Frederic
Cleanup and refactor, transformers
r10674 """
Paul Ivanov
replace 'transformer' with 'preprocessor'
r12219 Called once to 'preprocess' contents of the notebook.
damianavila
Added some changes covering Mathias's commentaries.
r11183
Jonathan Frederic
Cleanup and refactor, transformers
r10674 Parameters
----------
nb : NotebookNode
Notebook being converted
resources : dictionary
Additional resources used in the conversion process. Allows
Paul Ivanov
replace 'transformer' with 'preprocessor'
r12219 preprocessors to pass variables into the Jinja engine.
Jonathan Frederic
Cleanup and refactor, transformers
r10674 """
damianavila
Added some changes covering Mathias's commentaries.
r11183
MinRK
update nbconvert to nbformat 4
r18580 for index, cell in enumerate(nb.cells):
#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, subslide, or slide,
# end the last subslide/slide.
if cell.metadata.slide_type in ['slide']:
nb.cells[index - 1].metadata.slide_helper = 'slide_end'
if cell.metadata.slide_type in ['subslide']:
nb.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']:
nb.cells[index].metadata.frag_number = index
i = 1
while i < len(nb.cells) - index:
nb.cells[index + i].metadata.frag_helper = 'fragment_end'
nb.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']:
nb.cells[index - 1].metadata.slide_helper = '-'
damianavila
Added some changes covering Mathias's commentaries.
r11183
Jonathan Frederic
Fixed, don't check using in since resources is a default dict.
r12143 if not isinstance(resources['reveal'], dict):
damianavila
Added look for key 'reveal' to not overwrite it.
r11184 resources['reveal'] = {}
damianavila
Added some changes covering Mathias's commentaries.
r11183 resources['reveal']['url_prefix'] = self.url_prefix
Jonathan Frederic
Cleanup and refactor, transformers
r10674 return nb, resources