revealhelp.py
50 lines
| 2.0 KiB
| text/x-python
|
PythonLexer
Jonathan Frederic
|
r10674 | """Module that pre-processes the notebook for export via Reveal. | |
""" | |||
#----------------------------------------------------------------------------- | |||
# Copyright (c) 2013, the IPython Development Team. | |||
# | |||
# Distributed under the terms of the Modified BSD License. | |||
# | |||
# The full license is in the file COPYING.txt, distributed with this software. | |||
#----------------------------------------------------------------------------- | |||
#----------------------------------------------------------------------------- | |||
# Imports | |||
#----------------------------------------------------------------------------- | |||
Jonathan Frederic
|
r10624 | from .base import ConfigurableTransformer | |
Jonathan Frederic
|
r10437 | ||
Jonathan Frederic
|
r10674 | #----------------------------------------------------------------------------- | |
# Classes and functions | |||
#----------------------------------------------------------------------------- | |||
Jonathan Frederic
|
r10624 | class RevealHelpTransformer(ConfigurableTransformer): | |
Jonathan Frederic
|
r10437 | ||
damianavila
|
r10851 | def call(self, nb, resources): | |
Jonathan Frederic
|
r10674 | """ | |
Called once to 'transform' contents of the notebook. | |||
Parameters | |||
---------- | |||
nb : NotebookNode | |||
Notebook being converted | |||
resources : dictionary | |||
Additional resources used in the conversion process. Allows | |||
transformers to pass variables into the Jinja engine. | |||
""" | |||
Jonathan Frederic
|
r10437 | for worksheet in nb.worksheets : | |
for i, cell in enumerate(worksheet.cells): | |||
damianavila
|
r10823 | ||
#Make sure the cell has slideshow metadata. | |||
cell.metadata.slide_type = cell.get('metadata', {}).get('slideshow', {}).get('slide_type', '-') | |||
Jonathan Frederic
|
r10674 | #Get the slide type. If type is start of subslide or slide, | |
#end the last subslide/slide. | |||
Jonathan Frederic
|
r10437 | if cell.metadata.slide_type in ['slide']: | |
worksheet.cells[i - 1].metadata.slide_helper = 'slide_end' | |||
if cell.metadata.slide_type in ['subslide']: | |||
worksheet.cells[i - 1].metadata.slide_helper = 'subslide_end' | |||
Jonathan Frederic
|
r10674 | ||
return nb, resources | |||